comparison hgext/evolve.py @ 702:b5a85a8909d3 stable

touch: properly handle touching multiple changeset
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 08 Feb 2013 22:44:43 +0000
parents f752089479ce
children 79a1d2816bdb
comparison
equal deleted inserted replaced
701:f752089479ce 702:b5a85a8909d3
1592 wlock = lock = None 1592 wlock = lock = None
1593 try: 1593 try:
1594 wlock = repo.wlock() 1594 wlock = repo.wlock()
1595 lock = repo.lock() 1595 lock = repo.lock()
1596 tr = repo.transaction('touch') 1596 tr = repo.transaction('touch')
1597 revs.sort() # ensure parent are run first
1598 newmapping = {}
1597 try: 1599 try:
1598 for r in revs: 1600 for r in revs:
1599 ctx = repo[r] 1601 ctx = repo[r]
1600 extra = ctx.extra().copy() 1602 extra = ctx.extra().copy()
1601 extra['__touch-noise__'] = random.randint(0, 0xffffffff) 1603 extra['__touch-noise__'] = random.randint(0, 0xffffffff)
1604 # search for touched parent
1605 p1 = ctx.p1().node()
1606 p2 = ctx.p2().node()
1607 p1 = newmapping.get(p1, p1)
1608 p2 = newmapping.get(p2, p2)
1602 new, _ = rewrite(repo, ctx, [], ctx, 1609 new, _ = rewrite(repo, ctx, [], ctx,
1603 [ctx.p1().node(), ctx.p2().node()], 1610 [p1, p2],
1604 commitopts={'extra': extra}) 1611 commitopts={'extra': extra})
1612 # store touched version to help potential children
1613 newmapping[ctx.node()] = new
1605 if not duplicate: 1614 if not duplicate:
1606 createmarkers(repo, [(ctx, (repo[new],))]) 1615 createmarkers(repo, [(ctx, (repo[new],))])
1607 phases.retractboundary(repo, ctx.phase(), [new]) 1616 phases.retractboundary(repo, ctx.phase(), [new])
1608 if ctx in repo[None].parents(): 1617 if ctx in repo[None].parents():
1609 repo.dirstate.setparents(new, node.nullid) 1618 repo.dirstate.setparents(new, node.nullid)
1612 tr.release() 1621 tr.release()
1613 finally: 1622 finally:
1614 lockmod.release(lock, wlock) 1623 lockmod.release(lock, wlock)
1615 1624
1616 @command('^fold', 1625 @command('^fold',
1617 [('r', 'rev', [], _("revisions to fold")), 1626 [('r', 'rev', [], _("explicitly specify the full set of revision to fold")),
1618 ], 1627 ],
1619 # allow to choose the seed ? 1628 # allow to choose the seed ?
1620 _('[-r] revs')) 1629 _('rev'))
1621 def fold(ui, repo, *revs, **opts): 1630 def fold(ui, repo, *revs, **opts):
1622 """Fold multiple revisions into a single one""" 1631 """Fold multiple revisions into a single one
1632
1633 Revision from your current working directory to the specified one are fold
1634 as a new one replacing the other
1635
1636 you can alternatively use --rev to explicitly specify revision to be fold
1637 ignoring the current working directory parent.
1638 """
1623 revs = list(revs) 1639 revs = list(revs)
1624 revs.extend(opts['rev'])
1625 if revs: 1640 if revs:
1626 revs = scmutil.revrange(repo, revs) 1641 if opts.get('rev', ()):
1642 raise util.Abort("cannot specify both --rev and a target revision")
1643 targets = scmutil.revrange(repo, revs)
1644 revs = repo.revs('(%ld::.) or (.::%ld)', targets, targets)
1645 elif 'rev' in opts:
1646 revs = scmutil.revrange(repo, opts['rev'])
1647 else:
1648 revs = ()
1627 if not revs: 1649 if not revs:
1628 ui.write_err('no revision to fold\n') 1650 ui.write_err('no revision to fold\n')
1629 return 1 1651 return 1
1630 roots = repo.revs('roots(%ld)', revs) 1652 roots = repo.revs('roots(%ld)', revs)
1631 if len(roots) > 1: 1653 if len(roots) > 1: