D632: wrapfunction: use functools.partial if possible

2017-09-07 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5361771f9714: wrapfunction: use functools.partial if 
possible (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D632?vs=1678=1681

REVISION DETAIL
  https://phab.mercurial-scm.org/D632

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/extensions.py

CHANGE DETAILS

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import functools
 import imp
 import inspect
 import os
@@ -332,6 +333,7 @@
 
 def _updatewrapper(wrap, origfn, unboundwrapper):
 '''Copy and add some useful attributes to wrapper'''
+wrap.__name__ = origfn.__name__
 wrap.__module__ = getattr(origfn, '__module__')
 wrap.__doc__ = getattr(origfn, '__doc__')
 wrap.__dict__.update(getattr(origfn, '__dict__', {}))
@@ -459,7 +461,14 @@
 
 origfn = getattr(container, funcname)
 assert callable(origfn)
-wrap = bind(wrapper, origfn)
+if inspect.ismodule(container):
+# origfn is not an instance or class method. "partial" can be used.
+# "partial" won't insert a frame in traceback.
+wrap = functools.partial(wrapper, origfn)
+else:
+# "partial" cannot be safely used. Emulate its effect by using "bind".
+# The downside is one more frame in traceback.
+wrap = bind(wrapper, origfn)
 _updatewrapper(wrap, origfn, wrapper)
 setattr(container, funcname, wrap)
 return origfn
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -357,7 +357,10 @@
 return -1
 
 def aliasargs(fn, givenargs):
-args = getattr(fn, 'args', [])
+args = []
+# only care about alias 'args', ignore 'args' set by 
extensions.wrapfunction
+if not util.safehasattr(fn, '_origfunc'):
+args = getattr(fn, 'args', args)
 if args:
 cmd = ' '.join(map(util.shellquote, args))
 



To: quark, #hg-reviewers, phillco
Cc: martinvonz, phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D633: wrapcommand: use functools.partial

2017-09-07 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa763c891f36e: wrapcommand: use functools.partial (authored 
by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D633?vs=1679=1682

REVISION DETAIL
  https://phab.mercurial-scm.org/D633

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -377,7 +377,8 @@
 break
 
 origfn = entry[0]
-wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
+wrap = functools.partial(util.checksignature(wrapper),
+ util.checksignature(origfn))
 _updatewrapper(wrap, origfn, wrapper)
 if docstring is not None:
 wrap.__doc__ += docstring



To: quark, #hg-reviewers, phillco
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D633: wrapcommand: use functools.partial

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  Seems unlikely enough that someone passes a bound method as command wrapper. 
Queued.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D633

To: quark, #hg-reviewers, phillco
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D615: directaccess: store the access level in the ui object in dispatch

2017-09-07 Thread durham (Durham Goode)
durham added inline comments.

INLINE COMMENTS

> test-basic.t:4
>$ hg config
> +  extensions.fsmonitor= (fsmonitor !)
> +  _internal.hiddenlevel=0

Any idea why the order changed? Same for below

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D615

To: pulkit, #hg-reviewers, quark
Cc: durham, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D614: directaccess: make the hiddenlevel an attribute of the function

2017-09-07 Thread durham (Durham Goode)
durham added inline comments.

INLINE COMMENTS

> registrar.py:152
> +if hiddenlevel not in set([0, 1, 2]):
> +hiddenlevel = 0
> +func.hiddenlevel = hiddenlevel

Should we throw an exception instead?  Seems like a programmer error

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D614

To: pulkit, #hg-reviewers
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D644: rebase: remove complex unhiding code

2017-09-07 Thread durham (Durham Goode)
durham added a comment.


  I'd love to get rid of hidden filtering everywhere.  Just limit knowledge of 
"hidden" to getting the list of visible heads, and algorithms that need to 
traverse children.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D644

To: quark, #hg-reviewers
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D644: rebase: remove complex unhiding code

2017-09-07 Thread durham (Durham Goode)
durham added a comment.


  This sound reasonable, assuming all descendant/children computations are done 
before prepared is set.  Could you run the fb-hgext inhibit/fbamend tests with 
this change?  Since they might do some more interesting acrobatics around 
visibility changes.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D644

To: quark, #hg-reviewers
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D648: blackbox: fix rotation with chg

2017-09-07 Thread quark (Jun Wu)
quark added a comment.


  I think the original patch was trying to make different `ui` objects use a 
same file object if their `blackbox.log` path is the same. In theory it could 
also be problematic in the rotation case. Anyway, that becomes necessary after 
https://phab.mercurial-scm.org/D650.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D648

To: quark, #hg-reviewers
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D655: blackbox: set lastui even if ui.log is not called (issue5518)

2017-09-07 Thread durham (Durham Goode)
durham accepted this revision.
durham added a comment.


  It might be worth mentioning what lastui is use for in the commit message. I 
had to look at the code a little to remember what lastui did and why this was 
safe.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D655

To: quark, #hg-reviewers, durham
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D650: blackbox: do not cache file objects

2017-09-07 Thread durham (Durham Goode)
durham accepted this revision.
durham added inline comments.

INLINE COMMENTS

> blackbox.py:188
> +# do not restore _bbinlog intentionally to avoid failed
> +# logging again
> +else:

Might be worth mentioning this behavior change in the commit message.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D650

To: quark, #hg-reviewers, durham
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D648: blackbox: fix rotation with chg

2017-09-07 Thread durham (Durham Goode)
durham added a comment.


  This seems like mostly a revert of the original commit. timeless might have 
to chime in here, since it's not clear exactly what issue the original patch 
was fixing.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D648

To: quark, #hg-reviewers
Cc: durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D643: rebase: use unfiltered repo when loading state

2017-09-07 Thread quark (Jun Wu)
quark updated this revision to Diff 1680.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D643?vs=1641=1680

REVISION DETAIL
  https://phab.mercurial-scm.org/D643

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1301,3 +1301,73 @@
/
   o  0:426bada5c675 A
   
+For some reasons (--hidden, rebaseskipobsolete=0, directaccess, etc.),
+rebasestate may contain hidden hashes. "rebase --abort" should work regardless.
+
+  $ hg init $TESTTMP/hidden-state1
+  $ cd $TESTTMP/hidden-state1
+  $ cat >> .hg/hgrc < [experimental]
+  > rebaseskipobsolete=0
+  > EOF
+
+  $ hg debugdrawdag <<'EOS'
+  >C
+  >|
+  >  D B # prune: B, C
+  >  |/  # B/D=B
+  >  A
+  > EOS
+
+  $ eval `hg tags -T '{tag}={node}\n'`
+  $ rm .hg/localtags
+
+  $ hg update -q $C --hidden
+  $ hg rebase -s $B -d $D
+  rebasing 1:2ec65233581b "B"
+  merging D
+  warning: conflicts while merging D! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+  $ cp -R . $TESTTMP/hidden-state2
+
+  $ hg log -G
+  @  2:b18e25de2cf5 D
+  |
+  | @  1:2ec65233581b B
+  |/
+  o  0:426bada5c675 A
+  
+  $ hg summary
+  parent: 2:b18e25de2cf5 tip
+   D
+  parent: 1:2ec65233581b  (obsolete)
+   B
+  branch: default
+  commit: 2 modified, 1 unknown, 1 unresolved (merge)
+  update: (current)
+  phases: 3 draft
+  rebase: 0 rebased, 2 remaining (rebase --continue)
+
+  $ hg rebase --abort
+  rebase aborted
+
+Also test --continue for the above case
+
+  $ cd $TESTTMP/hidden-state2
+  $ hg resolve -m
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase --continue
+  rebasing 1:2ec65233581b "B"
+  rebasing 3:7829726be4dc "C" (tip)
+  $ hg log -G
+  @  5:1964d5d5b547 C
+  |
+  o  4:68deb90c12a2 B
+  |
+  o  2:b18e25de2cf5 D
+  |
+  o  0:426bada5c675 A
+  
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -198,7 +198,7 @@
 
 def restorestatus(self):
 """Restore a previously stored status"""
-repo = self.repo
+repo = self.repo.unfiltered()
 keepbranches = None
 legacydest = None
 collapse = False



To: quark, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D657: revset: move weight information to predicate

2017-09-07 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> phillco wrote in revset.py:256
> I take it this dictionary was moved there because of the import direction?

Yes.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D657

To: quark, #hg-reviewers, phillco
Cc: phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D632: wrapfunction: use functools.partial if possible

2017-09-07 Thread quark (Jun Wu)
quark marked an inline comment as done.
quark added a comment.


  Fixed. It's tricker than I though - Python 3 does not have "unbound function" 
concept and there is no easy way to detect "unbound function". So I changed 
approach to check `ismodule` instead, which seems to be more conservative and 
correct.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D632

To: quark, #hg-reviewers, phillco
Cc: martinvonz, phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D633: wrapcommand: use functools.partial

2017-09-07 Thread quark (Jun Wu)
quark updated this revision to Diff 1679.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D633?vs=1620=1679

REVISION DETAIL
  https://phab.mercurial-scm.org/D633

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -377,7 +377,8 @@
 break
 
 origfn = entry[0]
-wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
+wrap = functools.partial(util.checksignature(wrapper),
+ util.checksignature(origfn))
 _updatewrapper(wrap, origfn, wrapper)
 if docstring is not None:
 wrap.__doc__ += docstring



To: quark, #hg-reviewers, phillco
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D632: wrapfunction: use functools.partial if possible

2017-09-07 Thread quark (Jun Wu)
quark updated this revision to Diff 1678.
quark edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D632?vs=1619=1678

REVISION DETAIL
  https://phab.mercurial-scm.org/D632

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/extensions.py

CHANGE DETAILS

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import functools
 import imp
 import inspect
 import os
@@ -332,6 +333,7 @@
 
 def _updatewrapper(wrap, origfn, unboundwrapper):
 '''Copy and add some useful attributes to wrapper'''
+wrap.__name__ = origfn.__name__
 wrap.__module__ = getattr(origfn, '__module__')
 wrap.__doc__ = getattr(origfn, '__doc__')
 wrap.__dict__.update(getattr(origfn, '__dict__', {}))
@@ -459,7 +461,14 @@
 
 origfn = getattr(container, funcname)
 assert callable(origfn)
-wrap = bind(wrapper, origfn)
+if inspect.ismodule(container):
+# origfn is not an instance or class method. "partial" can be used.
+# "partial" won't insert a frame in traceback.
+wrap = functools.partial(wrapper, origfn)
+else:
+# "partial" cannot be safely used. Emulate its effect by using "bind".
+# The downside is one more frame in traceback.
+wrap = bind(wrapper, origfn)
 _updatewrapper(wrap, origfn, wrapper)
 setattr(container, funcname, wrap)
 return origfn
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -357,7 +357,10 @@
 return -1
 
 def aliasargs(fn, givenargs):
-args = getattr(fn, 'args', [])
+args = []
+# only care about alias 'args', ignore 'args' set by 
extensions.wrapfunction
+if not util.safehasattr(fn, '_origfunc'):
+args = getattr(fn, 'args', args)
 if args:
 cmd = ' '.join(map(util.shellquote, args))
 



To: quark, #hg-reviewers, phillco
Cc: martinvonz, phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D632: wrapfunction: use functools.partial if possible

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> extensions.py:464
>  assert callable(origfn)
> -wrap = bind(wrapper, origfn)
> +if util.safehasattr(origfn, 'im_self'):
> +# traditional bind, work with bound and unbound instancemethod, but

This patch makes test-py3-commands.t fail. I suspect it's because py3 has no 
"im_self".

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D632

To: quark, #hg-reviewers, phillco
Cc: martinvonz, phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: FYI: new emails from phabricator can be replied to

2017-09-07 Thread Jun Wu
Excerpts from Jun Wu's message of 2017-09-07 13:24:27 -0700:
> Excerpts from Augie Fackler's message of 2017-09-07 14:54:56 -0400:
> > Hopefully this means if you don't have a phabricator account, you can
> > still get comments attached to phabricator-sent patches.
> 
> By default Phabricator requires "From" address to match an existing user.
> 
> I think we can patch Phabricator to allow replying using a dummy user
> account if not registered.
> 
> diff --git a/src/applications/metamta/receiver/PhabricatorMailReceiver.php 
> b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
> index 05b44f364..2beb88119 100644
> --- a/src/applications/metamta/receiver/PhabricatorMailReceiver.php
> +++ b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
> @@ -100,6 +100,11 @@ abstract class PhabricatorMailReceiver extends Phobject {
>  
>  // Try to find a user with this email address.
>  $user = PhabricatorUser::loadOneWithEmailAddress($from);
> +if (!$user) {
> +  // Use a predefined fallback user
> +  $from = PhabricatorEnv::getEnvConfigIfExists('metamta.fallback-from');
> +  $user = PhabricatorUser::loadOneWithEmailAddress($from);
> +}
>  if ($user) {
>return $user;
>  } else {

Sorry but the above code missed a "null" check. I didn't have email infra to
test the patch but in theory it should work:


diff --git a/src/applications/metamta/receiver/PhabricatorMailReceiver.php 
b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
index 05b44f364..030962142 100644
--- a/src/applications/metamta/receiver/PhabricatorMailReceiver.php
+++ b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
@@ -100,6 +100,13 @@ abstract class PhabricatorMailReceiver extends Phobject {
 
 // Try to find a user with this email address.
 $user = PhabricatorUser::loadOneWithEmailAddress($from);
+if (!$user) {
+  // Use a predefined default user
+  $from = PhabricatorEnv::getEnvConfigIfExists('metamta.fallback-from');
+  if ($from) {
+$user = PhabricatorUser::loadOneWithEmailAddress($from);
+  }
+}
 if ($user) {
   return $user;
 } else {
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: FYI: new emails from phabricator can be replied to

2017-09-07 Thread Jun Wu
Excerpts from Augie Fackler's message of 2017-09-07 14:54:56 -0400:
> Hopefully this means if you don't have a phabricator account, you can
> still get comments attached to phabricator-sent patches.

By default Phabricator requires "From" address to match an existing user.

I think we can patch Phabricator to allow replying using a dummy user
account if not registered.

diff --git a/src/applications/metamta/receiver/PhabricatorMailReceiver.php 
b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
index 05b44f364..2beb88119 100644
--- a/src/applications/metamta/receiver/PhabricatorMailReceiver.php
+++ b/src/applications/metamta/receiver/PhabricatorMailReceiver.php
@@ -100,6 +100,11 @@ abstract class PhabricatorMailReceiver extends Phobject {
 
 // Try to find a user with this email address.
 $user = PhabricatorUser::loadOneWithEmailAddress($from);
+if (!$user) {
+  // Use a predefined fallback user
+  $from = PhabricatorEnv::getEnvConfigIfExists('metamta.fallback-from');
+  $user = PhabricatorUser::loadOneWithEmailAddress($from);
+}
 if ($user) {
   return $user;
 } else {

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[survey] How do you feel about Phabricator? Please take a survey!

2017-09-07 Thread Augie Fackler
If you don't care about how code contribution and review happens for Mercurial, 
you can stop reading now.

As you've probably noticed, we're experimenting with using Phabricator for 
contributing and reviewing patches. We're at a point now where we'd love to 
hear more broadly how people feel about Phabricator. We know it's been a rough 
experiment, but pending the outcome of this (and probably a chat at the 
sprint), we'll have a better sense of where we should go with review tooling, 
whether that's more investment on email, Phabricator, or both. Thanks!

https://goo.gl/forms/f6bFnp4bPk04tv4E2


signature.asc
Description: Message signed with OpenPGP
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D636: cmdutil: remove the redundant commit during amend

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  I fixed a few nits in flight and queued this. Thanks for cleaning this up!

INLINE COMMENTS

> cmdutil.py:3074-3078
> +matcher = scmutil.match(wctx, pats, opts)
> +if (opts.get('addremove')
> +and scmutil.addremove(repo, matcher, "", opts)):
> +raise error.Abort(
> +_("failed to mark all new/missing files as added/removed"))

Looks like this loses the dirstateguard from cmdutil.commit() (and duplicates 
the message). Perhaps it will be easier to let the caller do the addremove() 
call and the locking (it already does the locking, so the locking above seems 
unnecessary). Anyway, this seems fine for now.

> cmdutil.py:3080
> +
> +filestoamend = set([f for f in wctx.files() if matcher(f)])
> +

nit: No need to make a list and then a set, you should be able to just drop the 
brackets

> cmdutil.py:3104
> +# changes to other files from the old changeset.
> +if not path in filestoamend:
> +return old.filectx(path)

nit: usually written "path not in filestoamend"

> cmdutil.py:3195-3196
> +# and modified in the amend to "normal" in the dirstate.
> +normalfiles = set(
> +wctx.modified() + wctx.added()).intersection(filestoamend)
> +for f in normalfiles:

nit: i think we usually write "a & b" instead of "a.intersection(b)"

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D636

To: singhsrb, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D636: cmdutil: remove the redundant commit during amend

2017-09-07 Thread singhsrb (Saurabh Singh)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe8a7c1a0565a: cmdutil: remove the redundant commit during 
amend (authored by singhsrb).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D636?vs=1630=1676#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D636?vs=1630=1676

REVISION DETAIL
  https://phab.mercurial-scm.org/D636

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-amend.t
  tests/test-commit-amend.t
  tests/test-commit-interactive-curses.t
  tests/test-histedit-obsolete.t
  tests/test-log.t
  tests/test-obsmarker-template.t
  tests/test-obsolete.t
  tests/test-rebase-obsolete.t
  tests/test-treemanifest.t

CHANGE DETAILS

diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -862,7 +862,7 @@
   $ hg commit -Aqm 'pre-empty commit'
   $ hg rm z
   $ hg commit --amend -m 'empty commit'
-  saved backup bundle to 
$TESTTMP/grafted-dir-repo-clone/.hg/strip-backup/cb99d5717cea-de37743b-amend.hg 
(glob)
+  saved backup bundle to 
$TESTTMP/grafted-dir-repo-clone/.hg/strip-backup/cb99d5717cea-9e3b6b02-amend.hg 
(glob)
   $ hg log -r 'tip + tip^' -T '{manifest}\n'
   1:678d3574b88c
   1:678d3574b88c
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -626,11 +626,11 @@
   $ hg add M
   $ hg commit --amend -m "M"
   $ hg log -G
-  @  20:bfaedf8eb73b M
+  @  18:bfaedf8eb73b M
   |
-  | o  18:97219452e4bd L
+  | o  17:97219452e4bd L
   | |
-  | x  17:fc37a630c901 K
+  | x  16:fc37a630c901 K
   |/
   | o  15:5ae8a643467b J
   | |
@@ -660,8 +660,8 @@
   |/
   o  0:cd010b8cd998 A
   
-  $ hg rebase -s 14 -d 18 --config experimental.rebaseskipobsolete=True
-  note: not rebasing 14:9ad579b4a5de "I", already in destination as 
17:fc37a630c901 "K"
+  $ hg rebase -s 14 -d 17 --config experimental.rebaseskipobsolete=True
+  note: not rebasing 14:9ad579b4a5de "I", already in destination as 
16:fc37a630c901 "K"
   rebasing 15:5ae8a643467b "J"
 
   $ cd ..
@@ -797,9 +797,9 @@
   $ hg add foo
   $ hg commit -m "bar foo"
   $ hg log -G
-  @  15:73568ab6879d bar foo
+  @  14:73568ab6879d bar foo
   |
-  | o  14:77d874d096a2 10'
+  | o  13:77d874d096a2 10'
   | |
   | | o  12:3eb461388009 john doe
   | |/
@@ -814,7 +814,7 @@
   o  0:4a2df7238c3b A
   
   $ hg summary
-  parent: 15:73568ab6879d tip (orphan)
+  parent: 14:73568ab6879d tip (orphan)
bar foo
   branch: default
   commit: (clean)
@@ -826,9 +826,9 @@
   (to force the rebase please set experimental.allowdivergence=True)
   [255]
   $ hg log -G
-  @  15:73568ab6879d bar foo
+  @  14:73568ab6879d bar foo
   |
-  | o  14:77d874d096a2 10'
+  | o  13:77d874d096a2 10'
   | |
   | | o  12:3eb461388009 john doe
   | |/
@@ -846,9 +846,9 @@
 
   $ hg rebase -s 10 -d 12 --config experimental.allowdivergence=True
   rebasing 10:121d9e3bc4c6 "P"
-  rebasing 15:73568ab6879d "bar foo" (tip)
+  rebasing 14:73568ab6879d "bar foo" (tip)
   $ hg summary
-  parent: 17:61bd55f69bc4 tip
+  parent: 16:61bd55f69bc4 tip
bar foo
   branch: default
   commit: (clean)
@@ -859,8 +859,8 @@
 rebase --continue + skipped rev because their successors are in destination
 we make a change in trunk and work on conflicting changes to make rebase abort.
 
-  $ hg log -G -r 17::
-  @  17:61bd55f69bc4 bar foo
+  $ hg log -G -r 16::
+  @  16:61bd55f69bc4 bar foo
   |
   ~
 
@@ -873,7 +873,7 @@
   $ hg commit -m "dummy change successor"
 
 Create the changes that we will rebase
-  $ hg update -C 17 -q
+  $ hg update -C 16 -q
   $ printf "b" > willconflict
   $ hg add willconflict
   $ hg commit -m "willconflict second version"
@@ -884,25 +884,25 @@
   $ printf "dummy" > L
   $ hg add L
   $ hg commit -m "dummy change"
-  $ hg debugobsolete `hg log -r ".^" -T '{node}'` `hg log -r 19 -T '{node}'` 
--config experimental.stabilization=all
+  $ hg debugobsolete `hg log -r ".^" -T '{node}'` `hg log -r 18 -T '{node}'` 
--config experimental.stabilization=all
   obsoleted 1 changesets
 
-  $ hg log -G -r 17::
-  @  22:7bdc8a87673d dummy change
+  $ hg log -G -r 16::
+  @  21:7bdc8a87673d dummy change
   |
-  x  21:8b31da3c4919 dummy change
+  x  20:8b31da3c4919 dummy change
   |
-  o  20:b82fb57ea638 willconflict second version
+  o  19:b82fb57ea638 willconflict second version
   |
-  | o  19:601db7a18f51 dummy change successor
+  | o  18:601db7a18f51 dummy change successor
   | |
-  | o  18:357ddf1602d5 willconflict first version
+  | o  17:357ddf1602d5 willconflict first version
   |/
-  o  17:61bd55f69bc4 bar foo
+  o  16:61bd55f69bc4 bar foo
   |
   ~
-  $ hg rebase -r ".^^ + .^ + ." -d 19
-  rebasing 20:b82fb57ea638 "willconflict second version"
+  $ hg rebase -r ".^^ + .^ + ." -d 18
+  rebasing 19:b82fb57ea638 "willconflict second version"
   merging willconflict
   warning: conflicts while merging willconflict! (edit, then use 'hg 

D635: cmdutil: remove redundant commitfunc parameter in amend (API)

2017-09-07 Thread singhsrb (Saurabh Singh)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa39dce4a76b8: cmdutil: remove redundant commitfunc 
parameter in amend (API) (authored by singhsrb).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D635?vs=1629=1677

REVISION DETAIL
  https://phab.mercurial-scm.org/D635

AFFECTED FILES
  hgext/keyword.py
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -1213,11 +1213,9 @@
   > command = registrar.command(cmdtable)
   > @command(b"amendtransient",[], _('hg amendtransient [rev]'))
   > def amend(ui, repo, *pats, **opts):
-  >   def commitfunc(ui, repo, message, match, opts):
-  > return repo.commit(message, repo['.'].user(), repo['.'].date(), match)
   >   opts['message'] = 'Test'
   >   opts['logfile'] = None
-  >   cmdutil.amend(ui, repo, commitfunc, repo['.'], {}, pats, opts)
+  >   cmdutil.amend(ui, repo, repo['.'], {}, pats, opts)
   >   ui.write('%s\n' % repo.changelog.headrevs())
   > EOF
   $ cat >> $HGRCPATH << EOF
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1550,15 +1550,7 @@
 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
 cmdutil.checkunfinished(repo)
 
-# commitfunc is used only for temporary amend commit by cmdutil.amend
-def commitfunc(ui, repo, message, match, opts):
-return repo.commit(message,
-   opts.get('user') or old.user(),
-   opts.get('date') or old.date(),
-   match,
-   extra=extra)
-
-node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
+node = cmdutil.amend(ui, repo, old, extra, pats, opts)
 if node == old.node():
 ui.status(_("nothing changed\n"))
 return 1
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3026,8 +3026,7 @@
 else:
 return f not in ctx2.manifest()
 
-# TODO: remove the commitfunc parameter because it is no longer used
-def amend(ui, repo, commitfunc, old, extra, pats, opts):
+def amend(ui, repo, old, extra, pats, opts):
 # avoid cycle context -> subrepo -> cmdutil
 from . import context
 
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -614,14 +614,14 @@
 if kwt:
 kwt.match = origmatch
 
-def kw_amend(orig, ui, repo, commitfunc, old, extra, pats, opts):
+def kw_amend(orig, ui, repo, old, extra, pats, opts):
 '''Wraps cmdutil.amend expanding keywords after amend.'''
 kwt = getattr(repo, '_keywordkwt', None)
 if kwt is None:
-return orig(ui, repo, commitfunc, old, extra, pats, opts)
+return orig(ui, repo, old, extra, pats, opts)
 with repo.wlock():
 kwt.postcommit = True
-newid = orig(ui, repo, commitfunc, old, extra, pats, opts)
+newid = orig(ui, repo, old, extra, pats, opts)
 if newid != old.node():
 ctx = repo[newid]
 kwt.restrict = True



To: singhsrb, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


FYI: new emails from phabricator can be replied to

2017-09-07 Thread Augie Fackler
Kevin (TheMystic) and I finally figured out the requisite incantation to get 
phabricator emails to be reply-to-able. Unfortunately, the email handling in 
phabricator means that this will only work for *new* emails sent by 
phabricator, so you can only reply to new messages (more recent than about 5 
minutes before this email was sent), not old messages (which will respond to 
you with an error).

Hopefully this means if you don't have a phabricator account, you can still get 
comments attached to phabricator-sent patches. Please let us know if you 
encounter any problems.

Thanks!
Augie


signature.asc
Description: Message signed with OpenPGP
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D660: patchbomb: add test that shows --to and --cc override matching config item

2017-09-07 Thread durin42 (Augie Fackler)
durin42 added a comment.


  This is an email reply. Will it work?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D660

To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D660: patchbomb: add test that shows --to and --cc override matching config item

2017-09-07 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As far as I know this has always been true and is intentional (it's in
  line with many other behaviors), but it wasn't tested. Since I'm about
  to tweak To and Cc behavior pretty heavily, let's add a test.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D660

AFFECTED FILES
  tests/test-patchbomb.t

CHANGE DETAILS

diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -70,6 +70,45 @@
   +a
   
 
+If --to is specified on the command line, it should override any
+email.to config setting. Same for --cc:
+
+  $ hg email --date '1970-1-1 0:1' -n -f quux --to foo --cc bar -r tip \
+  >   --config email.to=b...@example.com --config email.cc=al...@example.com
+  this patch series consists of 1 patches.
+  
+  
+  displaying [PATCH] a ...
+  Content-Type: text/plain; charset="us-ascii"
+  MIME-Version: 1.0
+  Content-Transfer-Encoding: 7bit
+  Subject: [PATCH] a
+  X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  X-Mercurial-Series-Index: 1
+  X-Mercurial-Series-Total: 1
+  Message-Id: <8580ff50825a50c8f716...@augie-macbookpro2.roam.corp.google.com>
+  X-Mercurial-Series-Id: 
<8580ff50825a50c8f716...@augie-macbookpro2.roam.corp.google.com>
+  User-Agent: Mercurial-patchbomb/4.2.1+627-72f2cafb81e3
+  Date: Thu, 01 Jan 1970 00:01:00 +
+  From: quux
+  To: foo
+  Cc: bar
+  
+  # HG changeset patch
+  # User test
+  # Date 1 0
+  #  Thu Jan 01 00:00:01 1970 +
+  # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  # Parent  
+  a
+  
+  diff -r  -r 8580ff50825a a
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:01 1970 +
+  @@ -0,0 +1,1 @@
+  +a
+  
+
   $ hg --config ui.interactive=1 email --confirm -n -f quux -t foo -c bar -r 
tip< n
   > EOF



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D659: patchbomb: add test that shows --to and --cc override matching config item

2017-09-07 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As far as I know this has always been true and is intentional (it's in
  line with many other behaviors), but it wasn't tested. Since I'm about
  to tweak To and Cc behavior pretty heavily, let's add a test.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D659

AFFECTED FILES
  tests/test-patchbomb.t

CHANGE DETAILS

diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -70,6 +70,45 @@
   +a
   
 
+If --to is specified on the command line, it should override any
+email.to config setting. Same for --cc:
+
+  $ hg email --date '1970-1-1 0:1' -n -f quux --to foo --cc bar -r tip \
+  >   --config email.to=b...@example.com --config email.cc=al...@example.com
+  this patch series consists of 1 patches.
+  
+  
+  displaying [PATCH] a ...
+  Content-Type: text/plain; charset="us-ascii"
+  MIME-Version: 1.0
+  Content-Transfer-Encoding: 7bit
+  Subject: [PATCH] a
+  X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  X-Mercurial-Series-Index: 1
+  X-Mercurial-Series-Total: 1
+  Message-Id: <8580ff50825a50c8f716...@augie-macbookpro2.roam.corp.google.com>
+  X-Mercurial-Series-Id: 
<8580ff50825a50c8f716...@augie-macbookpro2.roam.corp.google.com>
+  User-Agent: Mercurial-patchbomb/4.2.1+627-72f2cafb81e3
+  Date: Thu, 01 Jan 1970 00:01:00 +
+  From: quux
+  To: foo
+  Cc: bar
+  
+  # HG changeset patch
+  # User test
+  # Date 1 0
+  #  Thu Jan 01 00:00:01 1970 +
+  # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  # Parent  
+  a
+  
+  diff -r  -r 8580ff50825a a
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/a  Thu Jan 01 00:00:01 1970 +
+  @@ -0,0 +1,1 @@
+  +a
+  
+
   $ hg --config ui.interactive=1 email --confirm -n -f quux -t foo -c bar -r 
tip< n
   > EOF



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D616: context: add overlayworkingcontext and overlayworkingfilectx

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> context.py:1987-1989
> +If `exists` is True, either `data` or `flags` must be non-None (either 
> both,
> +or just `flags`), and 'date' is non-None. If it is `False`, the file was
> +deleted.

It sounds like a shorter version of

  If `exists` is True, either `data` or `flags` must be non-None (either both, 
or just `flags`)

is

  If `exists` is True, `flags` must be non-None

> context.py:2007
> +else:
> +raise IOError("No such file or directory: %s" % self._path)
> +else:

maybe these IOErrors should be ProgrammingError?

> context.py:2029-2034
> +self._markdirty(path)
> +self._cache[path]['exists'] = True
> +self._cache[path]['data'] = data
> +self._cache[path]['date'] = util.makedate()
> +if flags is not None:
> +self._cache[path]['flags'] = flags

looks like this can be both simpler and more efficient if written with 
_markdirty() like this:

  def _markdirty(self, path, flags=None, exists=True, data=None, date=None)

> context.py:2035
> +self._cache[path]['flags'] = flags
> +pass
> +

a little unnecessary :-)

> context.py:2064
> +for path in self._writeorder:
> +if self._cache[path]['exists'] is True:
> +self._underlyingctx(path).clearunknown()

can reduce some repetition by extracting something like

  entry = self._cache[path]
  if entry['exists'] is True:
  data = entry['data']
  flags = entry['flags']
  ...

> context.py:2078
> +self._underlyingctx(path).remove(path)
> +else:
> +continue

doesn't seem like this can happen. i'd drop this and the "is True/False" in the 
conditions above

> context.py:2085
> +
> +def clean(self):
> +self._cache = {}

should this be "private"? seems kind of risky to call it outside of flushall()

> context.py:2093
> +'exists': None,
> +'data': None,
> +'flags': None,

you're not setting date here, which seems inconsistent

> context.py:2094
> +'data': None,
> +'flags': None,
> +}

i think no flags are usually expressed as empty string, not None, so i think we 
should at least make sure the return value of flags() follows that (and the 
simplest way of doing that is probably to change this line)

> context.py:2103
> +def _underlyingctx(self, path):
> +return self._wrappedctx.filectx(path)
> +

This can also be written "self._wrappedctx[path]", which seems similarly short 
and clear, so I'm not sure this method buys us much

> context.py:2126
> +def exists(self):
> +return self.lexists()
> +

Why is it safe to call lexists() here? I don't know how exists() is used, so 
it's not clear to me. Maybe add a comment (if it actually is safe)

> context.py:2145-2149
> +def flags(self):
> +return self._parent.flags(self._path)
> +
> +def setflags(self, islink, isexec):
> +return self._parent.setflags(self._path, islink, isexec)

Unrelated to this patch, but this interface seems pretty uglily asymmetric 
(flags() returns a string of character flags, setflags() take two boolean 
flags). And that's why you're forced to make the flag handling in your 
setflags() above ugly.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D616

To: phillco, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D657: revset: move weight information to predicate

2017-09-07 Thread phillco (Phil Cohen)
phillco accepted this revision.
phillco added a comment.


  lgtm

INLINE COMMENTS

> revset.py:256
>  #   x - argument in tree form
> -symbols = {}
> +symbols = revsetlang.symbols
>  

I take it this dictionary was moved there because of the import direction?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D657

To: quark, #hg-reviewers, phillco
Cc: phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D613: dispatch: store the command name which is going to run in ui object

2017-09-07 Thread quark (Jun Wu)
quark added a comment.


  In https://phab.mercurial-scm.org/D613#10670, @yuja wrote:
  
  > Perhaps it could be a read-only flag (or class) set to repo object?
  
  
  Yes. It seems `repo.filtername` may be a reasonable choice.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D613

To: pulkit, #hg-reviewers
Cc: quark, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D449: merge: pass wctx to premerge, filemerge

2017-09-07 Thread phillco (Phil Cohen)
phillco added a comment.


  I thought this wasn't needed, but it is.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D449

To: phillco, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D628: merge: flush any deferred writes before, and after, running any workers

2017-09-07 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1672.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D628?vs=1669=1672

REVISION DETAIL
  https://phab.mercurial-scm.org/D628

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -,6 +,10 @@
 
 _warnifmissingcwd(repo, cwd)
 
+# It's necessary to flush here in case we're inside a worker fork and will
+# quit after this function.
+_flushifdeferred(wctx)
+
 def batchget(repo, mctx, wctx, actions):
 """apply gets to the working directory
 
@@ -1146,6 +1150,10 @@
 if i > 0:
 yield i, f
 
+# It's necessary to flush here in case we're inside a worker fork and will
+# quit after this function.
+_flushifdeferred(wctx)
+
 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
 """apply the merge action list to the working directory
 
@@ -1214,6 +1222,10 @@
 progress(_updating, z, item=item, total=numupdates, unit=_files)
 removed = len(actions['r'])
 
+# We should flush before forking into worker processes, since those workers
+# flush when they complete, and we don't want to duplicate work.
+_flushifdeferred(wctx)
+
 # get in parallel
 prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx, wctx),
  actions['g'])
@@ -1744,6 +1756,14 @@
 copies.duplicatecopies(repo, ctx.rev(), pctx.rev())
 return stats
 
+def _flushifdeferred(ctx):
+"""If ``ctx`` is an overlayworkingctx and queuing any writes, flushes those
+to disk. Otherwise no-ops.
+"""
+from . import context
+if isinstance(ctx, context.overlayworkingctx):
+ctx.flushall()
+
 def _getcwd():
 try:
 return pycompat.getcwd()



To: phillco, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D449: merge: pass wctx to premerge, filemerge

2017-09-07 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1670.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D449?vs=1298=1670

REVISION DETAIL
  https://phab.mercurial-scm.org/D449

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/filemerge.py
  mercurial/merge.py
  tests/failfilemerge.py

CHANGE DETAILS

diff --git a/tests/failfilemerge.py b/tests/failfilemerge.py
--- a/tests/failfilemerge.py
+++ b/tests/failfilemerge.py
@@ -9,7 +9,8 @@
 )
 
 def failfilemerge(filemergefn,
-  premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+  premerge, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=None):
 raise error.Abort("^C")
 return filemergefn(premerge, repo, mynode, orig, fcd, fco, fca, labels)
 
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -495,12 +495,14 @@
 f.close()
 else:
 wctx[dfile].remove(ignoremissing=True)
-complete, r, deleted = filemerge.premerge(self._repo, self._local,
-  lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.premerge(self._repo, wctx,
+  self._local, lfile, fcd,
+  fco, fca,
   labels=self._labels)
 else:
-complete, r, deleted = filemerge.filemerge(self._repo, self._local,
-   lfile, fcd, fco, fca,
+complete, r, deleted = filemerge.filemerge(self._repo, wctx,
+   self._local, lfile, fcd,
+   fco, fca,
labels=self._labels)
 if r is None:
 # no real conflict
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -626,7 +626,7 @@
 
 return b, c
 
-def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
+def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
 """perform a 3-way merge in the working directory
 
 premerge = whether this is a premerge
@@ -750,11 +750,13 @@
 def _workingpath(repo, ctx):
 return repo.wjoin(ctx.path())
 
-def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
+def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
+return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=labels)
 
-def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-return _filemerge(False, repo, mynode, orig, fcd, fco, fca, labels=labels)
+def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
+return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,
+  labels=labels)
 
 def loadinternalmerge(ui, extname, registrarobj):
 """Load internal merge tool from specified registrarobj
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -545,10 +545,10 @@
 
 # Override filemerge to prompt the user about how they wish to merge
 # largefiles. This will handle identical edits without prompting the user.
-def overridefilemerge(origfn, premerge, repo, mynode, orig, fcd, fco, fca,
+def overridefilemerge(origfn, premerge, repo, wctx, mynode, orig, fcd, fco, 
fca,
   labels=None):
 if not lfutil.isstandin(orig) or fcd.isabsent() or fco.isabsent():
-return origfn(premerge, repo, mynode, orig, fcd, fco, fca,
+return origfn(premerge, repo, wctx, mynode, orig, fcd, fco, fca,
   labels=labels)
 
 ahash = lfutil.readasstandin(fca).lower()



To: phillco, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D627: filemerge: flush if using deferred writes when running a merge tool

2017-09-07 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1671.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D627?vs=1668=1671

REVISION DETAIL
  https://phab.mercurial-scm.org/D627

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -666,6 +666,11 @@
 onfailure = _("merging %s failed!\n")
 precheck = None
 
+# Must flush any deferred contents if running an external merge tool.
+from . import context
+if isinstance(wctx, context.overlayworkingctx):
+wctx.flushall()
+
 toolconf = tool, toolpath, binary, symlink
 
 if mergetype == nomerge:



To: phillco, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D450: filemerge: add wctx to all internal tools

2017-09-07 Thread phillco (Phil Cohen)
phillco abandoned this revision.
phillco added a subscriber: martinvonz.
phillco added a comment.


  No longer needed thanks to @martinvonz's careful eye.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D450

To: phillco, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D628: merge: flush any deferred writes before, and after, running any workers

2017-09-07 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1669.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D628?vs=1609=1669

REVISION DETAIL
  https://phab.mercurial-scm.org/D628

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1109,6 +1109,10 @@
 
 _warnifmissingcwd(repo, cwd)
 
+# It's necessary to flush here in case we're inside a worker fork and will
+# quit after this function.
+_flushifdeferred(wctx)
+
 def batchget(repo, mctx, wctx, actions):
 """apply gets to the working directory
 
@@ -1144,6 +1148,10 @@
 if i > 0:
 yield i, f
 
+# It's necessary to flush here in case we're inside a worker fork and will
+# quit after this function.
+_flushifdeferred(wctx)
+
 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
 """apply the merge action list to the working directory
 
@@ -1212,6 +1220,10 @@
 progress(_updating, z, item=item, total=numupdates, unit=_files)
 removed = len(actions['r'])
 
+# We should flush before forking into worker processes, since those workers
+# flush when they complete, and we don't want to duplicate work.
+_flushifdeferred(wctx)
+
 # get in parallel
 prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx, wctx),
  actions['g'])
@@ -1742,6 +1754,14 @@
 copies.duplicatecopies(repo, ctx.rev(), pctx.rev())
 return stats
 
+def _flushifdeferred(ctx):
+"""If ``ctx`` is an overlayworkingctx and queuing any writes, flushes those
+to disk. Otherwise no-ops.
+"""
+from . import context
+if isinstance(ctx, context.overlayworkingctx):
+ctx.flushall()
+
 def _getcwd():
 try:
 return pycompat.getcwd()



To: phillco, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D627: filemerge: flush if using deferred writes when running a merge tool

2017-09-07 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1668.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D627?vs=1608=1668

REVISION DETAIL
  https://phab.mercurial-scm.org/D627

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -666,6 +666,11 @@
 onfailure = _("merging %s failed!\n")
 precheck = None
 
+# Must flush any deferred contents if running an external merge tool.
+from . import context
+if isinstance(wctx, context.overlayworkingctx):
+wctx.flushall()
+
 toolconf = tool, toolpath, binary, symlink
 
 if mergetype == nomerge:



To: phillco, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D657: revset: move weight information to predicate

2017-09-07 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Previously revset weight is hardcoded and cannot be modified. This patch
  moves it to predicate so newly registered revsets could define their weight
  to properly give static optimization some hint.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D657

AFFECTED FILES
  mercurial/registrar.py
  mercurial/revset.py
  mercurial/revsetlang.py

CHANGE DETAILS

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -49,6 +49,8 @@
 
 keywords = {'and', 'or', 'not'}
 
+symbols = {}
+
 _quoteletters = {'"', "'"}
 _simpleopletters = set(pycompat.iterbytestr("()[]#:=,-|&+!~^%"))
 
@@ -441,21 +443,7 @@
 elif op == 'func':
 f = getsymbol(x[1])
 wa, ta = _optimize(x[2])
-if f in ('author', 'branch', 'closed', 'date', 'desc', 'file', 'grep',
- 'keyword', 'outgoing', 'user', 'destination'):
-w = 10 # slow
-elif f in ('modifies', 'adds', 'removes'):
-w = 30 # slower
-elif f == "contains":
-w = 100 # very slow
-elif f == "ancestor":
-w = 0.5
-elif f in ('reverse', 'limit', 'first', 'wdir', '_intlist'):
-w = 0
-elif f == "sort":
-w = 10 # assume most sorts look at changelog
-else:
-w = 1
+w = getattr(symbols.get(f), '_weight', 1)
 return w + wa, (op, x[1], ta)
 raise ValueError('invalid operator %r' % op)
 
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -253,7 +253,7 @@
 #   repo - current repository instance
 #   subset - of revisions to be examined
 #   x - argument in tree form
-symbols = {}
+symbols = revsetlang.symbols
 
 # symbols which can't be used for a DoS attack for any given input
 # (e.g. those which accept regexes as plain strings shouldn't be included)
@@ -276,7 +276,7 @@
 sourceset = getset(repo, fullreposet(repo), x)
 return subset & baseset([destutil.destmerge(repo, sourceset=sourceset)])
 
-@predicate('adds(pattern)', safe=True)
+@predicate('adds(pattern)', safe=True, weight=30)
 def adds(repo, subset, x):
 """Changesets that add a file matching pattern.
 
@@ -288,7 +288,7 @@
 pat = getstring(x, _("adds requires a pattern"))
 return checkstatus(repo, subset, pat, 1)
 
-@predicate('ancestor(*changeset)', safe=True)
+@predicate('ancestor(*changeset)', safe=True, weight=0.5)
 def ancestor(repo, subset, x):
 """A greatest common ancestor of the changesets.
 
@@ -394,7 +394,7 @@
 ps.add(r)
 return subset & ps
 
-@predicate('author(string)', safe=True)
+@predicate('author(string)', safe=True, weight=10)
 def author(repo, subset, x):
 """Alias for ``user(string)``.
 """
@@ -462,7 +462,7 @@
 bms -= {node.nullrev}
 return subset & bms
 
-@predicate('branch(string or set)', safe=True)
+@predicate('branch(string or set)', safe=True, weight=10)
 def branch(repo, subset, x):
 """
 All changesets belonging to the given branch or the branches of the given
@@ -595,16 +595,16 @@
 cs = _children(repo, subset, s)
 return subset & cs
 
-@predicate('closed()', safe=True)
+@predicate('closed()', safe=True, weight=10)
 def closed(repo, subset, x):
 """Changeset is closed.
 """
 # i18n: "closed" is a keyword
 getargs(x, 0, 0, _("closed takes no arguments"))
 return subset.filter(lambda r: repo[r].closesbranch(),
  condrepr='')
 
-@predicate('contains(pattern)')
+@predicate('contains(pattern)', weight=100)
 def contains(repo, subset, x):
 """The revision's manifest contains a file matching pattern (but might not
 modify it). See :hg:`help patterns` for information about file patterns.
@@ -654,7 +654,7 @@
 return subset.filter(lambda r: _matchvalue(r),
  condrepr=('', rev))
 
-@predicate('date(interval)', safe=True)
+@predicate('date(interval)', safe=True, weight=10)
 def date(repo, subset, x):
 """Changesets within the interval, see :hg:`help dates`.
 """
@@ -664,7 +664,7 @@
 return subset.filter(lambda x: dm(repo[x].date()[0]),
  condrepr=('', ds))
 
-@predicate('desc(string)', safe=True)
+@predicate('desc(string)', safe=True, weight=10)
 def desc(repo, subset, x):
 """Search commit message for string. The match is case-insensitive.
 
@@ -722,7 +722,7 @@
 # Like ``descendants(set)`` but follows only the first parents.
 return _descendants(repo, subset, x, followfirst=True)
 
-@predicate('destination([set])', safe=True)
+@predicate('destination([set])', safe=True, weight=10)
 def destination(repo, subset, x):
 """Changesets that were created by a graft, transplant or rebase operation,
 with the given revisions specified as the source.  

D656: revset: remove "small" argument from "_optimize"

2017-09-07 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `_optimize` calculates weights of subtrees. "small" affects some weight
  calculation (either 1 or 0). The weights are now only useful in `and`
  optimization where we might swap two arguments and use `andsmally`.
  
  In the real world, it seems unlikely that revsets with weight of 0.5 or 1
  matters the `and` order optimization. I think the important thing is to get
  weights of expensive revsets right (ex. `contains`).
  
  This patch removes the `small` argument to simplify the interface.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D656

AFFECTED FILES
  mercurial/revsetlang.py

CHANGE DETAILS

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -353,20 +353,16 @@
 """
 return _analyze(x)
 
-def _optimize(x, small):
+def _optimize(x):
 if x is None:
 return 0, x
 
-smallbonus = 1
-if small:
-smallbonus = .5
-
 op = x[0]
 if op in ('string', 'symbol'):
-return smallbonus, x # single revisions are small
+return 0.5, x # single revisions are small
 elif op == 'and':
-wa, ta = _optimize(x[1], True)
-wb, tb = _optimize(x[2], True)
+wa, ta = _optimize(x[1])
+wb, tb = _optimize(x[2])
 w = min(wa, wb)
 
 # (draft/secret/_notpublic() & ::x) have a fast path
@@ -397,12 +393,12 @@
 else:
 s = '\0'.join(t[1] for w, t in ss)
 y = _build('_list(_)', ('string', s))
-w, t = _optimize(y, False)
+w, t = _optimize(y)
 ws.append(w)
 ts.append(t)
 del ss[:]
 for y in getlist(x[1]):
-w, t = _optimize(y, False)
+w, t = _optimize(y)
 if t is not None and (t[0] == 'string' or t[0] == 'symbol'):
 ss.append((w, t))
 continue
@@ -416,44 +412,44 @@
 elif op == 'not':
 # Optimize not public() to _notpublic() because we have a fast version
 if _match('public()', x[1]):
-o = _optimize(_build('_notpublic()'), not small)
+o = _optimize(_build('_notpublic()'))
 return o[0], o[1]
 else:
-o = _optimize(x[1], not small)
+o = _optimize(x[1])
 return o[0], (op, o[1])
 elif op == 'rangeall':
-return smallbonus, x
+return 1, x
 elif op in ('rangepre', 'rangepost', 'parentpost'):
-o = _optimize(x[1], small)
+o = _optimize(x[1])
 return o[0], (op, o[1])
 elif op in ('dagrange', 'range'):
-wa, ta = _optimize(x[1], small)
-wb, tb = _optimize(x[2], small)
+wa, ta = _optimize(x[1])
+wb, tb = _optimize(x[2])
 return wa + wb, (op, ta, tb)
 elif op in ('parent', 'ancestor', 'relation', 'subscript'):
-w, t = _optimize(x[1], small)
+w, t = _optimize(x[1])
 return w, (op, t, x[2])
 elif op == 'relsubscript':
-w, t = _optimize(x[1], small)
+w, t = _optimize(x[1])
 return w, (op, t, x[2], x[3])
 elif op == 'list':
-ws, ts = zip(*(_optimize(y, small) for y in x[1:]))
+ws, ts = zip(*(_optimize(y) for y in x[1:]))
 return sum(ws), (op,) + ts
 elif op == 'keyvalue':
-w, t = _optimize(x[2], small)
+w, t = _optimize(x[2])
 return w, (op, x[1], t)
 elif op == 'func':
 f = getsymbol(x[1])
-wa, ta = _optimize(x[2], small)
+wa, ta = _optimize(x[2])
 if f in ('author', 'branch', 'closed', 'date', 'desc', 'file', 'grep',
  'keyword', 'outgoing', 'user', 'destination'):
 w = 10 # slow
 elif f in ('modifies', 'adds', 'removes'):
 w = 30 # slower
 elif f == "contains":
 w = 100 # very slow
 elif f == "ancestor":
-w = 1 * smallbonus
+w = 0.5
 elif f in ('reverse', 'limit', 'first', 'wdir', '_intlist'):
 w = 0
 elif f == "sort":
@@ -468,7 +464,7 @@
 
 All pseudo operations should be transformed beforehand.
 """
-_weight, newtree = _optimize(tree, small=True)
+_weight, newtree = _optimize(tree)
 return newtree
 
 # the set of valid characters for the initial letter of symbols in



To: quark, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D627: filemerge: flush if using deferred writes when running a merge tool

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> filemerge.py:500-503
> +# Must flush any deferred contents if running a merge tool.
> +from . import context
> +if isinstance(wctx, context.overlayworkingctx):
> +wctx.flushall()

As Phil and I talked about out-of-band, it seems like this can be done in 
_filemerge() instead (~line 677) and we won't need to pass the wctx to all the 
merge tools (i.e. drop https://phab.mercurial-scm.org/D450).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D627

To: phillco, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D641: cleanup: rename "matchfn" to "match" where obviously a matcher

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG08346a8fa65f: cleanup: rename "matchfn" to "match" where 
obviously a matcher (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D641?vs=1638=1663

REVISION DETAIL
  https://phab.mercurial-scm.org/D641

AFFECTED FILES
  hgext/largefiles/lfcommands.py
  hgext/mq.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -,13 +,13 @@
 
 ctx = webutil.changectx(web.repo, req)
 pats = []
-matchfn = scmutil.match(ctx, [])
+match = scmutil.match(ctx, [])
 file = req.form.get('file', None)
 if file:
 pats = ['path:' + file[0]]
-matchfn = scmutil.match(ctx, pats, default='path')
+match = scmutil.match(ctx, pats, default='path')
 if pats:
-files = [f for f in ctx.manifest().keys() if matchfn(f)]
+files = [f for f in ctx.manifest().keys() if match(f)]
 if not files:
 raise ErrorResponse(HTTP_NOT_FOUND,
 'file(s) not found: %s' % file[0])
@@ -1132,7 +1132,7 @@
 req.respond(HTTP_OK, mimetype)
 
 archival.archive(web.repo, req, cnode, artype, prefix=name,
- matchfn=matchfn,
+ matchfn=match,
  subrepos=web.configbool("web", "archivesubrepos"))
 return []
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -477,9 +477,9 @@
 prefix = os.path.basename(repo.root) + '-%h'
 
 prefix = cmdutil.makefilename(repo, prefix, node)
-matchfn = scmutil.match(ctx, [], opts)
+match = scmutil.match(ctx, [], opts)
 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
- matchfn, prefix, subrepos=opts.get('subrepos'))
+ match, prefix, subrepos=opts.get('subrepos'))
 
 @command('backout',
 [('', 'merge', None, _('merge with old dirstate parent after backout')),
@@ -2489,7 +2489,7 @@
 
 skip = {}
 revfiles = {}
-matchfn = scmutil.match(repo[None], pats, opts)
+match = scmutil.match(repo[None], pats, opts)
 found = False
 follow = opts.get('follow')
 
@@ -2530,7 +2530,7 @@
 
 ui.pager('grep')
 fm = ui.formatter('grep', opts)
-for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
+for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
 rev = ctx.rev()
 parent = ctx.p1().rev()
 for fn in sorted(revfiles.get(rev, [])):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2001,19 +2001,19 @@
 regular display via changeset_printer() is done.
 """
 # options
-matchfn = None
+match = None
 if opts.get('patch') or opts.get('stat'):
-matchfn = scmutil.matchall(repo)
+match = scmutil.matchall(repo)
 
 if opts.get('template') == 'json':
-return jsonchangeset(ui, repo, matchfn, opts, buffered)
+return jsonchangeset(ui, repo, match, opts, buffered)
 
 spec = _lookuplogtemplate(ui, opts.get('template'), opts.get('style'))
 
 if not spec.ref and not spec.tmpl and not spec.mapfile:
-return changeset_printer(ui, repo, matchfn, opts, buffered)
-
-return changeset_templater(ui, repo, spec, matchfn, opts, buffered)
+return changeset_printer(ui, repo, match, opts, buffered)
+
+return changeset_templater(ui, repo, spec, match, opts, buffered)
 
 def showmarker(fm, marker, index=None):
 """utility function to display obsolescence marker in a readable way
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1664,15 +1664,15 @@
 changes = repo.changelog.read(top)
 man = repo.manifestlog[changes[0]].read()
 aaa = aa[:]
-matchfn = scmutil.match(repo[None], pats, opts)
+match1 = scmutil.match(repo[None], pats, opts)
 # in short mode, we only diff the files included in the
 # patch already plus specified files
 if opts.get('short'):
 # if amending a patch, we start with existing
 # files plus specified files - unfiltered
-match = scmutil.matchfiles(repo, mm + aa + dd + 
matchfn.files())
+match = scmutil.matchfiles(repo, mm + aa + dd + match1.files())
 # filter with include/exclude options
-matchfn = scmutil.match(repo[None], opts=opts)
+match1 = scmutil.match(repo[None], opts=opts)
 else:
 match = scmutil.matchall(repo)
 m, a, r, d = repo.status(match=match)[:4]
@@ 

D639: amend: use context manager for config override

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5dc6ac6555e6: amend: use context manager for config 
override (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D639?vs=1636=1661

REVISION DETAIL
  https://phab.mercurial-scm.org/D639

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -35,7 +35,6 @@
 obsolete,
 patch,
 pathutil,
-phases,
 pycompat,
 registrar,
 revlog,
@@ -3162,16 +3161,13 @@
 # This not what we expect from amend.
 return old.node()
 
-ph = repo.ui.config('phases', 'new-commit', phases.draft)
-try:
-if opts.get('secret'):
-commitphase = 'secret'
-else:
-commitphase = old.phase()
-repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
+if opts.get('secret'):
+commitphase = 'secret'
+else:
+commitphase = old.phase()
+overrides = {('phases', 'new-commit'): commitphase}
+with ui.configoverride(overrides, 'amend'):
 newid = repo.commitctx(new)
-finally:
-repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
 
 # Reroute the working copy parent to the new changeset
 repo.setparents(newid, nullid)



To: martinvonz, #hg-reviewers, singhsrb
Cc: singhsrb, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D642: checknlink: rename file object from 'fd' to 'fp'

2017-09-07 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6c5cdb02f2f9: checknlink: rename file object from 'fd' to 
'fp' (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D642?vs=1639=1664

REVISION DETAIL
  https://phab.mercurial-scm.org/D642

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1457,24 +1457,23 @@
 
 # testfile may be open, so we need a separate file for checking to
 # work around issue2543 (or testfile may get lost on Samba shares)
-f1, f2, fd = None, None, None
+f1, f2, fp = None, None, None
 try:
 fd, f1 = tempfile.mkstemp(prefix='.%s-' % os.path.basename(testfile),
   suffix='1~', dir=os.path.dirname(testfile))
 os.close(fd)
-fd = None
 f2 = '%s2~' % f1[:-2]
 
 oslink(f1, f2)
 # nlinks() may behave differently for files on Windows shares if
 # the file is open.
-fd = posixfile(f2)
+fp = posixfile(f2)
 return nlinks(f2) > 1
 except OSError:
 return False
 finally:
-if fd is not None:
-fd.close()
+if fp is not None:
+fp.close()
 for f in (f1, f2):
 try:
 if f is not None:



To: quark, #hg-reviewers, phillco
Cc: phillco, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D638: amend: delete dead assignment to "newid"

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4059b10d7490: amend: delete dead assignment to "newid" 
(authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D638?vs=1635=1660

REVISION DETAIL
  https://phab.mercurial-scm.org/D638

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3163,7 +3163,6 @@
 return old.node()
 
 ph = repo.ui.config('phases', 'new-commit', phases.draft)
-newid = None
 try:
 if opts.get('secret'):
 commitphase = 'secret'



To: martinvonz, #hg-reviewers, singhsrb
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D637: check-code: fix incorrect capitalization in camelcase regex

2017-09-07 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGba6e14f9a2d8: check-code: fix incorrect capitalization in 
camelcase regex (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D637?vs=1634=1662

REVISION DETAIL
  https://phab.mercurial-scm.org/D637

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -262,7 +262,7 @@
 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
 #(r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
 # "don't use underbars in identifiers"),
-(r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
+(r'^\s+(self\.)?[A-Za-z][a-z0-9]+[A-Z]\w* = ',
  "don't use camelcase in identifiers"),
 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
  "linebreak after :"),



To: martinvonz, #hg-reviewers, quark
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D612: directaccess: add a hiddenlevel argument to registrar.command

2017-09-07 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> durham wrote in registrar.py:142
> I think an enum would be better here (UNRECOVERABLE_WRITE, RECOVERABLE_WRITE, 
> READ_ONLY).  Especially because I think people generally copy and paste the 
> registrar decorators from other functions, and if we're just specifying 
> numbers they are more likely to just reuse whatever value they copied.

nod. registrar.internalmerge() has a good example of pseudo enum.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D612

To: pulkit, #hg-reviewers
Cc: yuja, durham, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D613: dispatch: store the command name which is going to run in ui object

2017-09-07 Thread yuja (Yuya Nishihara)
yuja added a comment.


  In https://phab.mercurial-scm.org/D613#10467, @quark wrote:
  
  > This is for directaccess as directaccess originally designed 
(https://www.mercurial-scm.org/repo/evolve/rev/b8f880d417)
  >
  > It may be cleaner to use a flag of `scmutil.rev*` instead. So commands 
themselves could decide whether to enable directaccess or not.
  
  
  Perhaps it could be a read-only flag (or class) set to repo object?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D613

To: pulkit, #hg-reviewers
Cc: quark, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D623: copytrace: move fast heuristic copytracing algorithm to core

2017-09-07 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> pulkit wrote in copies.py:638
> I am sorry but I didn't understand the `base were in other side` thing. Did 
> you mean base is a child of ctx?

//In theory//, base could be anywhere between c1 and c2. If it belonged to the 
c1 branch, c2.p1().p1()... would never reach
to it.

  o c1 (wctx)
  |
  o base
  |
  :  o c2
  | /
  o anc

This won't happen in production because base is set to c2.p1(),
but it's better to break a possible infinite loop.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D623

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] debuginstall: do not pass exception object to formatter (issue5676)

2017-09-07 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1504791414 -32400
#  Thu Sep 07 22:36:54 2017 +0900
# Node ID 3573b95ec1f32805bde3a08b1f4f7dca8e3d699f
# Parent  5fda73a5468d3789bccdcb2da6d6b56e5ca2410b
debuginstall: do not pass exception object to formatter (issue5676)

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1000,7 +1000,7 @@ def debuginstall(ui, **opts):
 try:
 codecs.lookup(pycompat.sysstr(encoding.encoding))
 except LookupError as inst:
-err = inst
+err = util.forcebytestr(inst)
 problems += 1
 fm.condwrite(err, 'encodingerror', _(" %s\n"
  " (check that your locale is properly set)\n"), err)
@@ -1056,7 +1056,7 @@ def debuginstall(ui, **opts):
 )
 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
 except Exception as inst:
-err = inst
+err = util.forcebytestr(inst)
 problems += 1
 fm.condwrite(err, 'extensionserror', " %s\n", err)
 
@@ -1088,7 +1088,7 @@ def debuginstall(ui, **opts):
 try:
 templater.templater.frommapfile(m)
 except Exception as inst:
-err = inst
+err = util.forcebytestr(inst)
 p = None
 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
 else:
@@ -1124,7 +1124,7 @@ def debuginstall(ui, **opts):
 try:
 username = ui.username()
 except error.Abort as e:
-err = e
+err = util.forcebytestr(e)
 problems += 1
 
 fm.condwrite(username, 'username',  _("checking username (%s)\n"), 
username)
diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -81,6 +81,14 @@ hg debuginstall with invalid encoding
   checking encoding (invalidenc)...
unknown encoding: invalidenc
 
+exception message in JSON
+
+  $ HGENCODING=invalidenc HGUSER= hg debuginstall -Tjson | grep error
+"defaulttemplateerror": null,
+"encodingerror": "unknown encoding: invalidenc",
+"extensionserror": null, (no-pure !)
+"usernameerror": "no username supplied",
+
 path variables are expanded (~ is the same as $TESTTMP)
   $ mkdir tools
   $ touch tools/testeditor.exe
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] debuginstall: use codecs.lookup() to detect invalid encoding

2017-09-07 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1504790843 -32400
#  Thu Sep 07 22:27:23 2017 +0900
# Node ID 5fda73a5468d3789bccdcb2da6d6b56e5ca2410b
# Parent  1104718fb0907a4a841e6a24006c0c7fcb9caa9e
debuginstall: use codecs.lookup() to detect invalid encoding

encoding.fromlocal() never tries to decode an ascii string since 853574db5b12,
and there's no universal non-ascii string which can be decoded as any valid
character set.

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import codecs
 import collections
 import difflib
 import errno
@@ -997,8 +998,8 @@ def debuginstall(ui, **opts):
 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
 err = None
 try:
-encoding.fromlocal("test")
-except error.Abort as inst:
+codecs.lookup(pycompat.sysstr(encoding.encoding))
+except LookupError as inst:
 err = inst
 problems += 1
 fm.condwrite(err, 'encodingerror', _(" %s\n"
diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -76,6 +76,11 @@ hg debuginstall with no username
   1 problems detected, please check your install!
   [1]
 
+hg debuginstall with invalid encoding
+  $ HGENCODING=invalidenc hg debuginstall | grep encoding
+  checking encoding (invalidenc)...
+   unknown encoding: invalidenc
+
 path variables are expanded (~ is the same as $TESTTMP)
   $ mkdir tools
   $ touch tools/testeditor.exe
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D624: copytrace: move the full copytracing algorithm under 'full' option

2017-09-07 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added inline comments.

INLINE COMMENTS

> yuja wrote in copies.py:376
> This should either abort or fall back to the default copy tracing.
> Returning None doesn't make sense.

Falling back to default copytracing make sense. I am dropping this revision as 
that's already the case in this series without this patch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D624

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D623: copytrace: move fast heuristic copytracing algorithm to core

2017-09-07 Thread pulkit (Pulkit Goyal)
pulkit planned changes to this revision.
pulkit added inline comments.

INLINE COMMENTS

> yuja wrote in copies.py:608
> This cdst/csrc naming is confusing because c1 is actually the
> source revision (= the original wctx) in "update" scenario. And
> IIUC, we are searching for copies from c1 to c2.
> 
> Can you rename them?

Yes, sure. :)

> yuja wrote in copies.py:638
> Perhaps this wouldn't stop if the base were in the other side.
> I don't think that would happen thanks to how mergecopies()
> are used currently, but it's probably better to error out early.

I am sorry but I didn't understand the `base were in other side` thing. Did you 
mean base is a child of ctx?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D623

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D615: directaccess: store the access level in the ui object in dispatch

2017-09-07 Thread quark (Jun Wu)
quark requested changes to this revision.
quark added a comment.
This revision now requires changes to proceed.


  Setting `ui` config seems like an abuse of the config system. I think it'll 
be cleaner if feed the right "repo" object directly to the command function. 
i.e. By default commands get the "visible" repo: `repo.filtered('visible')` - 
see `hg.repository`. We can change that and add special filter - like 
`repo.fitlered('visible-directaccess-warn')`. So the `repo` object carries the 
information itself.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D615

To: pulkit, #hg-reviewers, quark
Cc: quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel