diff --git a/hgext/share.py b/hgext/share.py --- a/hgext/share.py +++ b/hgext/share.py @@ -123,7 +123,7 @@ def clone(orig, ui, source, *args, **opt def extsetup(ui): extensions.wrapfunction(bookmarks.bmstore, 'getbkfile', getbkfile) extensions.wrapfunction(bookmarks.bmstore, 'recordchange', recordchange) - extensions.wrapfunction(bookmarks.bmstore, 'write', write) + extensions.wrapfunction(bookmarks.bmstore, '_writerepo', writerepo) extensions.wrapcommand(commands.table, 'clone', clone) def _hassharedbookmarks(repo): @@ -166,10 +166,11 @@ def recordchange(orig, self, tr): category = 'share-bookmarks' tr.addpostclose(category, lambda tr: self._writerepo(srcrepo)) -def write(orig, self): +def writerepo(orig, self, repo): # First write local bookmarks file in case we ever unshare - orig(self) + orig(self, repo) + if _hassharedbookmarks(self._repo): srcrepo = _getsrcrepo(self._repo) if srcrepo is not None: - self._writerepo(srcrepo) + orig(self, srcrepo) diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -1174,3 +1174,42 @@ Try again but with a corrupted shelve st rebase aborted $ hg up -C . 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ cd .. + +Keep active bookmark while (un)shelving even on shared repo (issue4940) +----------------------------------------------------------------------- + + $ cat <> $HGRCPATH + > [extensions] + > share = + > EOF + + $ hg bookmarks -R repo + test 4:33f7f61e6c5e + $ hg share -B repo share + updating working directory + 6 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cd share + + $ hg bookmarks + test 4:33f7f61e6c5e + $ hg bookmarks foo + $ hg bookmarks + * foo 5:703117a2acfb + test 4:33f7f61e6c5e + $ echo x >> x + $ hg shelve + shelved as foo + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg bookmarks + * foo 5:703117a2acfb + test 4:33f7f61e6c5e + + $ hg unshelve + unshelving change 'foo' + $ hg bookmarks + * foo 5:703117a2acfb + test 4:33f7f61e6c5e + + $ cd ..