[PATCH 3 of 3] shelve: copy bookmarks and restore them after a commit
David Soria Parra
dsp at experimentalworks.net
Thu Oct 3 09:47:44 CDT 2013
# HG changeset patch
# User David Soria Parra <dsp at experimentalworks.net>
# Date 1380806188 -7200
# Thu Oct 03 15:16:28 2013 +0200
# Node ID 9e7613f80b09e92726b81adb8b267bf93aec2ff0
# Parent a9c81ba427312f5b0eb0c6f18ead265a89d87623
shelve: copy bookmarks and restore them after a commit
cmdutil.commit() will advance the bookmarks. Therefore we have to restore
them afterwards.
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -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,15 @@
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
+ bms.write()
if tr:
tr.abort()
lockmod.release(lock, wlock)
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -418,3 +418,23 @@
default (*) create conflict (glob)
$ hg shelve --cleanup
$ hg shelve --list
+
+test bookmarks
+
+ $ hg bookmark test
+ $ hg bookmark
+ * test 5:01ba9745dc5a
+ $ hg shelve
+ shelved as test
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ hg bookmark
+ * test 5:01ba9745dc5a
+ $ hg unshelve
+ unshelving change 'test'
+ adding changesets
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 7 files
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg bookmark
+ * test 5:01ba9745dc5a
More information about the Mercurial-devel
mailing list