changeset 22041:97f86ce79abe

changegroup: add a `targetphase` argument to `addchangegroup` This argument controls the phase used for the added changesets. This can be useful to unbundle in "secret" phase as required by shelve. This change aims at helping high-level code get rid of manual phase movement. An important milestone for having phases part of the transaction.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 05 Aug 2014 13:49:38 -0700
parents 122fa73657c6
children 8d99c107b041
files mercurial/changegroup.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Tue Aug 05 14:37:45 2014 -0700
+++ b/mercurial/changegroup.py	Tue Aug 05 13:49:38 2014 -0700
@@ -569,7 +569,8 @@
 
     return revisions, files
 
-def addchangegroup(repo, source, srctype, url, emptyok=False):
+def addchangegroup(repo, source, srctype, url, emptyok=False,
+                   targetphase=phases.draft):
     """Add the changegroup returned by source.read() to this repo.
     srctype is a string like 'push', 'pull', or 'unbundle'.  url is
     the URL of the repo where this changegroup is coming from.
@@ -701,13 +702,16 @@
             if publishing:
                 phases.advanceboundary(repo, phases.public, srccontent)
             else:
+                # Those changesets have been pushed from the outside, their
+                # phases are going to be pushed alongside. Therefor
+                # `targetphase` is ignored.
                 phases.advanceboundary(repo, phases.draft, srccontent)
                 phases.retractboundary(repo, phases.draft, added)
         elif srctype != 'strip':
             # publishing only alter behavior during push
             #
             # strip should not touch boundary at all
-            phases.retractboundary(repo, phases.draft, added)
+            phases.retractboundary(repo, targetphase, added)
 
         # make changelog see real files again
         cl.finalize(trp)