diff hgext/share.py @ 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 56b2bcea2529
children 34d26e22a2b0
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)