hgext/evolve.py
changeset 1005 4fe159fdfc4c
parent 1004 808a33826700
child 1006 deba3a063c63
--- a/hgext/evolve.py	Tue Jul 29 17:15:57 2014 -0700
+++ b/hgext/evolve.py	Mon Jul 28 00:08:06 2014 +0200
@@ -2320,18 +2320,26 @@
 
 
 
-@eh.wrapfunction(exchange, '_pushobsolete')
-def _pushobsolete(orig, pushop):
-    """utility function to push obsolete markers to a remote"""
-    pushop.ui.debug('try to push obsolete markers to remote\n')
+
+def _obsmarkersdiscovery(pushop):
+    """return the list of marker that needs to be pushed to the server
+
+    When used before (or at the same time) the changegroup have been pushed, it
+    returns the value as if the planned changegroup was succesful. Othewise it
+    use te actual common heads to decide whats needs to be pushed.
+    """
     repo = pushop.repo
     remote = pushop.remote
     unfi = repo.unfiltered()
     cl = unfi.changelog
+    commonheads = pushop.commonheads
+    if commonheads is None:
+        # ctx not pushed yet, we try to be in the same bundle2
+        commonheads = pushop.outgoing.missingheads
     if (obsolete._enabled and repo.obsstore and
         'obsolete' in remote.listkeys('namespaces')):
         repo.ui.status("OBSEXC: computing relevant nodes\n")
-        revs = unfi.revs('::%ln', pushop.commonheads)
+        revs = unfi.revs('::%ln', commonheads)
         common = []
         if remote.capable('_evoext_obshash_0'):
             repo.ui.status("OBSEXC: looking for common markers in %i nodes\n"
@@ -2346,6 +2354,24 @@
         else:
             repo.ui.status("OBSEXC: markers already in sync\n")
             markers = []
+        return markers
+
+@eh.wrapfunction(exchange, '_pushobsolete')
+def _pushobsolete(orig, pushop):
+    """utility function to push obsolete markers to a remote"""
+    stepsdone = getattr(pushop, 'stepsdone', None)
+    if stepsdone is not None:
+        if 'obsmarkers' in stepsdone:
+            return
+        stepsdone.add('obsmarkers')
+    pushop.ui.debug('try to push obsolete markers to remote\n')
+    repo = pushop.repo
+    remote = pushop.remote
+    unfi = repo.unfiltered()
+    cl = unfi.changelog
+    if (obsolete._enabled and repo.obsstore and
+        'obsolete' in remote.listkeys('namespaces')):
+        markers = _obsmarkersdiscovery(pushop)
         if not markers:
             repo.ui.status("OBSEXC: no marker to push\n")
         elif remote.capable('_evoext_b2x_obsmarkers_0'):