Mercurial > hg
changeset 26998:4414d500604f
localrepo: put bookmark move following commit in one transaction
Before this patch, making a commit on a local repo could move a bookmark and
both operations would not be grouped as one transaction. This patch makes both
operations part of one transaction. This is necessary to switch to the new api
to save bookmarks repo._bookmarks.recordchange if we don't want to change the
current behavior of rollback.
Dirstate change happening after the commit is done is now part of the
transaction mentioned above. This leads to a change in the expected output of
several tests.
The change to test-fncache happens because both lock are now released in the
same finally clause. The lock release is made explicitly buggy in this test.
Previously releasing lock would crash triggering release of wlock that crashes
too. Now lock release crash does not directly result in the release of wlock.
Instead wlock is released at garbage collection time and the error raised at
that time "confuses" python.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 18 Nov 2015 01:36:58 -0800 |
parents | 1791f9aa782f |
children | 2d79a354d843 |
files | mercurial/localrepo.py tests/test-fncache.t tests/test-hardlinks.t tests/test-histedit-edit.t tests/test-inherit-mode.t tests/test-mq-qfold.t tests/test-mq-qnew.t tests/test-mq-qrefresh-replace-log-message.t tests/test-rollback.t tests/test-tag.t |
diffstat | 10 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Nov 17 15:43:21 2015 -0800 +++ b/mercurial/localrepo.py Wed Nov 18 01:36:58 2015 -0800 @@ -1455,8 +1455,9 @@ match.explicitdir = vdirs.append match.bad = fail - wlock = self.wlock() + wlock = lock = tr = None try: + wlock = self.wlock() wctx = self[None] merge = len(wctx.parents()) > 1 @@ -1591,23 +1592,26 @@ subrepo.writestate(self, newstate) p1, p2 = self.dirstate.parents() + lock = self.lock() hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') try: self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2) + tr = self.transaction('commit') ret = self.commitctx(cctx, True) except: # re-raises if edited: self.ui.write( _('note: commit message saved in %s\n') % msgfn) raise - # update bookmarks, dirstate and mergestate bookmarks.update(self, [p1, p2], ret) cctx.markcommitted(ret) ms.reset() + tr.close() + finally: - wlock.release() + lockmod.release(tr, lock, wlock) def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): # hack for command that use a temporary commit (eg: histedit)
--- a/tests/test-fncache.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-fncache.t Wed Nov 18 01:36:58 2015 -0800 @@ -96,6 +96,7 @@ .hg/phaseroots .hg/requires .hg/undo + .hg/undo.backup.dirstate .hg/undo.backupfiles .hg/undo.bookmarks .hg/undo.branch @@ -132,6 +133,7 @@ .hg/store/undo .hg/store/undo.backupfiles .hg/store/undo.phaseroots + .hg/undo.backup.dirstate .hg/undo.bookmarks .hg/undo.branch .hg/undo.desc @@ -223,6 +225,7 @@ $ touch y $ hg ci -qAm y abort: forced lock failure + Exception mercurial.error.Abort: Abort('forced lock failure',) in <bound method lock.__del__ of <mercurial.lock.lock object at *>> ignored (glob) [255] $ cat .hg/store/fncache data/y.i
--- a/tests/test-hardlinks.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-hardlinks.t Wed Nov 18 01:36:58 2015 -0800 @@ -229,6 +229,7 @@ 2 r4/.hg/store/undo.backup.phaseroots 2 r4/.hg/store/undo.backupfiles 2 r4/.hg/store/undo.phaseroots + 2 r4/.hg/undo.backup.dirstate 2 r4/.hg/undo.bookmarks 2 r4/.hg/undo.branch 2 r4/.hg/undo.desc @@ -264,6 +265,7 @@ 2 r4/.hg/store/undo.backup.phaseroots 2 r4/.hg/store/undo.backupfiles 2 r4/.hg/store/undo.phaseroots + 2 r4/.hg/undo.backup.dirstate 2 r4/.hg/undo.bookmarks 2 r4/.hg/undo.branch 2 r4/.hg/undo.desc
--- a/tests/test-histedit-edit.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-histedit-edit.t Wed Nov 18 01:36:58 2015 -0800 @@ -364,9 +364,9 @@ HG: branch 'default' HG: added f ==== + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt abort: pretxncommit.unexpectedabort hook exited with status 1 [255] $ cat .hg/last-message.txt @@ -388,9 +388,9 @@ HG: user: test HG: branch 'default' HG: added f + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt abort: pretxncommit.unexpectedabort hook exited with status 1 [255]
--- a/tests/test-inherit-mode.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-inherit-mode.t Wed Nov 18 01:36:58 2015 -0800 @@ -83,6 +83,7 @@ 00660 ./.hg/store/undo 00660 ./.hg/store/undo.backupfiles 00660 ./.hg/store/undo.phaseroots + 00660 ./.hg/undo.backup.dirstate 00660 ./.hg/undo.bookmarks 00660 ./.hg/undo.branch 00660 ./.hg/undo.desc
--- a/tests/test-mq-qfold.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-mq-qfold.t Wed Nov 18 01:36:58 2015 -0800 @@ -229,9 +229,9 @@ HG: added aa HG: changed a ==== + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt qrefresh interrupted while patch was popped! (revert --all, qpush to recover) abort: pretxncommit.unexpectedabort hook exited with status 1 [255]
--- a/tests/test-mq-qnew.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-mq-qnew.t Wed Nov 18 01:36:58 2015 -0800 @@ -299,9 +299,9 @@ HG: branch 'default' HG: no files changed ==== + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt abort: pretxncommit.unexpectedabort hook exited with status 1 [255] $ cat .hg/last-message.txt
--- a/tests/test-mq-qrefresh-replace-log-message.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-mq-qrefresh-replace-log-message.t Wed Nov 18 01:36:58 2015 -0800 @@ -185,9 +185,9 @@ HG: branch 'default' HG: added file2 ==== + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt qrefresh interrupted while patch was popped! (revert --all, qpush to recover) abort: pretxncommit.unexpectedabort hook exited with status 1 [255] @@ -228,9 +228,9 @@ 0:25e397dabed2 A file2 ==== + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt qrefresh interrupted while patch was popped! (revert --all, qpush to recover) abort: pretxncommit.unexpectedabort hook exited with status 1 [255]
--- a/tests/test-rollback.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-rollback.t Wed Nov 18 01:36:58 2015 -0800 @@ -113,9 +113,9 @@ > echo "another precious commit message" > "$1" > __EOF__ $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg --config hooks.pretxncommit=false commit 2>&1 + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt abort: pretxncommit hook exited with status * (glob) [255] $ cat .hg/last-message.txt
--- a/tests/test-tag.t Tue Nov 17 15:43:21 2015 -0800 +++ b/tests/test-tag.t Wed Nov 18 01:36:58 2015 -0800 @@ -272,9 +272,9 @@ HG: branch 'tag-and-branch-same-name' HG: changed .hgtags ==== + note: commit message saved in .hg/last-message.txt transaction abort! rollback completed - note: commit message saved in .hg/last-message.txt abort: pretxncommit.unexpectedabort hook exited with status 1 [255] $ cat .hg/last-message.txt