changeset 36944:8fd9b56e8d7c

push-discovery: extract the bookmark comparison logic in its own function This will help extensions to alter the behavior as they see fit.
author Boris Feld <boris.feld@octobus.net>
date Fri, 09 Mar 2018 15:53:41 +0100
parents cc51b6a07869
children 45bfcd16f27e
files mercurial/exchange.py
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Mar 09 16:31:35 2018 +0100
+++ b/mercurial/exchange.py	Fri Mar 09 15:53:41 2018 +0100
@@ -624,12 +624,21 @@
                 for (b, scid, dcid) in bookmarks]
 
     comp = [hexifycompbookmarks(marks) for marks in comp]
+    return _processcompared(pushop, ancestors, explicit, remotebookmark, comp)
+
+def _processcompared(pushop, pushed, explicit, remotebms, comp):
+    """take decision on bookmark to pull from the remote bookmark
+
+    Exist to help extensions who want to alter this behavior.
+    """
     addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp
 
+    repo = pushop.repo
+
     for b, scid, dcid in advsrc:
         if b in explicit:
             explicit.remove(b)
-        if not ancestors or repo[scid].rev() in ancestors:
+        if not pushed or repo[scid].rev() in pushed:
             pushop.outbookmarks.append((b, dcid, scid))
     # search added bookmark
     for b, scid, dcid in addsrc:
@@ -655,8 +664,8 @@
     if explicit:
         explicit = sorted(explicit)
         # we should probably list all of them
-        ui.warn(_('bookmark %s does not exist on the local '
-                  'or remote repository!\n') % explicit[0])
+        pushop.ui.warn(_('bookmark %s does not exist on the local '
+                         'or remote repository!\n') % explicit[0])
         pushop.bkresult = 2
 
     pushop.outbookmarks.sort()