Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 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 | bf3eec62212f |
children | dfb31eebd949 |
comparison
equal
deleted
inserted
replaced
26997:1791f9aa782f | 26998:4414d500604f |
---|---|
1453 if not force: | 1453 if not force: |
1454 vdirs = [] | 1454 vdirs = [] |
1455 match.explicitdir = vdirs.append | 1455 match.explicitdir = vdirs.append |
1456 match.bad = fail | 1456 match.bad = fail |
1457 | 1457 |
1458 wlock = self.wlock() | 1458 wlock = lock = tr = None |
1459 try: | 1459 try: |
1460 wlock = self.wlock() | |
1460 wctx = self[None] | 1461 wctx = self[None] |
1461 merge = len(wctx.parents()) > 1 | 1462 merge = len(wctx.parents()) > 1 |
1462 | 1463 |
1463 if not force and merge and match.ispartial(): | 1464 if not force and merge and match.ispartial(): |
1464 raise error.Abort(_('cannot partially commit a merge ' | 1465 raise error.Abort(_('cannot partially commit a merge ' |
1589 sr = sub.commit(cctx._text, user, date) | 1590 sr = sub.commit(cctx._text, user, date) |
1590 newstate[s] = (newstate[s][0], sr) | 1591 newstate[s] = (newstate[s][0], sr) |
1591 subrepo.writestate(self, newstate) | 1592 subrepo.writestate(self, newstate) |
1592 | 1593 |
1593 p1, p2 = self.dirstate.parents() | 1594 p1, p2 = self.dirstate.parents() |
1595 lock = self.lock() | |
1594 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') | 1596 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
1595 try: | 1597 try: |
1596 self.hook("precommit", throw=True, parent1=hookp1, | 1598 self.hook("precommit", throw=True, parent1=hookp1, |
1597 parent2=hookp2) | 1599 parent2=hookp2) |
1600 tr = self.transaction('commit') | |
1598 ret = self.commitctx(cctx, True) | 1601 ret = self.commitctx(cctx, True) |
1599 except: # re-raises | 1602 except: # re-raises |
1600 if edited: | 1603 if edited: |
1601 self.ui.write( | 1604 self.ui.write( |
1602 _('note: commit message saved in %s\n') % msgfn) | 1605 _('note: commit message saved in %s\n') % msgfn) |
1603 raise | 1606 raise |
1604 | |
1605 # update bookmarks, dirstate and mergestate | 1607 # update bookmarks, dirstate and mergestate |
1606 bookmarks.update(self, [p1, p2], ret) | 1608 bookmarks.update(self, [p1, p2], ret) |
1607 cctx.markcommitted(ret) | 1609 cctx.markcommitted(ret) |
1608 ms.reset() | 1610 ms.reset() |
1611 tr.close() | |
1612 | |
1609 finally: | 1613 finally: |
1610 wlock.release() | 1614 lockmod.release(tr, lock, wlock) |
1611 | 1615 |
1612 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): | 1616 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): |
1613 # hack for command that use a temporary commit (eg: histedit) | 1617 # hack for command that use a temporary commit (eg: histedit) |
1614 # temporary commit got stripped before hook release | 1618 # temporary commit got stripped before hook release |
1615 if self.changelog.hasnode(ret): | 1619 if self.changelog.hasnode(ret): |