Mercurial > evolve
comparison hgext/evolve.py @ 701:f752089479ce stable
add a duplicate option in touch
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Fri, 08 Feb 2013 22:12:46 +0000 |
parents | dba3ed9f2c4f |
children | b5a85a8909d3 |
comparison
equal
deleted
inserted
replaced
700:ebcfd72e7609 | 701:f752089479ce |
---|---|
1566 finally: | 1566 finally: |
1567 if lock is not None: | 1567 if lock is not None: |
1568 lock.release() | 1568 lock.release() |
1569 | 1569 |
1570 @command('^touch', | 1570 @command('^touch', |
1571 [('r', 'rev', [], 'revision to update'),], | 1571 [('r', 'rev', [], 'revision to update'), |
1572 ('D', 'duplicate', False, | |
1573 'do not mark the new revision as successor of the old one')], | |
1572 # allow to choose the seed ? | 1574 # allow to choose the seed ? |
1573 _('[-r] revs')) | 1575 _('[-r] revs')) |
1574 def touch(ui, repo, *revs, **opts): | 1576 def touch(ui, repo, *revs, **opts): |
1575 """Create successors with exact same property but hash | 1577 """Create successors with exact same property but hash |
1576 | 1578 |
1577 This is used to "resurrect" changesets | 1579 This is used to "resurrect" changesets |
1578 """ | 1580 """ |
1581 duplicate = opts['duplicate'] | |
1579 revs = list(revs) | 1582 revs = list(revs) |
1580 revs.extend(opts['rev']) | 1583 revs.extend(opts['rev']) |
1581 if not revs: | 1584 if not revs: |
1582 revs = ['.'] | 1585 revs = ['.'] |
1583 revs = scmutil.revrange(repo, revs) | 1586 revs = scmutil.revrange(repo, revs) |
1584 if not revs: | 1587 if not revs: |
1585 ui.write_err('no revision to touch\n') | 1588 ui.write_err('no revision to touch\n') |
1586 return 1 | 1589 return 1 |
1587 if repo.revs('public() and %ld', revs): | 1590 if not duplicate and repo.revs('public() and %ld', revs): |
1588 raise util.Abort("can't touch public revision") | 1591 raise util.Abort("can't touch public revision") |
1589 wlock = lock = None | 1592 wlock = lock = None |
1590 try: | 1593 try: |
1591 wlock = repo.wlock() | 1594 wlock = repo.wlock() |
1592 lock = repo.lock() | 1595 lock = repo.lock() |
1597 extra = ctx.extra().copy() | 1600 extra = ctx.extra().copy() |
1598 extra['__touch-noise__'] = random.randint(0, 0xffffffff) | 1601 extra['__touch-noise__'] = random.randint(0, 0xffffffff) |
1599 new, _ = rewrite(repo, ctx, [], ctx, | 1602 new, _ = rewrite(repo, ctx, [], ctx, |
1600 [ctx.p1().node(), ctx.p2().node()], | 1603 [ctx.p1().node(), ctx.p2().node()], |
1601 commitopts={'extra': extra}) | 1604 commitopts={'extra': extra}) |
1602 createmarkers(repo, [(ctx, (repo[new],))]) | 1605 if not duplicate: |
1606 createmarkers(repo, [(ctx, (repo[new],))]) | |
1603 phases.retractboundary(repo, ctx.phase(), [new]) | 1607 phases.retractboundary(repo, ctx.phase(), [new]) |
1604 if ctx in repo[None].parents(): | 1608 if ctx in repo[None].parents(): |
1605 repo.dirstate.setparents(new, node.nullid) | 1609 repo.dirstate.setparents(new, node.nullid) |
1606 tr.close() | 1610 tr.close() |
1607 finally: | 1611 finally: |