# HG changeset patch # User Pierre-Yves David # Date 2012-07-17 16:14:16 # Node ID 246131d670c263d8006371b71dc56841ea7f3551 # Parent 4f321eecbf8d6819ba040340a77592773be88298 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 @@ def checkheads(repo, remote, outgoing, r 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 @@ def checkheads(repo, remote, outgoing, r 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: