diff mercurial/bookmarks.py @ 13352:f9cd37fca5ba

bookmarks: move update into core
author Matt Mackall <mpm@selenic.com>
date Thu, 10 Feb 2011 13:46:27 -0600
parents 6c5368cd2df9
children 689bf32b3bbd
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
+++ b/mercurial/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
@@ -105,3 +105,19 @@
     finally:
         wlock.release()
     repo._bookmarkcurrent = mark
+
+def update(repo, parents, node):
+    marks = repo._bookmarks
+    update = False
+    if repo.ui.configbool('bookmarks', 'track.current'):
+        mark = repo._bookmarkcurrent
+        if mark and marks[mark] in parents:
+            marks[mark] = node
+            update = True
+    else:
+        for mark, n in marks.items():
+            if n in parents:
+                marks[mark] = node
+                update = True
+    if update:
+        write(repo)