[PATCH 4 of 4] phases: Only synchronize on commonheads when push failed

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jan 13 15:58:17 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1326491670 -3600
# Node ID bbc93193d3d51dc5e212efbac9cd123f181db025
# Parent  11eda234598fa3849faeae573970b8e447a436b2
phases: Only synchronize on commonheads when push failed

If push failed we should not expect the pushed changeset to exist on remote.
The common set before the push is used for phase related operation instead of
common + missing.

Note:
  * We still pull phase data even if push fails
  * We still try to push data even if push fails (same than bookmark)

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1623,33 +1623,32 @@
                         # we return an integer indicating remote head count change
                         ret = remote.addchangegroup(cg, 'push', self.url())
 
-                fut = outgoing.commonheads + outgoing.missingheads
+                # get the heads of the now common subset
+                cheads = outgoing.commonheads[:]
+                if cg is not None and ret:
+                    # push succeed, synchonize common + pushed
+                    cheads += outgoing.missingheads
 
                 # even when we don't push, exchanging phase data is useful
                 remotephases = remote.listkeys('phases')
                 if not remotephases: # old server or public only repo
-                    phases.advanceboundary(self, phases.public, fut)
+                    phases.advanceboundary(self, phases.public, cheads)
                     # don't push any phase data as there is nothing to push
                 else:
-                    ana = phases.analyzeremotephases(self, fut, remotephases)
+                    ana = phases.analyzeremotephases(self, cheads, remotephases)
                     pheads, droots = ana
                     ### Apply remote phase on local
                     if remotephases.get('publishing', False):
-                        phases.advanceboundary(self, phases.public, fut)
+                        phases.advanceboundary(self, phases.public, cheads)
                     else: # publish = False
                         phases.advanceboundary(self, phases.public, pheads)
-                        phases.advanceboundary(self, phases.draft, fut)
+                        phases.advanceboundary(self, phases.draft, cheads)
                     ### Apply local phase on remote
-                    #
-                    # XXX If push failed we should use strict common and not
-                    # future to avoid pushing phase data on unknown changeset.
-                    # This is to done later.
-
                     # Get the list of all revs draft on remote by public here.
                     # XXX Beware that revset break if droots is not strictly
                     # XXX root we may want to ensure it is but it is costly
                     outdated =  self.set('heads((%ln::%ln) and public())',
-                                         droots, fut)
+                                         droots, cheads)
                     for newremotehead in outdated:
                         r = remote.pushkey('phases',
                                            newremotehead.hex(),
diff --git a/tests/test-push-http.t b/tests/test-push-http.t
--- a/tests/test-push-http.t
+++ b/tests/test-push-http.t
@@ -29,7 +29,7 @@
   searching for changes
   remote: ssl required
   remote: ssl required
-  updating ba677d0156c1 to public failed!
+  updating cb9a9f314b8b to public failed!
   % serve errors
 
 expect authorization error


More information about the Mercurial-devel mailing list