checkheads: extract bookmark computation from the branch loop
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 17 Jul 2012 18:14:16 +0200
changeset 17212 246131d670c2
parent 17211 4f321eecbf8d
child 17213 7eb5aa1f83fd
checkheads: extract bookmark computation from the branch loop No branch specific data are used in the computation of the bookmarked heads. We can only compute it once.
mercurial/discovery.py
--- a/mercurial/discovery.py	Tue Jul 17 16:30:42 2012 +0200
+++ b/mercurial/discovery.py	Tue Jul 17 18:14:16 2012 +0200
@@ -249,12 +249,22 @@
                          hint=_("use 'hg push --new-branch' to create"
                                 " new remote branches"))
 
-    # 2. Check for new heads.
+    # 2 compute newly pushed bookmarks. We
+    # we don't warned about bookmarked heads.
+    localbookmarks = repo._bookmarks
+    remotebookmarks = remote.listkeys('bookmarks')
+    bookmarkedheads = set()
+    for bm in localbookmarks:
+        rnode = remotebookmarks.get(bm)
+        if rnode and rnode in repo:
+            lctx, rctx = repo[bm], repo[rnode]
+            if rctx == lctx.ancestor(rctx):
+                bookmarkedheads.add(lctx.node())
+
+    # 3. Check for new heads.
     # If there are more heads after the push than before, a suitable
     # error message, depending on unsynced status, is displayed.
     error = None
-    localbookmarks = repo._bookmarks
-
     unsynced = False
     for branch, heads in headssum.iteritems():
         if heads[0] is None:
@@ -267,14 +277,6 @@
         newhs = set(heads[1])
         dhs = None
         if len(newhs) > len(oldhs):
-            remotebookmarks = remote.listkeys('bookmarks')
-            bookmarkedheads = set()
-            for bm in localbookmarks:
-                rnode = remotebookmarks.get(bm)
-                if rnode and rnode in repo:
-                    lctx, rctx = repo[bm], repo[rnode]
-                    if rctx == lctx.ancestor(rctx):
-                        bookmarkedheads.add(lctx.node())
             # strip updates to existing remote heads from the new heads list
             dhs = list(newhs - bookmarkedheads - oldhs)
         if dhs: