Patchwork [5,of,6] changegroup: add a `targetphase` argument to `addchangegroup`

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 4:27 a.m.
Message ID <d11c2e8f86f1de73e292.1407299253@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5287/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 6, 2014, 4:27 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1407271778 25200
#      Tue Aug 05 13:49:38 2014 -0700
# Node ID d11c2e8f86f1de73e2922dbf6a42cc38f61e1bef
# Parent  ab3ee8efb2e3f80826985df5d1a8837a4d539a52
changegroup: add a `targetphase` argument to `addchangegroup`

This argument control the phase used for the added changesets. This can be
useful to unbundle in "secret" phase as required by shelve.

This changes aims at helping high level code to get rid of manual phase
movement. An important milestone for having phases part of the transaction.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -567,11 +567,12 @@  def addchangegroupfiles(repo, source, re
                     _('missing file data for %s:%s - run hg verify') %
                     (f, hex(n)))
 
     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.
 
     Return an integer summarizing the change to this repo:
@@ -699,17 +700,20 @@  def addchangegroup(repo, source, srctype
             # We should not use added here but the list of all change in
             # the bundle
             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)
 
         tr.close()