Mercurial > evolve
comparison hgext/evolve.py @ 515:0b60c28d9c43 stable
fold: simplify locking
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 25 Aug 2012 09:18:40 +0200 |
parents | ea667749ccd1 |
children | 18854dbc92e7 |
comparison
equal
deleted
inserted
replaced
514:ea667749ccd1 | 515:0b60c28d9c43 |
---|---|
2038 raise util.Abort("can't touch public revision") | 2038 raise util.Abort("can't touch public revision") |
2039 heads = repo.revs('heads(%ld)', revs) | 2039 heads = repo.revs('heads(%ld)', revs) |
2040 if len(heads) > 1: | 2040 if len(heads) > 1: |
2041 raise util.Abort("set have multiple heads") | 2041 raise util.Abort("set have multiple heads") |
2042 head = repo[heads[0]] | 2042 head = repo[heads[0]] |
2043 wlock = repo.wlock() | 2043 wlock = lock = None |
2044 try: | 2044 try: |
2045 wlock = repo.wlock() | |
2045 lock = repo.lock() | 2046 lock = repo.lock() |
2047 tr = repo.transaction('touch') | |
2046 try: | 2048 try: |
2047 tr = repo.transaction('touch') | 2049 allctx = [repo[r] for r in revs] |
2048 try: | 2050 targetphase = max(c.phase() for c in allctx) |
2049 allctx = [repo[r] for r in revs] | 2051 msg = '\n\n***\n\n'.join(c.description() for c in allctx) |
2050 targetphase = max(c.phase() for c in allctx) | 2052 newid, _ = rewrite(repo, root, allctx, head, |
2051 msg = '\n\n***\n\n'.join(c.description() for c in allctx) | 2053 [root.p1().node(), root.p2().node()], |
2052 newid, _ = rewrite(repo, root, allctx, head, | 2054 commitopts={'message': msg}) |
2053 [root.p1().node(), root.p2().node()], | 2055 phases.retractboundary(repo, targetphase, [newid]) |
2054 commitopts={'message': msg}) | 2056 createmarkers(repo, [(ctx, (repo[newid],)) |
2055 phases.retractboundary(repo, targetphase, [newid]) | 2057 for ctx in allctx]) |
2056 createmarkers(repo, [(ctx, (repo[newid],)) | 2058 tr.close() |
2057 for ctx in allctx]) | |
2058 tr.close() | |
2059 finally: | |
2060 tr.release() | |
2061 finally: | 2059 finally: |
2062 lock.release() | 2060 tr.release() |
2063 ui.status('%i changesets folded\n' % len(revs)) | 2061 ui.status('%i changesets folded\n' % len(revs)) |
2064 if repo.revs('. and %ld', revs): | 2062 if repo.revs('. and %ld', revs): |
2065 repo.dirstate.setparents(newid, node.nullid) | 2063 repo.dirstate.setparents(newid, node.nullid) |
2066 finally: | 2064 finally: |
2067 wlock.release() | 2065 lockmod.release(lock, wlock) |
2068 | 2066 |
2069 | 2067 |
2070 @eh.wrapcommand('graft') | 2068 @eh.wrapcommand('graft') |
2071 def graftwrapper(orig, ui, repo, *revs, **kwargs): | 2069 def graftwrapper(orig, ui, repo, *revs, **kwargs): |
2072 kwargs = dict(kwargs) | 2070 kwargs = dict(kwargs) |