diff hgext/shelve.py @ 19874:5836edcbdc2e

shelve: copy bookmarks and restore them after a commit cmdutil.commit() will advance the bookmarks. Therefore we have to restore them afterwards. We have to use update() to ensure we preserve the bmstore object.
author David Soria Parra <dsp@experimentalworks.net>
date Thu, 03 Oct 2013 19:41:25 +0200
parents 28b1b7b9b4a9
children 821a89018f17
line wrap: on
line diff
--- a/hgext/shelve.py	Thu Oct 03 14:50:47 2013 +0200
+++ b/hgext/shelve.py	Thu Oct 03 19:41:25 2013 +0200
@@ -172,11 +172,12 @@
 
     name = opts['name']
 
-    wlock = lock = tr = None
+    wlock = lock = tr = bms = None
     try:
         wlock = repo.wlock()
         lock = repo.lock()
 
+        bms = repo._bookmarks.copy()
         # use an uncommited transaction to generate the bundle to avoid
         # pull races. ensure we don't print the abort message to stderr.
         tr = repo.transaction('commit', report=lambda x: None)
@@ -224,11 +225,16 @@
                        fp=shelvedfile(repo, name, 'patch').opener('wb'),
                        opts=mdiff.diffopts(git=True))
 
+
         if ui.formatted():
             desc = util.ellipsis(desc, ui.termwidth())
         ui.status(_('shelved as %s\n') % name)
         hg.update(repo, parent.node())
     finally:
+        if bms:
+            # restore old bookmarks
+            repo._bookmarks.update(bms)
+            repo._bookmarks.write()
         if tr:
             tr.abort()
         lockmod.release(lock, wlock)