D696: registrar: add a enum 'cmdtype' for the type of the command

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


  I think the name could be better, but that can be bikeshed.  Stamping my 
approval for the concept and pattern.

INLINE COMMENTS

> registrar.py:148
>  
> +class cmdtype(object):
> +""" enum for the type of command which will tell whether the command is

`cmdtype` might be overly vague, since I could imagine a number of 
classifications it could mean.  Maybe "cmdwritetype"?

REPOSITORY
  rHG Mercurial

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

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


D715: repair: preserve phase also when not using generaldelta (issue5678)

2017-09-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 1833.
martinvonz edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D715?vs=1829=1833

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/repair.py
  tests/test-rebase-scenario-global.t
  tests/test-strip.t

CHANGE DETAILS

diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -1116,6 +1116,6 @@
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/489bac576828-bef27e14-backup.hg (glob)
   $ hg unbundle -q .hg/strip-backup/*
-BROKEN: obsmarker got lost
   $ hg debugobsolete
+  cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
489bac576828490c0bb8d45eac9e5e172e4ec0a8 0 (Thu Jan 01 00:00:00 1970 +) 
{'user': 'test'}
   $ cd ..
diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -399,11 +399,10 @@
   $ hg rebase -s 1 -d 2
   rebasing 1:d2ae7f538514 "b"
   saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/d2ae7f538514-2953539b-rebase.hg (glob)
-BROKEN: d36c should remain public
   $ hg log -G -T '{rev}:{node|shortest} {phase} {desc}\n'
   o  2:c882 draft b
   |
-  @  1:d36c draft c
+  @  1:d36c public c
   |
   o  0:cb9a public a
   
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -38,7 +38,7 @@
 totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
 
-cgversion = changegroup.safeversion(repo)
+cgversion = changegroup.localversion(repo)
 comp = None
 if cgversion != '01':
 bundletype = "HG20"
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -872,6 +872,11 @@
 versions.discard('02')
 return versions
 
+def localversion(repo):
+# Finds the best version to use for bundles that are meant to be used
+# locally, such as those from strip and shelve, and temporary bundles.
+return max(supportedoutgoingversions(repo))
+
 def safeversion(repo):
 # Finds the smallest version that it's safe to assume clients of the repo
 # will support. For example, all hg versions that support generaldelta also



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


D714: tests: add test for issue5678

2017-09-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 1832.
martinvonz edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D714?vs=1828=1832

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

AFFECTED FILES
  tests/test-rebase-scenario-global.t
  tests/test-strip.t

CHANGE DETAILS

diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -1097,3 +1097,25 @@
   112478962961147124edd43549aedd1a335e44bf 0 
{426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +) 
{'operation': 'replace', 'user': 'test'}
   08ebfeb61bac6e3f12079de774d285a0d6689eba 0 
{426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +) 
{'operation': 'replace', 'user': 'test'}
   26805aba1e600a82e93661149f2313866a221a7b 0 
{112478962961147124edd43549aedd1a335e44bf} (Thu Jan 01 00:00:00 1970 +) 
{'operation': 'replace', 'user': 'test'}
+  $ cd ..
+
+Test that obsmarkers are restored even when not using generaldelta
+
+  $ hg --config format.usegeneraldelta=no init issue5678
+  $ cd issue5678
+  $ cat >> .hg/hgrc < [experimental]
+  > evolution=all
+  > EOF
+  $ echo a > a
+  $ hg ci -Aqm a
+  $ hg ci --amend -m a2
+  $ hg debugobsolete
+  cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
489bac576828490c0bb8d45eac9e5e172e4ec0a8 0 (Thu Jan 01 00:00:00 1970 +) 
{'user': 'test'}
+  $ hg strip .
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/489bac576828-bef27e14-backup.hg (glob)
+  $ hg unbundle -q .hg/strip-backup/*
+BROKEN: obsmarker got lost
+  $ hg debugobsolete
+  $ cd ..
diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -375,6 +375,40 @@
 
   $ cd ..
 
+Check that temporary bundle doesn't lose phase when not using generaldelta
+
+  $ hg --config format.usegeneraldelta=no init issue5678
+  $ cd issue5678
+  $ grep generaldelta .hg/requires
+  [1]
+  $ echo a > a
+  $ hg ci -Aqm a
+  $ echo b > b
+  $ hg ci -Aqm b
+  $ hg co -q '.^'
+  $ echo c > c
+  $ hg ci -Aqm c
+  $ hg phase --public
+  $ hg log -G -T '{rev}:{node|shortest} {phase} {desc}\n'
+  @  2:d36c public c
+  |
+  | o  1:d2ae draft b
+  |/
+  o  0:cb9a public a
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:d2ae7f538514 "b"
+  saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/d2ae7f538514-2953539b-rebase.hg (glob)
+BROKEN: d36c should remain public
+  $ hg log -G -T '{rev}:{node|shortest} {phase} {desc}\n'
+  o  2:c882 draft b
+  |
+  @  1:d36c draft c
+  |
+  o  0:cb9a public a
+  
+  $ cd ..
+
 Test for revset
 
 We need a bit different graph



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


D682: merge: allow a custom working context to be passed to update

2017-09-14 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1831.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D682?vs=1726=1831

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

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
@@ -1479,7 +1479,7 @@
 
 def update(repo, node, branchmerge, force, ancestor=None,
mergeancestor=False, labels=None, matcher=None, mergeforce=False,
-   updatecheck=None):
+   updatecheck=None, wc=None):
 """
 Perform a merge between the working directory and the given node
 
@@ -1527,6 +1527,9 @@
 2 = abort: uncommitted changes (commit or update --clean to discard 
changes)
 3 = abort: uncommitted changes (checked in commands.py)
 
+The merge is performed inside ``wc``, a workingctx-like objects. It 
defaults
+to repo[None] if None is passed.
+
 Return the same tuple as applyupdates().
 """
 # Avoid cycle.
@@ -1550,7 +1553,8 @@
 else:
 partial = True
 with repo.wlock():
-wc = repo[None]
+if wc is None:
+wc = repo[None]
 pl = wc.parents()
 p1 = pl[0]
 pas = [None]



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


D674: filemerge: use arbitraryfilectx for backup files

2017-09-14 Thread phillco (Phil Cohen)
phillco updated this revision to Diff 1830.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D674?vs=1724=1830

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

AFFECTED FILES
  mercurial/context.py
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -7,7 +7,6 @@
 
 from __future__ import absolute_import
 
-import filecmp
 import os
 import re
 import tempfile
@@ -226,9 +225,9 @@
 return '\n'
 return None # unknown
 
-def _matcheol(file, origfile):
+def _matcheol(file, back):
 "Convert EOL markers in a file to match origfile"
-tostyle = _eoltype(util.readfile(origfile))
+tostyle = _eoltype(back.data()) # No repo.wread filters?
 if tostyle:
 data = util.readfile(file)
 style = _eoltype(data)
@@ -468,6 +467,12 @@
 a = _workingpath(repo, fcd)
 fd = fcd.path()
 
+# Run ``flushall()`` to make any missing folders the following wwrite
+# calls might be depending on.
+from . import context
+if isinstance(fcd, context.overlayworkingfilectx):
+fcd.ctx().flushall()
+
 util.writefile(a + ".local", fcd.decodeddata())
 repo.wwrite(fd + ".other", fco.data(), fco.flags())
 repo.wwrite(fd + ".base", fca.data(), fca.flags())
@@ -505,7 +510,9 @@
 
 args = _toolstr(ui, tool, "args", '$local $base $other')
 if "$output" in args:
-out, a = a, back # read input from backup, write to original
+# read input from backup, write to original
+out = a
+a = repo.wvfs.join(back.path())
 replace = {'local': a, 'base': b, 'other': c, 'output': out}
 args = util.interpolate(r'\$', replace, args,
 lambda s: util.shellquote(util.localpath(s)))
@@ -588,24 +595,39 @@
 def _restorebackup(fcd, back):
 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
 # util.copy here instead.
-fcd.write(util.readfile(back), fcd.flags())
+fcd.write(back.data(), fcd.flags())
 
 def _makebackup(repo, ui, fcd, premerge):
-"""Makes a backup of the local `fcd` file prior to merging.
+"""Makes and returns a filectx-like object for ``fcd``'s backup file.
 
 In addition to preserving the user's pre-existing modifications to `fcd`
 (if any), the backup is used to undo certain premerges, confirm whether a
 merge changed anything, and determine what line endings the new file should
 have.
 """
 if fcd.isabsent():
 return None
+from . import context
+back = scmutil.origpath(ui, repo, repo.wjoin(fcd.path()))
 
-a = _workingpath(repo, fcd)
-back = scmutil.origpath(ui, repo, a)
-if premerge:
-util.copyfile(a, back)
-return back
+inworkingdir = (back.startswith(repo.wvfs.base) and not
+back.startswith(repo.vfs.base))
+
+if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
+# If the backup file is to be in the working directory, and we're
+# merging in-memory, we must redirect the backup to the memory context
+# so we don't disturb the working directory.
+relpath = back[len(repo.wvfs.base) + 1:]
+fcd.ctx()[relpath].write(fcd.data(), fcd.flags())
+return fcd.ctx()[relpath]
+else:
+# Otherwise, write to wherever the user specified the backups should 
go.
+#
+# A arbitraryfilectx is returned, so we can run the same functions on
+# the backup context regardless of where it lives.
+if premerge:
+util.copyfile(_workingpath(repo, fcd), back)
+return context.arbitraryfilectx(back, repo=repo)
 
 def _maketempfiles(repo, fco, fca):
 """Writes out `fco` and `fca` as temporary files, so an external merge
@@ -719,7 +741,7 @@
 return True, r, deleted
 finally:
 if not r and back is not None:
-util.unlink(back)
+back.remove()
 
 def _check(repo, r, ui, tool, fcd, files):
 fd = fcd.path()
@@ -741,7 +763,7 @@
 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
   'changed' in
   _toollist(ui, tool, "check")):
-if back is not None and filecmp.cmp(_workingpath(repo, fcd), back):
+if back is not None and not fcd.cmp(back):
 if ui.promptchoice(_(" output file %s appears unchanged\n"
  "was merge successful (yn)?"
  "$$  $$ ") % fd, 1):
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -8,6 +8,7 @@
 from __future__ import absolute_import
 
 import errno
+import filecmp
 import os
 import re
 import stat
@@ -697,7 +698,11 @@
 def matches(self, match):
 return self.walk(match)
 
-class basefilectx(object):

D715: repair: preserve phase also when not using generaldelta (issue5678)

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


  In https://phab.mercurial-scm.org/D715#11879, @indygreg wrote:
  
  > This seems reasonable to me. I'm not sure it is appropriate for stable 
though.
  >
  > The temporary bundles should definitely use the latest available version. 
But changing the backup bundles (which are persisted after the operation 
completes) is a BC change and therefore marginally appropriate for stable. I'd 
feel better if we limited the behavior change on stable to just the temporary 
bundles and made backup bundle changes on default.
  >
  > I could be convinced this is appropriate for stable as written if we 
intended to store the latest available bundle format in backup bundles all 
along. This does seem reasonable...
  
  
  As I was trying to argue in the commit message, it seemed to be our intention 
to use the oldest changegroup format until recently. Then our intention changed 
and we started assuming that obsmarkers and phase information got stored in the 
bundle. You can see that we depend on obsmarkers being in the bundle from this 
test case:
  
$ cat >> $HGRCPATH << EOF
> [experimental]
> evolution=createmarkers
> [format]
> usegeneraldelta=no
> [extensions]
> strip=
> EOF

$ hg init
$ echo a > a
$ hg ci -Aqm a
$ hg ci --amend -m a2
$ hg strip .
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
saved backup bundle to 
$TESTTMP/.hg/strip-backup/489bac576828-bef27e14-backup.hg (glob)
$ hg unbundle -q .hg/strip-backup/*
$ hg log -G -T '{node}\n'
o  489bac576828490c0bb8d45eac9e5e172e4ec0a8
  
  Without this patch, it fails like this:
  
  @@ -18,3 +18,5 @@
  
$ hg log -G -T '{node}\n'
o  489bac576828490c0bb8d45eac9e5e172e4ec0a8
  
  
  +  o  cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
  +

REPOSITORY
  rHG Mercurial

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

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


D715: repair: preserve phase also when not using generaldelta (issue5678)

2017-09-14 Thread quark (Jun Wu)
quark accepted this revision.
quark added a comment.


  I have been thinking about moving `repo._phasecache.filterunknown(repo)` 
around, or adding some `if` conditions to skip that for bundles without phases. 
But that is less cleaner - ex. we also need to revert 
https://phab.mercurial-scm.org/rHG168ba5c4dfcbe076747986a4d7305e0c93e5a9a7. I 
prefer cleaner and simpler logic. So I think this is the more desired fix.

REPOSITORY
  rHG Mercurial

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

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


D714: tests: add test for issue5678

2017-09-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 1828.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D714?vs=1826=1828

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

AFFECTED FILES
  tests/test-rebase-scenario-global.t

CHANGE DETAILS

diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -375,6 +375,40 @@
 
   $ cd ..
 
+Check that temporary bundle doesn't lose phase when not using generaldelta
+
+  $ hg --config format.usegeneraldelta=no init issue5678
+  $ cd issue5678
+  $ grep generaldelta .hg/requires
+  [1]
+  $ echo a > a
+  $ hg ci -Aqm a
+  $ echo b > b
+  $ hg ci -Aqm b
+  $ hg co -q '.^'
+  $ echo c > c
+  $ hg ci -Aqm c
+  $ hg phase --public
+  $ hg log -G -T '{rev}:{node|shortest} {phase} {desc}\n'
+  @  2:d36c public c
+  |
+  | o  1:d2ae draft b
+  |/
+  o  0:cb9a public a
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:d2ae7f538514 "b"
+  saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/d2ae7f538514-2953539b-rebase.hg (glob)
+BROKEN: d36c should remain public
+  $ hg log -G -T '{rev}:{node|shortest} {phase} {desc}\n'
+  o  2:c882 draft b
+  |
+  @  1:d36c draft c
+  |
+  o  0:cb9a public a
+  
+  $ cd ..
+
 Test for revset
 
 We need a bit different graph



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


D715: repair: preserve phase also when not using generaldelta (issue5678)

2017-09-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 1829.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D715?vs=1827=1829

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/repair.py
  tests/test-rebase-scenario-global.t

CHANGE DETAILS

diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -399,11 +399,10 @@
   $ hg rebase -s 1 -d 2
   rebasing 1:d2ae7f538514 "b"
   saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/d2ae7f538514-2953539b-rebase.hg (glob)
-BROKEN: d36c should remain public
   $ hg log -G -T '{rev}:{node|shortest} {phase} {desc}\n'
   o  2:c882 draft b
   |
-  @  1:d36c draft c
+  @  1:d36c public c
   |
   o  0:cb9a public a
   
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -38,7 +38,7 @@
 totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
 
-cgversion = changegroup.safeversion(repo)
+cgversion = changegroup.localversion(repo)
 comp = None
 if cgversion != '01':
 bundletype = "HG20"
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -872,6 +872,11 @@
 versions.discard('02')
 return versions
 
+def localversion(repo):
+# Finds the best version to use for bundles that are meant to be used
+# locally, such as those from strip and shelve, and temporary bundles.
+return max(supportedoutgoingversions(repo))
+
 def safeversion(repo):
 # Finds the smallest version that it's safe to assume clients of the repo
 # will support. For example, all hg versions that support generaldelta also



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


D715: repair: preserve phase also when not using generaldelta (issue5678)

2017-09-14 Thread indygreg (Gregory Szorc)
indygreg accepted this revision as: indygreg.
indygreg added a comment.


  This seems reasonable to me. I'm not sure it is appropriate for stable though.
  
  The temporary bundles should definitely use the latest available version. But 
changing the backup bundles (which are persisted after the operation completes) 
is a BC change and therefore marginally appropriate for stable. I'd feel better 
if we limited the behavior change on stable to just the temporary bundles and 
made backup bundle changes on default.
  
  I could be convinced this is appropriate for stable as written if we intended 
to store the latest available bundle format in backup bundles all along. This 
does seem reasonable...

REPOSITORY
  rHG Mercurial

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

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


D714: tests: add test for issue5678

2017-09-14 Thread quark (Jun Wu)
quark accepted this revision.
quark added inline comments.

INLINE COMMENTS

> test-rebase-scenario-global.t:392
> +  $ hg phase --public
> +  $ hg log -G -T '{node|shortest} {phase} {desc}\n'
> +  @  d36c public c

Maybe add `{rev}` so the following `hg rebase -s 1 -d 2` becomes easier to read.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #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


[Bug 5679] New: subscription model for phabricator emails

2017-09-14 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5679

Bug ID: 5679
   Summary: subscription model for phabricator emails
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Windows
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: infrastructure
  Assignee: bugzi...@mercurial-scm.org
  Reporter: adr...@cadifra.com
CC: kbullock+mercur...@ringworld.org,
mercurial-devel@mercurial-scm.org

I would like to have exactly one notification email for every new diff in
phabricator. Users would then have to subscribe that particular diff in order
to get any further notification email about that particular diff.

This would reduce the signal to noise ratio for users like me, who are not
interested in most changes in phabricator.

I'm, for example, absolutely not interested in

   https://phab.mercurial-scm.org/D529

but despite that fact, I do get a whole pile of emails from phabricator each
time someone changes or adds anyting to that exact phab diff.

I mean, if I am really interested in a particulary phab diff, I could easily
subscribe to that diff in phabricator in order to get further notification
emails.

That's how bugzilla works already.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4 evolve-ext] evolve: use registrar.templatekeyword to register template keyword functions

2017-09-14 Thread Boris Feld
Thank you for your patches, they have been accepted.

On Fri, 2017-09-15 at 01:33 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori 
> # Date 1502115761 -32400
> #  Mon Aug 07 23:22:41 2017 +0900
> # Node ID d24bf49080b751520b734482936566da7421de12
> # Parent  dea894973e8faddafe06cc53fbfe6a4f109c3143
> # Available At https://fo...@bitbucket.org/foozy/hgext-evolve
> #  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve
>  -r d24bf49080b7
> # EXP-Topic doc-improvement
> evolve: use registrar.templatekeyword to register template keyword
> functions
> 
> Now, using registrar.templatekeyword of Mercurial directly in evolve
> extension should be safe enough. because it has been available since
> Mercurial 3.8, and minimum Mercurial version for evolve extension is
> 3.8, too.
> 
> BTW, this also fixes an issue of "hg help templates" output that
> template keywords "precursors" and "successors" are not displayed as
> same as others, because they do not have ":KEYWORD:" prefix in their
> docstring.
> 
> diff --git a/hgext3rd/evolve/exthelper.py
> b/hgext3rd/evolve/exthelper.py
> --- a/hgext3rd/evolve/exthelper.py
> +++ b/hgext3rd/evolve/exthelper.py
> @@ -99,8 +99,11 @@ class exthelper(object):
>  revsetpredicate(name)(symbol)
>  revset.loadpredicate(ui, 'evolve', revsetpredicate)
>  
> +templatekeyword = registrar.templatekeyword()
>  for name, kw in self._templatekws:
> -templatekw.keywords[name] = kw
> +templatekeyword(name)(kw)
> +templatekw.loadkeyword(ui, 'evolve', templatekeyword)
> +
>  for ext, command, wrapper, opts in self._extcommandwrappers:
>  if ext not in knownexts:
>  try:
> diff --git a/hgext3rd/evolve/templatekw.py
> b/hgext3rd/evolve/templatekw.py
> --- a/hgext3rd/evolve/templatekw.py
> +++ b/hgext3rd/evolve/templatekw.py
> @@ -28,7 +28,7 @@ eh = exthelper.exthelper()
>  
>  @eh.templatekw('obsolete')
>  def obsoletekw(repo, ctx, templ, **args):
> -""":obsolete: String. Whether the changeset is ``obsolete``.
> +"""String. Whether the changeset is ``obsolete``.
>  """
>  if ctx.obsolete():
>  return 'obsolete'
> @@ -36,7 +36,7 @@ def obsoletekw(repo, ctx, templ, **args)
>  
>  @eh.templatekw('troubles')
>  def showtroubles(**args):
> -""":troubles: List of strings. Evolution troubles affecting the
> changeset
> +"""List of strings. Evolution troubles affecting the changeset
>  (zero or more of "unstable", "divergent" or "bumped")."""
>  ctx = args['ctx']
>  try:
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH evolve-ext] topic: centralize compatibility logic between hg versions into compat module

2017-09-14 Thread Boris Feld
Thank you for your patch, they have been accepted.

On Fri, 2017-09-15 at 00:31 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori 
> # Date 1505050914 -32400
> #  Sun Sep 10 22:41:54 2017 +0900
> # Node ID 3412cce8dbb22a937e72939a5d726c0949715983
> # Parent  23c9600607e7ea3c6d95cddc5ad134cab4f7d7fe
> # Available At https://fo...@bitbucket.org/foozy/hgext-evolve
> #  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve
>  -r 3412cce8dbb2
> # EXP-Topic topic-hg-version-portability
> topic: centralize compatibility logic between hg versions into compat
> module
> 
> This patch can delay loading obsutil and obsolete modules until they
> are actually used at "hg topics" or so, if demandimport of Mercurial
> is enabled.
> 
> diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
> --- a/hgext3rd/topic/__init__.py
> +++ b/hgext3rd/topic/__init__.py
> @@ -79,6 +79,7 @@ from mercurial import (
>  )
>  
>  from . import (
> +compat,
>  constants,
>  revset as topicrevset,
>  destination,
> @@ -727,16 +728,6 @@ def _showlasttouched(repo, fm, opts):
>  fm.plain('\n')
>  fm.end()
>  
> -getmarkers = None
> -try:
> -from mercurial import obsutil
> -getmarkers = getattr(obsutil, 'getmarkers', None)
> -except ImportError:
> -pass
> -
> -if getmarkers is None:
> -getmarkers = obsolete.getmarkers
> -
>  def _getlasttouched(repo, topics):
>  """
>  Calculates the last time a topic was used. Returns a dictionary
> of seconds
> @@ -758,7 +749,7 @@ def _getlasttouched(repo, topics):
>  maxtime = rt
>  # looking on the markers also to get more information
> and accurate
>  # last touch time.
> -obsmarkers = getmarkers(repo, [repo[revs].node()])
> +obsmarkers = compat.getmarkers(repo,
> [repo[revs].node()])
>  for marker in obsmarkers:
>  rt = marker.date()
>  if rt[0] > maxtime[0]:
> diff --git a/hgext3rd/topic/compat.py b/hgext3rd/topic/compat.py
> new file mode 100644
> --- /dev/null
> +++ b/hgext3rd/topic/compat.py
> @@ -0,0 +1,24 @@
> +# Copyright 2017 FUJIWARA Katsunori 
> +#
> +# This software may be used and distributed according to the terms
> of the
> +# GNU General Public License version 2 or any later version.
> +"""
> +Compatibility module
> +"""
> +from __future__ import absolute_import
> +
> +from mercurial import obsolete
> +
> +getmarkers = None
> +successorssets = None
> +try:
> +from mercurial import obsutil
> +getmarkers = getattr(obsutil, 'getmarkers', None)
> +successorssets = getattr(obsutil, 'successorssets', None)
> +except ImportError:
> +pass
> +
> +if getmarkers is None:
> +getmarkers = obsolete.getmarkers
> +if successorssets is None:
> +successorssets = obsolete.successorssets
> diff --git a/hgext3rd/topic/evolvebits.py
> b/hgext3rd/topic/evolvebits.py
> --- a/hgext3rd/topic/evolvebits.py
> +++ b/hgext3rd/topic/evolvebits.py
> @@ -1,15 +1,6 @@
>  import collections
> -from mercurial import obsolete
>  
> -successorssets = None
> -try:
> -from mercurial import obsutil
> -successorssets = getattr(obsutil, 'successorssets', None)
> -except ImportError:
> -pass
> -
> -if successorssets is None:
> -successorssets = obsolete.successorssets
> +from . import compat
>  
>  # Copied from evolve 081605c2e9b6
>  
> @@ -82,14 +73,14 @@ def _singlesuccessor(repo, p):
>  return p.rev()
>  obs = repo[p]
>  ui = repo.ui
> -newer = successorssets(repo, obs.node())
> +newer = compat.successorssets(repo, obs.node())
>  # search of a parent which is not killed
>  while not newer:
>  ui.debug("stabilize target %s is plain dead,"
>   " trying to stabilize on its parent\n" %
>   obs)
>  obs = obs.parents()[0]
> -newer = successorssets(repo, obs.node())
> +newer = compat.successorssets(repo, obs.node())
>  if len(newer) > 1 or len(newer[0]) > 1:
>  raise MultipleSuccessorsError(newer)
>  
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D714: tests: add test for issue5678

2017-09-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-rebase-scenario-global.t

CHANGE DETAILS

diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -375,6 +375,40 @@
 
   $ cd ..
 
+Check that temporary bundle doesn't lose phase when not using generaldelta
+
+  $ hg --config format.usegeneraldelta=no init issue5678
+  $ cd issue5678
+  $ grep generaldelta .hg/requires
+  [1]
+  $ echo a > a
+  $ hg ci -Aqm a
+  $ echo b > b
+  $ hg ci -Aqm b
+  $ hg co -q '.^'
+  $ echo c > c
+  $ hg ci -Aqm c
+  $ hg phase --public
+  $ hg log -G -T '{node|shortest} {phase} {desc}\n'
+  @  d36c public c
+  |
+  | o  d2ae draft b
+  |/
+  o  cb9a public a
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:d2ae7f538514 "b"
+  saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/d2ae7f538514-2953539b-rebase.hg (glob)
+BROKEN: d36c should remain public
+  $ hg log -G -T '{node|shortest} {phase} {desc}\n'
+  o  c882 draft b
+  |
+  @  d36c draft c
+  |
+  o  cb9a public a
+  
+  $ cd ..
+
 Test for revset
 
 We need a bit different graph



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


D715: repair: preserve phase also when not using generaldelta (issue5678)

2017-09-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It seems like we used to pick the oldest possible version of the
  changegroup to use for bundles created by the repair module (used
  e.g. by "hg strip" and for temporary bundles by "hg rebase"). I tried
  to preserve that behavior when I created the changegroup.safeversion()
  method in 
https://phab.mercurial-scm.org/rHG3b2ac2115464477040b21efd10c7ce69c8ba513f 
(changegroup: introduce safeversion(),
  2016-01-19).
  
  However, we have recently chagned our minds and decided that these
  commands are only used locally and downgrades are unlikely. That
  decicion allowed us to start adding obsmarker and phase information to
  these bundles. However, as the bug report shows, it means we get
  different behavior e.g. when generaldelta is not enabled (because when
  it was enabled, it forced us to use bundle2).
  
  So, since we now depend on having more information in the bundles,
  let's make sure we instead pick the newest possible changegroup
  version.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/repair.py
  tests/test-rebase-scenario-global.t

CHANGE DETAILS

diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -399,11 +399,10 @@
   $ hg rebase -s 1 -d 2
   rebasing 1:d2ae7f538514 "b"
   saved backup bundle to 
$TESTTMP/issue5678/.hg/strip-backup/d2ae7f538514-2953539b-rebase.hg (glob)
-BROKEN: d36c should remain public
   $ hg log -G -T '{node|shortest} {phase} {desc}\n'
   o  c882 draft b
   |
-  @  d36c draft c
+  @  d36c public c
   |
   o  cb9a public a
   
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -38,7 +38,7 @@
 totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
 
-cgversion = changegroup.safeversion(repo)
+cgversion = changegroup.localversion(repo)
 comp = None
 if cgversion != '01':
 bundletype = "HG20"
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -872,6 +872,11 @@
 versions.discard('02')
 return versions
 
+def localversion(repo):
+# Finds the best version to use for bundles that are meant to be used
+# locally, such as those from strip and shelve, and temporary bundles.
+return max(supportedoutgoingversions(repo))
+
 def safeversion(repo):
 # Finds the smallest version that it's safe to assume clients of the repo
 # will support. For example, all hg versions that support generaldelta also



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


D529: uncommit: move fb-extension to core which uncommits a changeset

2017-09-14 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 1823.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D529?vs=1729=1823

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
new file mode 100644
--- /dev/null
+++ b/tests/test-uncommit.t
@@ -0,0 +1,366 @@
+Test uncommit - set up the config
+
+  $ cat >> $HGRCPATH < [experimental]
+  > evolution=createmarkers, allowunstable
+  > [extensions]
+  > uncommit =
+  > drawdag=$TESTDIR/drawdag.py
+  > EOF
+
+Build up a repo
+
+  $ hg init repo
+  $ cd repo
+  $ hg bookmark foo
+
+Help for uncommit
+
+  $ hg help uncommit
+  hg uncommit [OPTION]... [FILE]...
+  
+  uncommit part or all of a local changeset
+  
+  This command undoes the effect of a local commit, returning the affected
+  files to their uncommitted state. This means that files modified or
+  deleted in the changeset will be left unchanged, and so will remain
+  modified in the working directory.
+  
+  (use 'hg help -e uncommit' to show help for the uncommit extension)
+  
+  options ([+] can be repeated):
+  
+  --empty   allow an empty commit after uncommiting
+   -I --include PATTERN [+] include names matching the given patterns
+   -X --exclude PATTERN [+] exclude names matching the given patterns
+  
+  (some details hidden, use --verbose to show complete help)
+
+Uncommit with no commits should fail
+
+  $ hg uncommit
+  abort: cannot uncommit null changeset
+  [255]
+
+Create some commits
+
+  $ touch files
+  $ hg add files
+  $ for i in a ab abc abcd abcde; do echo $i > files; echo $i > file-$i; hg 
add file-$i; hg commit -m "added file-$i"; done
+  $ ls
+  file-a
+  file-ab
+  file-abc
+  file-abcd
+  file-abcde
+  files
+
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  @  4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
+  |
+  o  3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
+  |
+  o  2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
+  |
+  o  1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
+  |
+  o  0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
+  
+Simple uncommit off the top, also moves bookmark
+
+  $ hg bookmark
+   * foo   4:6c4fd43ed714
+  $ hg uncommit
+  $ hg status
+  M files
+  A file-abcde
+  $ hg bookmark
+   * foo   3:6db330d65db4
+
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  x  4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
+  |
+  @  3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
+  |
+  o  2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
+  |
+  o  1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
+  |
+  o  0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
+  
+
+Recommit
+
+  $ hg commit -m 'new change abcde'
+  $ hg status
+  $ hg heads -T '{rev}:{node} {desc}'
+  5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol)
+
+Uncommit of non-existent and unchanged files has no effect
+  $ hg uncommit nothinghere
+  nothing to uncommit
+  [1]
+  $ hg status
+  $ hg uncommit file-abc
+  nothing to uncommit
+  [1]
+  $ hg status
+
+Try partial uncommit, also moves bookmark
+
+  $ hg bookmark
+   * foo   5:0c07a3ccda77
+  $ hg uncommit files
+  $ hg status
+  M files
+  $ hg bookmark
+   * foo   6:3727deee06f7
+  $ hg heads -T '{rev}:{node} {desc}'
+  6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol)
+  $ hg log -r . -p -T '{rev}:{node} {desc}'
+  6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 
6db330d65db4 -r 3727deee06f7 file-abcde
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/file-abcde Thu Jan 01 00:00:00 1970 +
+  @@ -0,0 +1,1 @@
+  +abcde
+  
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  @  6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
+  |
+  | x  5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
+  |/
+  | x  4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
+  |/
+  o  3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
+  |
+  o  2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
+  |
+  o  1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
+  |
+  o  0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
+  
+  $ hg commit -m 'update files for abcde'
+
+Uncommit with dirty state
+
+  $ echo "foo" >> files
+  $ cat files
+  abcde
+  foo
+  $ hg status
+  M files
+  $ hg uncommit files
+  $ cat files
+  abcde
+  foo
+  $ hg commit -m "files abcde + foo"
+
+Uncommit in the middle of a stack, does not move bookmark
+
+  $ hg checkout '.^^^'
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  (leaving bookmark foo)
+  $ hg log -r . -p -T '{rev}:{node} {desc}'
+  2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 

D706: bundle2: move processpart stream maintenance into part iterator

2017-09-14 Thread durham (Durham Goode)
durham updated this revision to Diff 1818.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D706?vs=1802=1818

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -354,21 +354,32 @@
 self.unbundler = unbundler
 self.iterator = None
 self.count = 0
+self.current = None
 
 def __enter__(self):
 def func():
 itr = enumerate(self.unbundler.iterparts())
 for count, p in itr:
 self.count = count
+self.current = p
 yield p
+p.seek(0, 2)
+self.current = None
 self.iterator = func()
 return self.iterator
 
 def __exit__(self, type, exc, tb):
 if not self.iterator:
 return
 
 if exc:
+# If exiting or interrupted, do not attempt to seek the stream in
+# the finally block below. This makes abort faster.
+if (self.current and
+not isinstance(exc, (SystemExit, KeyboardInterrupt))):
+# consume the part content to not corrupt the stream.
+self.current.seek(0, 2)
+
 # Any exceptions seeking to the end of the bundle at this point are
 # almost certainly related to the underlying stream being bad.
 # And, chances are that the exception we're handling is related to
@@ -455,7 +466,6 @@
 The part is guaranteed to have been fully consumed when the function exits
 (even if an exception is raised)."""
 status = 'unknown' # used by debug output
-hardabort = False
 try:
 try:
 handler = parthandlermapping.get(part.type)
@@ -511,15 +521,8 @@
mandatory=False)
 outpart.addparam(
 'in-reply-to', pycompat.bytestr(part.id), mandatory=False)
-# If exiting or interrupted, do not attempt to seek the stream in the
-# finally block below. This makes abort faster.
-except (SystemExit, KeyboardInterrupt):
-hardabort = True
-raise
 finally:
-# consume the part content to not corrupt the stream.
-if not hardabort:
-part.seek(0, 2)
+pass
 
 
 def decodecaps(blob):
@@ -1143,7 +1146,15 @@
 return
 part = unbundlepart(self.ui, headerblock, self._fp)
 op = interruptoperation(self.ui)
-_processpart(op, part)
+hardabort = False
+try:
+_processpart(op, part)
+except (SystemExit, KeyboardInterrupt):
+hardabort = True
+raise
+finally:
+if not hardabort:
+part.seek(0, 2)
 self.ui.debug('bundle2-input-stream-interrupt:'
   ' closing out of band context\n')
 



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


D707: bundle2: move handler validation out of processpart

2017-09-14 Thread durham (Durham Goode)
durham updated this revision to Diff 1819.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D707?vs=1803=1819

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -460,48 +460,55 @@
 })
 return ret
 
+def _gethandler(op, part):
+status = 'unknown' # used by debug output
+try:
+handler = parthandlermapping.get(part.type)
+if handler is None:
+status = 'unsupported-type'
+raise error.BundleUnknownFeatureError(parttype=part.type)
+indebug(op.ui, 'found a handler for part %r' % part.type)
+unknownparams = part.mandatorykeys - handler.params
+if unknownparams:
+unknownparams = list(unknownparams)
+unknownparams.sort()
+status = 'unsupported-params (%s)' % unknownparams
+raise error.BundleUnknownFeatureError(parttype=part.type,
+  params=unknownparams)
+status = 'supported'
+except error.BundleUnknownFeatureError as exc:
+if part.mandatory: # mandatory parts
+raise
+indebug(op.ui, 'ignoring unsupported advisory part %s' % exc)
+return # skip to part processing
+finally:
+if op.ui.debugflag:
+msg = ['bundle2-input-part: "%s"' % part.type]
+if not part.mandatory:
+msg.append(' (advisory)')
+nbmp = len(part.mandatorykeys)
+nbap = len(part.params) - nbmp
+if nbmp or nbap:
+msg.append(' (params:')
+if nbmp:
+msg.append(' %i mandatory' % nbmp)
+if nbap:
+msg.append(' %i advisory' % nbmp)
+msg.append(')')
+msg.append(' %s\n' % status)
+op.ui.debug(''.join(msg))
+
+return handler
+
 def _processpart(op, part):
 """process a single part from a bundle
 
 The part is guaranteed to have been fully consumed when the function exits
 (even if an exception is raised)."""
-status = 'unknown' # used by debug output
 try:
-try:
-handler = parthandlermapping.get(part.type)
-if handler is None:
-status = 'unsupported-type'
-raise error.BundleUnknownFeatureError(parttype=part.type)
-indebug(op.ui, 'found a handler for part %r' % part.type)
-unknownparams = part.mandatorykeys - handler.params
-if unknownparams:
-unknownparams = list(unknownparams)
-unknownparams.sort()
-status = 'unsupported-params (%s)' % unknownparams
-raise error.BundleUnknownFeatureError(parttype=part.type,
-  params=unknownparams)
-status = 'supported'
-except error.BundleUnknownFeatureError as exc:
-if part.mandatory: # mandatory parts
-raise
-indebug(op.ui, 'ignoring unsupported advisory part %s' % exc)
-return # skip to part processing
-finally:
-if op.ui.debugflag:
-msg = ['bundle2-input-part: "%s"' % part.type]
-if not part.mandatory:
-msg.append(' (advisory)')
-nbmp = len(part.mandatorykeys)
-nbap = len(part.params) - nbmp
-if nbmp or nbap:
-msg.append(' (params:')
-if nbmp:
-msg.append(' %i mandatory' % nbmp)
-if nbap:
-msg.append(' %i advisory' % nbmp)
-msg.append(')')
-msg.append(' %s\n' % status)
-op.ui.debug(''.join(msg))
+handler = _gethandler(op, part)
+if handler is None:
+return
 
 # handler is called outside the above try block so that we don't
 # risk catching KeyErrors from anything other than the



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


D708: bundle2: remove unnecessary try finally

2017-09-14 Thread durham (Durham Goode)
durham updated this revision to Diff 1820.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D708?vs=1804=1820

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -505,32 +505,28 @@
 
 The part is guaranteed to have been fully consumed when the function exits
 (even if an exception is raised)."""
-try:
-handler = _gethandler(op, part)
-if handler is None:
-return
+handler = _gethandler(op, part)
+if handler is None:
+return
 
-# handler is called outside the above try block so that we don't
-# risk catching KeyErrors from anything other than the
-# parthandlermapping lookup (any KeyError raised by handler()
-# itself represents a defect of a different variety).
-output = None
-if op.captureoutput and op.reply is not None:
-op.ui.pushbuffer(error=True, subproc=True)
-output = ''
-try:
-handler(op, part)
-finally:
-if output is not None:
-output = op.ui.popbuffer()
-if output:
-outpart = op.reply.newpart('output', data=output,
-   mandatory=False)
-outpart.addparam(
-'in-reply-to', pycompat.bytestr(part.id), mandatory=False)
+# handler is called outside the above try block so that we don't
+# risk catching KeyErrors from anything other than the
+# parthandlermapping lookup (any KeyError raised by handler()
+# itself represents a defect of a different variety).
+output = None
+if op.captureoutput and op.reply is not None:
+op.ui.pushbuffer(error=True, subproc=True)
+output = ''
+try:
+handler(op, part)
 finally:
-pass
-
+if output is not None:
+output = op.ui.popbuffer()
+if output:
+outpart = op.reply.newpart('output', data=output,
+   mandatory=False)
+outpart.addparam(
+'in-reply-to', pycompat.bytestr(part.id), mandatory=False)
 
 def decodecaps(blob):
 """decode a bundle2 caps bytes blob into a dictionary



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


D663: dirstate: perform transactions with _map using single call, where possible

2017-09-14 Thread mbolin (Michael Bolin)
mbolin added inline comments.

INLINE COMMENTS

> yuja wrote in dirstate.py:554
> test-add.t fails here. It was `self[d]`, not `self._map[d]`.

My bad: fixed without bringing the extra lookup back.

REPOSITORY
  rHG Mercurial

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

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


D663: dirstate: perform transactions with _map using single call, where possible

2017-09-14 Thread mbolin (Michael Bolin)
mbolin updated this revision to Diff 1817.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D663?vs=1687=1817

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -550,7 +550,8 @@
 for d in util.finddirs(f):
 if d in self._dirs:
 break
-if d in self._map and self[d] != 'r':
+entry = self._map.get(d)
+if entry is not None and entry[0] != 'r':
 raise error.Abort(
 _('file %r in dirstate clashes with %r') % (d, f))
 if oldstate in "?r" and "_dirs" in self.__dict__:
@@ -580,22 +581,23 @@
 
 def normallookup(self, f):
 '''Mark a file normal, but possibly dirty.'''
-if self._pl[1] != nullid and f in self._map:
+if self._pl[1] != nullid:
 # if there is a merge going on and the file was either
 # in state 'm' (-1) or coming from other parent (-2) before
 # being removed, restore that state.
-entry = self._map[f]
-if entry[0] == 'r' and entry[2] in (-1, -2):
-source = self._copymap.get(f)
-if entry[2] == -1:
-self.merge(f)
-elif entry[2] == -2:
-self.otherparent(f)
-if source:
-self.copy(source, f)
-return
-if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
-return
+entry = self._map.get(f)
+if entry is not None:
+if entry[0] == 'r' and entry[2] in (-1, -2):
+source = self._copymap.get(f)
+if entry[2] == -1:
+self.merge(f)
+elif entry[2] == -2:
+self.otherparent(f)
+if source:
+self.copy(source, f)
+return
+if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
+return
 self._addpath(f, 'n', 0, -1, -1)
 self._copymap.pop(f, None)
 if f in self._nonnormalset:
@@ -624,14 +626,15 @@
 self._dirty = True
 self._droppath(f)
 size = 0
-if self._pl[1] != nullid and f in self._map:
-# backup the previous state
-entry = self._map[f]
-if entry[0] == 'm': # merge
-size = -1
-elif entry[0] == 'n' and entry[2] == -2: # other parent
-size = -2
-self._otherparentset.add(f)
+if self._pl[1] != nullid:
+entry = self._map.get(f)
+if entry is not None:
+# backup the previous state
+if entry[0] == 'm': # merge
+size = -1
+elif entry[0] == 'n' and entry[2] == -2: # other parent
+size = -2
+self._otherparentset.add(f)
 self._map[f] = dirstatetuple('r', 0, size, 0)
 self._nonnormalset.add(f)
 if size == 0:



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


[PATCH 2 of 4 evolve-ext] topic: use registrar.revsetpredicate to register revset predicate functions

2017-09-14 Thread FUJIWARA Katsunori
# HG changeset patch
# User FUJIWARA Katsunori 
# Date 1502115433 -32400
#  Mon Aug 07 23:17:13 2017 +0900
# Node ID c89a40ef1e93c733a8ecd2a88efd83c72e5c6ac9
# Parent  36c09de6c9765c41393c92298b0455b9491b91dc
# Available At https://fo...@bitbucket.org/foozy/hgext-evolve
#  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve -r 
c89a40ef1e93
# EXP-Topic doc-improvement
topic: use registrar.revsetpredicate to register revset predicate functions

Now, using registrar.revsetpredicate of Mercurial directly in topic
extension should be safe enough. because it has been available since
Mercurial 3.8, and minimum Mercurial version for topic extension is
4.0.

This patch also removes modsetup() in topic/revset.py, because it is
useless.

BTW, this patch fixes an issue of "hg help revsets" output that custom
revset predicates are not displayed as same as others, because they
are not "inline literal" in reST syntax (``NAME``).

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -186,7 +186,6 @@ def _nodemap(repo, node):
 
 def uisetup(ui):
 destination.modsetup(ui)
-topicrevset.modsetup(ui)
 discovery.modsetup(ui)
 topicmap.modsetup(ui)
 setupimportexport(ui)
@@ -308,6 +307,9 @@ def reposetup(ui, repo):
 'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
 listnames=lambda repo: repo.topics))
 
+# revset predicates are automatically registered at loading via this symbol
+revsetpredicate = topicrevset.revsetpredicate
+
 @command('topics', [
 ('', 'clear', False, 'clear active topic if any'),
 ('r', 'rev', [], 'revset of existing revisions', _('REV')),
diff --git a/hgext3rd/topic/revset.py b/hgext3rd/topic/revset.py
--- a/hgext3rd/topic/revset.py
+++ b/hgext3rd/topic/revset.py
@@ -1,6 +1,7 @@
 from __future__ import absolute_import
 
 from mercurial import (
+registrar,
 revset,
 util,
 )
@@ -16,10 +17,11 @@ try:
 except AttributeError:
 mkmatcher = util.stringmatcher
 
+revsetpredicate = registrar.revsetpredicate()
 
+@revsetpredicate('topic([topic])')
 def topicset(repo, subset, x):
-"""`topic([topic])`
-Specified topic or all changes with any topic specified.
+"""Specified topic or all changes with any topic specified.
 
 If `topic` starts with `re:` the remainder of the name is treated
 as a regular expression.
@@ -48,10 +50,9 @@ def topicset(repo, subset, x):
 return matcher(topic)
 return (subset & mutable).filter(matchtopic)
 
+@revsetpredicate('ngtip([branch])')
 def ngtipset(repo, subset, x):
-"""`ngtip([branch])`
-
-The untopiced tip.
+"""The untopiced tip.
 
 Name is horrible so that people change it.
 """
@@ -62,9 +63,9 @@ def ngtipset(repo, subset, x):
 branch = repo['.'].branch()
 return subset & revset.baseset(destination.ngtip(repo, branch))
 
+@revsetpredicate('stack()')
 def stackset(repo, subset, x):
-"""`stack()`
-All relevant changes in the current topic,
+"""All relevant changes in the current topic,
 
 This is roughly equivalent to 'topic(.) - obsolete' with a sorting moving
 unstable changeset after there future parent (as if evolve where already
@@ -79,9 +80,3 @@ def stackset(repo, subset, x):
 if not topic:
 branch = repo[None].branch()
 return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & 
subset
-
-
-def modsetup(ui):
-revset.symbols.update({'topic': topicset})
-revset.symbols.update({'ngtip': ngtipset})
-revset.symbols.update({'stack': stackset})
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 4 evolve-ext] evolve: use registrar.templatekeyword to register template keyword functions

2017-09-14 Thread FUJIWARA Katsunori
# HG changeset patch
# User FUJIWARA Katsunori 
# Date 1502115761 -32400
#  Mon Aug 07 23:22:41 2017 +0900
# Node ID d24bf49080b751520b734482936566da7421de12
# Parent  dea894973e8faddafe06cc53fbfe6a4f109c3143
# Available At https://fo...@bitbucket.org/foozy/hgext-evolve
#  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve -r 
d24bf49080b7
# EXP-Topic doc-improvement
evolve: use registrar.templatekeyword to register template keyword functions

Now, using registrar.templatekeyword of Mercurial directly in evolve
extension should be safe enough. because it has been available since
Mercurial 3.8, and minimum Mercurial version for evolve extension is
3.8, too.

BTW, this also fixes an issue of "hg help templates" output that
template keywords "precursors" and "successors" are not displayed as
same as others, because they do not have ":KEYWORD:" prefix in their
docstring.

diff --git a/hgext3rd/evolve/exthelper.py b/hgext3rd/evolve/exthelper.py
--- a/hgext3rd/evolve/exthelper.py
+++ b/hgext3rd/evolve/exthelper.py
@@ -99,8 +99,11 @@ class exthelper(object):
 revsetpredicate(name)(symbol)
 revset.loadpredicate(ui, 'evolve', revsetpredicate)
 
+templatekeyword = registrar.templatekeyword()
 for name, kw in self._templatekws:
-templatekw.keywords[name] = kw
+templatekeyword(name)(kw)
+templatekw.loadkeyword(ui, 'evolve', templatekeyword)
+
 for ext, command, wrapper, opts in self._extcommandwrappers:
 if ext not in knownexts:
 try:
diff --git a/hgext3rd/evolve/templatekw.py b/hgext3rd/evolve/templatekw.py
--- a/hgext3rd/evolve/templatekw.py
+++ b/hgext3rd/evolve/templatekw.py
@@ -28,7 +28,7 @@ eh = exthelper.exthelper()
 
 @eh.templatekw('obsolete')
 def obsoletekw(repo, ctx, templ, **args):
-""":obsolete: String. Whether the changeset is ``obsolete``.
+"""String. Whether the changeset is ``obsolete``.
 """
 if ctx.obsolete():
 return 'obsolete'
@@ -36,7 +36,7 @@ def obsoletekw(repo, ctx, templ, **args)
 
 @eh.templatekw('troubles')
 def showtroubles(**args):
-""":troubles: List of strings. Evolution troubles affecting the changeset
+"""List of strings. Evolution troubles affecting the changeset
 (zero or more of "unstable", "divergent" or "bumped")."""
 ctx = args['ctx']
 try:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 4 evolve-ext] doc: make paragraphs before example code end with "::" for reST syntax

2017-09-14 Thread FUJIWARA Katsunori
# HG changeset patch
# User FUJIWARA Katsunori 
# Date 1502115897 -32400
#  Mon Aug 07 23:24:57 2017 +0900
# Node ID 36c09de6c9765c41393c92298b0455b9491b91dc
# Parent  23c9600607e7ea3c6d95cddc5ad134cab4f7d7fe
# Available At https://fo...@bitbucket.org/foozy/hgext-evolve
#  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve -r 
36c09de6c976
# EXP-Topic doc-improvement
doc: make paragraphs before example code end with "::" for reST syntax

This prevents lines in an example code from being treated as a part of
normal paragraph. For issue example, lines are folded into one
paragraph.

diff --git a/hgext3rd/evolve/__init__.py b/hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py
+++ b/hgext3rd/evolve/__init__.py
@@ -34,7 +34,7 @@ experimental protocol are also supported
 help people transitioning. (The extensions is currently compatible down to
 Mercurial version 3.8).
 
-New Config:
+New Config::
 
 [experimental]
 # Set to control the behavior when pushing draft changesets to a publishing
@@ -103,7 +103,7 @@ implementation of some of the algorithms
 
 For very large repositories. it is currently recommended to disable obsmarkers
 discovery (Make sure you follow release announcement to know when you can turn
-it back on).
+it back on)::
 
 [experimental]
 evolution.obsdiscovery = no
@@ -137,7 +137,7 @@ The following config control the effect 
   # evolution.effect-flags = false
 
 You can display the effect flags with the command obslog, so if you have a
-changeset and you update only the message, you will see:
+changeset and you update only the message, you will see::
 
 $ hg commit -m "WIP
 $ hg commit -m "A better commit message!"
diff --git a/hgext3rd/evolve/cmdrewrite.py b/hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py
+++ b/hgext3rd/evolve/cmdrewrite.py
@@ -350,7 +350,7 @@ def fold(ui, repo, *revs, **opts):
 
  hg fold --from 3::6
 
- - Fold revisions 3 and 4:
+ - Fold revisions 3 and 4::
 
 hg fold "3 + 4" --exact
 
diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -319,23 +319,29 @@ def reposetup(ui, repo):
 def topics(ui, repo, topic=None, clear=False, rev=None, list=False, **opts):
 """View current topic, set current topic, change topic for a set of 
revisions, or see all topics.
 
-Clear topic on existing topiced revisions:
-`hg topic --rev  --clear`
-
-Change topic on some revisions:
-`hg topic  --rev `
-
-Clear current topic:
-`hg topic --clear`
-
-Set current topic:
-`hg topic `
-
-List of topics:
-`hg topics`
-
-List of topics with their last touched time sorted according to it:
-`hg topic --age`
+Clear topic on existing topiced revisions::
+
+  hg topic --rev  --clear
+
+Change topic on some revisions::
+
+  hg topic  --rev 
+
+Clear current topic::
+
+  hg topic --clear
+
+Set current topic::
+
+  hg topic 
+
+List of topics::
+
+  hg topics
+
+List of topics with their last touched time sorted according to it::
+
+  hg topic --age
 
 The active topic (if any) will be prepended with a "*".
 
diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -19,22 +19,28 @@
   see all topics.
   
   Clear topic on existing topiced revisions:
-  'hg topic --rev  --clear'
+  
+hg topic --rev  --clear
   
   Change topic on some revisions:
-  'hg topic  --rev '
+  
+hg topic  --rev 
   
   Clear current topic:
-  'hg topic --clear'
+  
+hg topic --clear
   
   Set current topic:
-  'hg topic '
+  
+hg topic 
   
   List of topics:
-  'hg topics'
+  
+hg topics
   
   List of topics with their last touched time sorted according to it:
-  'hg topic --age'
+  
+hg topic --age
   
   The active topic (if any) will be prepended with a "*".
   
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 4 evolve-ext] evolve: use registrar.revsetpredicate to register revset predicate functions

2017-09-14 Thread FUJIWARA Katsunori
# HG changeset patch
# User FUJIWARA Katsunori 
# Date 1505041612 -32400
#  Sun Sep 10 20:06:52 2017 +0900
# Node ID dea894973e8faddafe06cc53fbfe6a4f109c3143
# Parent  c89a40ef1e93c733a8ecd2a88efd83c72e5c6ac9
# Available At https://fo...@bitbucket.org/foozy/hgext-evolve
#  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve -r 
dea894973e8f
# EXP-Topic doc-improvement
evolve: use registrar.revsetpredicate to register revset predicate functions

Now, using registrar.revsetpredicate of Mercurial directly in evolve
extension should be safe enough. because it has been available since
Mercurial 3.8, and minimum Mercurial version for evolve extension is
3.8, too.

diff --git a/hgext3rd/evolve/__init__.py b/hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py
+++ b/hgext3rd/evolve/__init__.py
@@ -482,10 +482,9 @@ def _installalias(ui):
 
 ### Troubled revset symbol
 
-@eh.revset('troubled')
+@eh.revset('troubled()')
 def revsettroubled(repo, subset, x):
-"""``troubled()``
-Changesets with troubles.
+"""Changesets with troubles.
 """
 revset.getargs(x, 0, 0, 'troubled takes no arguments')
 troubled = set()
@@ -589,10 +588,9 @@ def _allsuccessors(repo, s, haltonflags=
 
 
 ### XXX I'm not sure this revset is useful
-@eh.revset('suspended')
+@eh.revset('suspended()')
 def revsetsuspended(repo, subset, x):
-"""``suspended()``
-Obsolete changesets with non-obsolete descendants.
+"""Obsolete changesets with non-obsolete descendants.
 """
 revset.getargs(x, 0, 0, 'suspended takes no arguments')
 suspended = revset.baseset(getrevs(repo, 'suspended'))
@@ -600,10 +598,9 @@ def revsetsuspended(repo, subset, x):
 return subset & suspended
 
 
-@eh.revset('precursors')
+@eh.revset('precursors(set)')
 def revsetprecursors(repo, subset, x):
-"""``precursors(set)``
-Immediate precursors of changesets in set.
+"""Immediate precursors of changesets in set.
 """
 s = revset.getset(repo, revset.fullreposet(repo), x)
 s = revset.baseset(_precursors(repo, s))
@@ -611,10 +608,9 @@ def revsetprecursors(repo, subset, x):
 return subset & s
 
 
-@eh.revset('allprecursors')
+@eh.revset('allprecursors(set)')
 def revsetallprecursors(repo, subset, x):
-"""``allprecursors(set)``
-Transitive precursors of changesets in set.
+"""Transitive precursors of changesets in set.
 """
 s = revset.getset(repo, revset.fullreposet(repo), x)
 s = revset.baseset(_allprecursors(repo, s))
@@ -622,20 +618,18 @@ def revsetallprecursors(repo, subset, x)
 return subset & s
 
 
-@eh.revset('successors')
+@eh.revset('successors(set)')
 def revsetsuccessors(repo, subset, x):
-"""``successors(set)``
-Immediate successors of changesets in set.
+"""Immediate successors of changesets in set.
 """
 s = revset.getset(repo, revset.fullreposet(repo), x)
 s = revset.baseset(_successors(repo, s))
 s.sort()
 return subset & s
 
-@eh.revset('allsuccessors')
+@eh.revset('allsuccessors(set)')
 def revsetallsuccessors(repo, subset, x):
-"""``allsuccessors(set)``
-Transitive successors of changesets in set.
+"""Transitive successors of changesets in set.
 """
 s = revset.getset(repo, revset.fullreposet(repo), x)
 s = revset.baseset(_allsuccessors(repo, s))
diff --git a/hgext3rd/evolve/exthelper.py b/hgext3rd/evolve/exthelper.py
--- a/hgext3rd/evolve/exthelper.py
+++ b/hgext3rd/evolve/exthelper.py
@@ -93,8 +93,12 @@ class exthelper(object):
 - Register revset functions
 """
 knownexts = {}
+
+revsetpredicate = registrar.revsetpredicate()
 for name, symbol in self._revsetsymbols:
-revset.symbols[name] = symbol
+revsetpredicate(name)(symbol)
+revset.loadpredicate(ui, 'evolve', revsetpredicate)
+
 for name, kw in self._templatekws:
 templatekw.keywords[name] = kw
 for ext, command, wrapper, opts in self._extcommandwrappers:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D705: bundle2: move exception handling into part iterator

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

INLINE COMMENTS

> bundle2.py:368
> +def __exit__(self, type, exc, tb):
>  if not self.iterator:
>  return

Doesn't look like this can actually happen (if used properly in a 
with-statement)

> bundle2.py:402
> +if seekerror:
> +raise exc
> +

Looks like a small change in behavior here: the debug message below used to 
always be printed (before this patch and also before this series). Just 
pointing it out in case you didn't notice. I'll let you decide if it's worth 
restoring the message by putting it back in a finally-block.

REPOSITORY
  rHG Mercurial

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

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


[PATCH evolve-ext] topic: centralize compatibility logic between hg versions into compat module

2017-09-14 Thread FUJIWARA Katsunori
# HG changeset patch
# User FUJIWARA Katsunori 
# Date 1505050914 -32400
#  Sun Sep 10 22:41:54 2017 +0900
# Node ID 3412cce8dbb22a937e72939a5d726c0949715983
# Parent  23c9600607e7ea3c6d95cddc5ad134cab4f7d7fe
# Available At https://fo...@bitbucket.org/foozy/hgext-evolve
#  hg pull https://fo...@bitbucket.org/foozy/hgext-evolve -r 
3412cce8dbb2
# EXP-Topic topic-hg-version-portability
topic: centralize compatibility logic between hg versions into compat module

This patch can delay loading obsutil and obsolete modules until they
are actually used at "hg topics" or so, if demandimport of Mercurial
is enabled.

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -79,6 +79,7 @@ from mercurial import (
 )
 
 from . import (
+compat,
 constants,
 revset as topicrevset,
 destination,
@@ -727,16 +728,6 @@ def _showlasttouched(repo, fm, opts):
 fm.plain('\n')
 fm.end()
 
-getmarkers = None
-try:
-from mercurial import obsutil
-getmarkers = getattr(obsutil, 'getmarkers', None)
-except ImportError:
-pass
-
-if getmarkers is None:
-getmarkers = obsolete.getmarkers
-
 def _getlasttouched(repo, topics):
 """
 Calculates the last time a topic was used. Returns a dictionary of seconds
@@ -758,7 +749,7 @@ def _getlasttouched(repo, topics):
 maxtime = rt
 # looking on the markers also to get more information and accurate
 # last touch time.
-obsmarkers = getmarkers(repo, [repo[revs].node()])
+obsmarkers = compat.getmarkers(repo, [repo[revs].node()])
 for marker in obsmarkers:
 rt = marker.date()
 if rt[0] > maxtime[0]:
diff --git a/hgext3rd/topic/compat.py b/hgext3rd/topic/compat.py
new file mode 100644
--- /dev/null
+++ b/hgext3rd/topic/compat.py
@@ -0,0 +1,24 @@
+# Copyright 2017 FUJIWARA Katsunori 
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+"""
+Compatibility module
+"""
+from __future__ import absolute_import
+
+from mercurial import obsolete
+
+getmarkers = None
+successorssets = None
+try:
+from mercurial import obsutil
+getmarkers = getattr(obsutil, 'getmarkers', None)
+successorssets = getattr(obsutil, 'successorssets', None)
+except ImportError:
+pass
+
+if getmarkers is None:
+getmarkers = obsolete.getmarkers
+if successorssets is None:
+successorssets = obsolete.successorssets
diff --git a/hgext3rd/topic/evolvebits.py b/hgext3rd/topic/evolvebits.py
--- a/hgext3rd/topic/evolvebits.py
+++ b/hgext3rd/topic/evolvebits.py
@@ -1,15 +1,6 @@
 import collections
-from mercurial import obsolete
 
-successorssets = None
-try:
-from mercurial import obsutil
-successorssets = getattr(obsutil, 'successorssets', None)
-except ImportError:
-pass
-
-if successorssets is None:
-successorssets = obsolete.successorssets
+from . import compat
 
 # Copied from evolve 081605c2e9b6
 
@@ -82,14 +73,14 @@ def _singlesuccessor(repo, p):
 return p.rev()
 obs = repo[p]
 ui = repo.ui
-newer = successorssets(repo, obs.node())
+newer = compat.successorssets(repo, obs.node())
 # search of a parent which is not killed
 while not newer:
 ui.debug("stabilize target %s is plain dead,"
  " trying to stabilize on its parent\n" %
  obs)
 obs = obs.parents()[0]
-newer = successorssets(repo, obs.node())
+newer = compat.successorssets(repo, obs.node())
 if len(newer) > 1 or len(newer[0]) > 1:
 raise MultipleSuccessorsError(newer)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 4] configitems: register the 'mq.git' config

2017-09-14 Thread Yuya Nishihara
On Wed, 13 Sep 2017 08:31:12 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1498786994 -7200
> #  ven. juin 30 03:43:14 2017 +0200
> # Node ID ea821914bb23ec4365dbd92ca1ef4d25c4e28fb2
> # Parent  24bf823377fcbf49fec9da8adb796924dff91c73
> # EXP-Topic config.register.mq
> configitems: register the 'mq.git' config

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


Re: [PATCH V2] configitems: register the 'win32mbcs.encoding' config

2017-09-14 Thread Yuya Nishihara
On Wed, 13 Sep 2017 12:30:54 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1498787154 -7200
> #  ven. juin 30 03:45:54 2017 +0200
> # Node ID 5fb90f89802ce9428913ef67df6a96d66e218d51
> # Parent  a763c891f36e55f4869f443c220227d1da747d18
> # EXP-Topic config.register.win32mbcs
> configitems: register the 'win32mbcs.encoding' config

Queued this, thanks.
___
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-14 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa8d139c37353: copytrace: move fast heuristic copytracing 
algorithm to core (authored by pulkit, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D623?vs=1791=1815#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D623?vs=1791=1815

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

AFFECTED FILES
  mercurial/copies.py
  tests/test-copytrace-heuristics.t

CHANGE DETAILS

diff --git a/tests/test-copytrace-heuristics.t 
b/tests/test-copytrace-heuristics.t
new file mode 100644
--- /dev/null
+++ b/tests/test-copytrace-heuristics.t
@@ -0,0 +1,591 @@
+Test for the heuristic copytracing algorithm
+
+
+  $ cat >> $TESTTMP/copytrace.sh << '__EOF__'
+  > initclient() {
+  > cat >> $1/.hg/hgrc < [experimental]
+  > copytrace = heuristics
+  > EOF
+  > }
+  > __EOF__
+  $ . "$TESTTMP/copytrace.sh"
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > rebase=
+  > shelve=
+  > EOF
+
+Check filename heuristics (same dirname and same basename)
+  $ hg init server
+  $ cd server
+  $ echo a > a
+  $ mkdir dir
+  $ echo a > dir/file.txt
+  $ hg addremove
+  adding a
+  adding dir/file.txt
+  $ hg ci -m initial
+  $ hg mv a b
+  $ hg mv -q dir dir2
+  $ hg ci -m 'mv a b, mv dir/ dir2/'
+  $ cd ..
+  $ hg clone -q server repo
+  $ initclient repo
+  $ cd repo
+  $ hg up -q 0
+  $ echo b > a
+  $ echo b > dir/file.txt
+  $ hg ci -qm 'mod a, mod dir/file.txt'
+
+  $ hg log -G -T 'changeset: {node}\n desc: {desc}, phase: {phase}\n'
+  @  changeset: 557f403c0afd2a3cf15d7e2fb1f1001a8b85e081
+  |   desc: mod a, mod dir/file.txt, phase: draft
+  | o  changeset: 928d74bc9110681920854d845c06959f6dfc9547
+  |/desc: mv a b, mv dir/ dir2/, phase: public
+  o  changeset: 3c482b16e54596fed340d05ffaf155f156cda7ee
+  desc: initial, phase: public
+
+  $ hg rebase -s . -d 1
+  rebasing 2:557f403c0afd "mod a, mod dir/file.txt" (tip)
+  merging b and a to b
+  merging dir2/file.txt and dir/file.txt to dir2/file.txt
+  saved backup bundle to 
$TESTTMP/repo/.hg/strip-backup/557f403c0afd-9926eeff-rebase.hg (glob)
+  $ cd ..
+  $ rm -rf server
+  $ rm -rf repo
+
+Make sure filename heuristics do not when they are not related
+  $ hg init server
+  $ cd server
+  $ echo 'somecontent' > a
+  $ hg add a
+  $ hg ci -m initial
+  $ hg rm a
+  $ echo 'completelydifferentcontext' > b
+  $ hg add b
+  $ hg ci -m 'rm a, add b'
+  $ cd ..
+  $ hg clone -q server repo
+  $ initclient repo
+  $ cd repo
+  $ hg up -q 0
+  $ printf 'somecontent\nmoarcontent' > a
+  $ hg ci -qm 'mode a'
+
+  $ hg log -G -T 'changeset: {node}\n desc: {desc}, phase: {phase}\n'
+  @  changeset: d526312210b9e8f795d576a77dc643796384d86e
+  |   desc: mode a, phase: draft
+  | o  changeset: 46985f76c7e5e5123433527f5c8526806145650b
+  |/desc: rm a, add b, phase: public
+  o  changeset: e5b71fb099c29d9172ef4a23485aaffd497e4cc0
+  desc: initial, phase: public
+
+  $ hg rebase -s . -d 1
+  rebasing 2:d526312210b9 "mode a" (tip)
+  other [source] changed a which local [dest] deleted
+  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+  $ cd ..
+  $ rm -rf server
+  $ rm -rf repo
+
+Test when lca didn't modified the file that was moved
+  $ hg init server
+  $ cd server
+  $ echo 'somecontent' > a
+  $ hg add a
+  $ hg ci -m initial
+  $ echo c > c
+  $ hg add c
+  $ hg ci -m randomcommit
+  $ hg mv a b
+  $ hg ci -m 'mv a b'
+  $ cd ..
+  $ hg clone -q server repo
+  $ initclient repo
+  $ cd repo
+  $ hg up -q 1
+  $ echo b > a
+  $ hg ci -qm 'mod a'
+
+  $ hg log -G -T 'changeset: {node}\n desc: {desc}, phase: {phase}\n'
+  @  changeset: 9d5cf99c3d9f8e8b05ba55421f7f56530cfcf3bc
+  |   desc: mod a, phase: draft
+  | o  changeset: d760186dd240fc47b91eb9f0b58b0002aaeef95d
+  |/desc: mv a b, phase: public
+  o  changeset: 48e1b6ba639d5d7fb313fa7989eebabf99c9eb83
+  |   desc: randomcommit, phase: public
+  o  changeset: e5b71fb099c29d9172ef4a23485aaffd497e4cc0
+  desc: initial, phase: public
+
+  $ hg rebase -s . -d 2
+  rebasing 3:9d5cf99c3d9f "mod a" (tip)
+  merging b and a to b
+  saved backup bundle to 
$TESTTMP/repo/.hg/strip-backup/9d5cf99c3d9f-f02358cc-rebase.hg (glob)
+  $ cd ..
+  $ rm -rf server
+  $ rm -rf repo
+
+Rebase "backwards"
+  $ hg init server
+  $ cd server
+  $ echo 'somecontent' > a
+  $ hg add a
+  $ hg ci -m initial
+  $ echo c > c
+  $ hg add c
+  $ hg ci -m randomcommit
+  $ hg mv a b
+  $ hg ci -m 'mv a b'
+  $ cd ..
+  $ hg clone -q server repo
+  $ initclient repo
+  $ cd repo
+  $ hg up -q 2
+  $ echo b > b
+  $ hg ci -qm 'mod b'
+
+  $ hg log -G -T 'changeset: {node}\n desc: {desc}, phase: {phase}\n'
+  @  changeset: fbe97126b3969056795c462a67d93faf13e4d298
+  |   desc: mod b, phase: draft
+  o  changeset: 

D623: copytrace: move fast heuristic copytracing algorithm to core

2017-09-14 Thread yuja (Yuya Nishihara)
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Queued, thanks.
  
  > I don't think we can just swap c1 and c2 because what we're calculating
  >  is the copy from c1 to c2,
  
  For the record, this statement appears to be wrong, sorry. Perhaps the idea
  of swapping c1 and c2 would be valid, though there was a bug. However, I
  still think the new code is better because the untested part is simpler and
  less error-prone.

INLINE COMMENTS

> copies.py:637
> +baserev = base.rev()
> +if not repo.revs('%d::%d', baserev, c2rev):
> +# If base is not in c2 branch, we switch to fullcopytracing

Folded these variables which are used only once.

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