[PATCH 2 of 2] discovery: pass pushop to _nowarnheads

Ryan McElroy rm at fb.com
Tue Nov 10 13:21:00 CST 2015


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1447182985 28800
#      Tue Nov 10 11:16:25 2015 -0800
# Node ID e07ce4ccd15e6b16a99516b2d86d160c0cb84ea4
# Parent  a44afd1adea7ef653244e1a290c84c1bb3ccdb0b
discovery: pass pushop to _nowarnheads

Previously, we passed only enough information to _nowarnheads to perform the old
calculation. However, extensions may want to use more information in this
calculation. Now that pushop is extensible, extensions will often want access
to the additional fields they have added to the pushop, so pass that through.

Specifically, the remotenames extension will use this information to allow
pushing new heads that are bookmarked without requiring --force.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -238,8 +238,14 @@ def _oldheadssummary(repo, remoteheads, 
         unsynced = set()
     return {None: (oldheads, newheads, unsynced)}
 
-def _nowarnheads(repo, remote, newbookmarks):
+def _nowarnheads(pushop):
     # Compute newly pushed bookmarks. We don't warn about bookmarked heads.
+
+    # internal config: bookmarks.pushing
+    newbookmarks = pushop.ui.configlist('bookmarks', 'pushing')
+
+    repo = pushop.repo.unfiltered()
+    remote = pushop.remote
     localbookmarks = repo._bookmarks
     remotebookmarks = remote.listkeys('bookmarks')
     bookmarkedheads = set()
@@ -268,9 +274,6 @@ def checkheads(pushop):
     newbranch = pushop.newbranch
     inc = bool(pushop.incoming)
 
-    # internal config: bookmarks.pushing
-    newbookmarks = pushop.ui.configlist('bookmarks', 'pushing')
-
     # Check for each named branch if we're creating new remote heads.
     # To be a remote head after push, node must be either:
     # - unknown locally
@@ -296,7 +299,7 @@ def checkheads(pushop):
                                 " new remote branches"))
 
     # 2. Find heads that we need not warn about
-    nowarnheads = _nowarnheads(repo, remote, newbookmarks)
+    nowarnheads = _nowarnheads(pushop)
 
     # 3. Check for new heads.
     # If there are more heads after the push than before, a suitable


More information about the Mercurial-devel mailing list