changeset 7550:fead6cf99a09

bookmarks: set the current bookmark to the new name if we rename the current bookmark If we rename the current bookmark, we have to set the current bookmark to the new name.
author David Soria Parra <dsp@php.net>
date Thu, 18 Dec 2008 10:51:11 +0100
parents 9b64589b1112
children cab1cf26ca58
files hgext/bookmarks.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bookmarks.py	Sun Dec 07 19:33:26 2008 +0100
+++ b/hgext/bookmarks.py	Thu Dec 18 10:51:11 2008 +0100
@@ -64,9 +64,9 @@
     '''
     if os.path.exists(repo.join('bookmarks')):
         util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks'))
-    file = repo.opener('bookmarks', 'w+')
     if current(repo) not in refs:
         setcurrent(repo, None)
+    file = repo.opener('bookmarks', 'w+')
     for refspec, node in refs.items():
         file.write("%s %s\n" % (hex(node), refspec))
     file.close()
@@ -138,6 +138,8 @@
             raise util.Abort(_("new bookmark name required"))
         marks[mark] = marks[rename]
         del marks[rename]
+        if current(repo) == rename:
+            setcurrent(repo, mark)
         write(repo, marks)
         return