diff mercurial/bookmarks.py @ 13478:c631ac076375 stable

bookmarks: restrict moving a bookmark to its descendants (issue1502) A bookmark can only move to a descendant on commit, pull or unbundle. Bookmarks cannot jump between heads anymore. This fixese issue 1502. We explicitly use new.node(), to emphasise that we are updating the current bookmark to the new node.
author David Soria Parra <dsp@php.net>
date Thu, 24 Feb 2011 14:38:50 +0100
parents 0fe36c347c00
children 71a96f6c205d
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Fri Feb 18 17:09:08 2011 -0600
+++ b/mercurial/bookmarks.py	Thu Feb 24 14:38:50 2011 +0100
@@ -127,8 +127,11 @@
     update = False
     mark = repo._bookmarkcurrent
     if mark and marks[mark] in parents:
-        marks[mark] = node
-        update = True
+        old = repo[marks[mark]]
+        new = repo[node]
+        if new in old.descendants():
+            marks[mark] = new.node()
+            update = True
     if update:
         write(repo)