# HG changeset patch # User Patrick Mezard # Date 1345879215 -7200 # Node ID ea667749ccd10323b9f21ddba18b38f4b6fe5a0a # Parent 4602104b190d98197b2db60f7fd050778114ab4f touch: simplify locking pattern diff -r 4602104b190d -r ea667749ccd1 hgext/evolve.py --- a/hgext/evolve.py Sat Aug 25 08:51:37 2012 +0200 +++ b/hgext/evolve.py Sat Aug 25 09:20:15 2012 +0200 @@ -39,6 +39,7 @@ from mercurial import extensions from mercurial import hg from mercurial import localrepo +from mercurial import lock as lockmod from mercurial import merge from mercurial import node from mercurial import phases @@ -1992,30 +1993,28 @@ return 1 if repo.revs('public() and %ld', revs): raise util.Abort("can't touch public revision") - wlock = repo.wlock() + wlock = lock = None try: + wlock = repo.wlock() lock = repo.lock() + tr = repo.transaction('touch') try: - tr = repo.transaction('touch') - try: - for r in revs: - ctx = repo[r] - extra = ctx.extra().copy() - extra['__touch-noise__'] = random.randint(0, 0xffffffff) - new, _ = rewrite(repo, ctx, [], ctx, - [ctx.p1().node(), ctx.p2().node()], - commitopts={'extra': extra}) - createmarkers(repo, [(ctx, (repo[new],))]) - phases.retractboundary(repo, ctx.phase(), [new]) - if ctx in repo[None].parents(): - repo.dirstate.setparents(new, node.nullid) - tr.close() - finally: - tr.release() + for r in revs: + ctx = repo[r] + extra = ctx.extra().copy() + extra['__touch-noise__'] = random.randint(0, 0xffffffff) + new, _ = rewrite(repo, ctx, [], ctx, + [ctx.p1().node(), ctx.p2().node()], + commitopts={'extra': extra}) + createmarkers(repo, [(ctx, (repo[new],))]) + phases.retractboundary(repo, ctx.phase(), [new]) + if ctx in repo[None].parents(): + repo.dirstate.setparents(new, node.nullid) + tr.close() finally: - lock.release() + tr.release() finally: - wlock.release() + lockmod.release(lock, wlock) @command('^fold', [('r', 'rev', [], 'revision to fold'),],