Mercurial > hg
changeset 26933:a7eecd021782 stable
share: wrap bmstore._writerepo for transaction sensitivity (issue4940)
46dec89fe888 made 'bmstore.write()' transaction sensitive, to restore
original bookmarks correctly at failure of a transaction.
For example, shelve and unshelve imply steps below:
before 46dec89fe888:
1. move active bookmark forward at internal rebasing
2. 'bmstore.write()' writes updated ones into .hg/bookmarks
3. rollback transaction to remove internal commits
4. restore updated bookmarks manually
after 46dec89fe888:
1. move active bookmark forward at internal rebasing
2. 'bmstore.write()' doesn't write updated ones into .hg/bookmarks
(these are written into .hg/bookmarks.pending, if external hook
is spawn)
3. rollback transaction to remove internal commits
4. .hg/bookmarks should be clean, because it isn't changed while
transaction running: see (2) above
But if shelve or unshelve is executed in the repository created with
"shared bookmarks" ("hg share -B"), this doesn't work as expected,
because:
- share extension makes 'bmstore.write()' write updated bookmarks
into .hg/bookmarks of shared source repository regardless of
transaction activity, and
- intentional transaction failure at the end of shelve/unshelve
doesn't restore already updated .hg/bookmarks of shared source
This patch makes share extension wrap 'bmstore._writerepo()' instead
of 'bmstore.write()', because the former is used to actually write
bookmark changes out.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 13 Nov 2015 02:36:30 +0900 |
parents | 0994ef28e798 |
children | 2fb17f60bffa 8a256cee72c8 |
files | hgext/share.py tests/test-shelve.t |
diffstat | 2 files changed, 44 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/share.py Tue Nov 10 09:58:10 2015 -0800 +++ b/hgext/share.py Fri Nov 13 02:36:30 2015 +0900 @@ -123,7 +123,7 @@ 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 @@ 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)
--- a/tests/test-shelve.t Tue Nov 10 09:58:10 2015 -0800 +++ b/tests/test-shelve.t Fri Nov 13 02:36:30 2015 +0900 @@ -1174,3 +1174,42 @@ 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 <<EOF >> $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 ..