bookmarks: do not overwrite bookmarks.current if not necessary
authorDavid Soria Parra <dsp@php.net>
Sat, 06 Dec 2008 19:30:20 +0100
changeset 7484 167853c7e54a
parent 7483 187a13bd14c6
child 7485 ecfb683675ed
child 7487 63446383dfb7
bookmarks: do not overwrite bookmarks.current if not necessary If we update to the ref that the bookmarks.current points to, we do not want to update bookmarks.current
hgext/bookmarks.py
--- a/hgext/bookmarks.py	Sat Dec 06 14:03:30 2008 +0200
+++ b/hgext/bookmarks.py	Sat Dec 06 19:30:20 2008 +0100
@@ -96,9 +96,15 @@
     Set the name of the bookmark that we are on (hg update <bookmark>).
     The name is recoreded in .hg/bookmarks.current
     '''
-    if repo._bookmarkcurrent == mark:
+    if current(repo) == mark:
         return
+
     refs = parse(repo)
+
+    'do not update if we do update to an rev equal to the current bookmark'
+    if (mark not in refs and
+        current(repo) and refs[current(repo)] == repo.changectx('.').node()):
+        return
     if mark not in refs:
         mark = ''
     file = repo.opener('bookmarks.current', 'w+')