[PATCH 09 of 11 full-series] checkheads: Extract bookmark computation from the branch loop
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Jul 17 22:15:56 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1342541656 -7200
# Node ID 0c90b4f033af368c3abe1bc240d9049588182914
# Parent 902d9d02422a14e42b070e0ca81457d0b6105187
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.
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -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:
More information about the Mercurial-devel
mailing list