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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 25 16:51:13 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1351201432 -7200
# Branch stable
# Node ID f13b8ee57d1e541a0e7bfcf7a938005dd7641a64
# Parent  6a780ab5ede790067187aee1483f914731e7c360
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.

This have no impact on the result of this function.

- Descendants of unknown changeset as unknown,
- all successors of unknown changesets are already return by the call who
  returned those same unknown changesets,
- unknown changesets are never a valid destination for a bookmark.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -256,7 +256,7 @@
     elif repo.obsstore:
         # We only need this complicated logic if there is obsolescence
         # XXX will probably deserve an optimised revset.
-
+        nm = repo.changelog.nodemap
         validdests = set([old])
         plen = -1
         # compute the whole set of successors or descendants
@@ -268,7 +268,8 @@
                     # obsolescence marker does not apply to public changeset
                     succs.update(obsolete.allsuccessors(repo.obsstore,
                                                         [c.node()]))
-            validdests = set(repo.set('%ln::', succs))
+            known = (n for n in succs if nm.get(n) is not None)
+            validdests = set(repo.set('%ln::', known))
         validdests.remove(old)
         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