[PATCH 5 of 5 STABLE] bookmark: prevent crashing when a successor is unknown locally (issue3680)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Oct 24 17:32:22 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1351094342 -7200
# Branch stable
# Node ID 068e0c5b23aab7123609c4ed3b6dfcd35ec72d58
# Parent  bbf650099da1cb369cf76c3f5fdea0fef9da9ef3
bookmark: prevent crashing when a successor is unknown locally (issue3680)

The `%ln` revset substitution does not accept unknown node. We prune unknown
node from potential successors before computing descendants.

Computing the set of known node is convoluted because changelog have not cheap
was to get all nodes in a repo.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -257,6 +257,12 @@
         # We only need this complicated logic if there is obsolescence
         # XXX will probably deserve an optimised revset.
 
+        # set of all known node
+        nm = repo.changelog.nodemap
+        if util.safehasattr(nm, 'nodemap'): # node map is C version of the index
+            known = set(entry[7] for entry in nm)
+        else:
+            known = set(nm)
         validdests = set([old])
         plen = -1
         # compute the whole set of successors or descendants
@@ -266,6 +272,7 @@
             # obsolescence marker does not apply to immutable changeset
             mutable = [c.node() for c in validdests if c.mutable()]
             succs.update(obsolete.allsuccessors(repo.obsstore, mutable))
+            succs.intersection_update(known)
             validdests = set(repo.set('%ln::', succs))
         return new in validdests
     else:
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -262,7 +262,8 @@
   4efff6d98829d9c824c621afd6e3f01865f5439f
   $ hg id --debug -r 5
   c922c0139ca03858f655e4a2af4dd02796a63969 tip Y
-  $ hg debugobsolete f6fc62dde3c0771e29704af56ba4d8af77abcc2f 4efff6d98829d9c824c621afd6e3f01865f5439f
+  $ hg debugobsolete f6fc62dde3c0771e29704af56ba4d8af77abcc2f cccccccccccccccccccccccccccccccccccccccc
+  $ hg debugobsolete cccccccccccccccccccccccccccccccccccccccc 4efff6d98829d9c824c621afd6e3f01865f5439f
   $ hg push http://localhost:$HGPORT2/
   pushing to http://localhost:$HGPORT2/
   searching for changes


More information about the Mercurial-devel mailing list