comparison hgext/evolve.py @ 1141:ca17770d2ee9

evolve: preserve branch change evolve will now preserve branch change. If the evolved changeset had a different phases than its parent, this branch name will be preserved. This allow propagation of branch change during amend but do not overwrite special branch name on children,
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 01 Nov 2014 13:48:34 +0000
parents b7d85cd8ec7b
children 160fd06312fc
comparison
equal deleted inserted replaced
1140:b7d85cd8ec7b 1141:ca17770d2ee9
756 return newid, created 756 return newid, created
757 757
758 class MergeFailure(util.Abort): 758 class MergeFailure(util.Abort):
759 pass 759 pass
760 760
761 def relocate(repo, orig, dest): 761 def relocate(repo, orig, dest, keepbranch=False):
762 """rewrite <rev> on dest""" 762 """rewrite <rev> on dest"""
763 if orig.rev() == dest.rev(): 763 if orig.rev() == dest.rev():
764 raise util.Abort(_('tried to relocate a node on top of itself'), 764 raise util.Abort(_('tried to relocate a node on top of itself'),
765 hint=_("This shouldn't happen. If you still " 765 hint=_("This shouldn't happen. If you still "
766 "need to move changesets, please do so " 766 "need to move changesets, please do so "
809 {node.nullrev: node.nullrev}, False, 809 {node.nullrev: node.nullrev}, False,
810 orig.p1().node()) 810 orig.p1().node())
811 if r[-1]: #some conflict 811 if r[-1]: #some conflict
812 raise util.Abort( 812 raise util.Abort(
813 'unresolved merge conflicts (see hg help resolve)') 813 'unresolved merge conflicts (see hg help resolve)')
814 if keepbranch:
815 def _extrafn(ctx, extra):
816 extra['branch'] = ctx.branch()
817 else:
818 _extrafn = (lambda ctx, extra: None)
819
814 nodenew = rebase.concludenode(repo, orig.node(), dest.node(), 820 nodenew = rebase.concludenode(repo, orig.node(), dest.node(),
815 node.nullid, commitmsg) 821 node.nullid, commitmsg,
822 extrafn=_extrafn)
816 except util.Abort, exc: 823 except util.Abort, exc:
817 repo.dirstate.beginparentchange() 824 repo.dirstate.beginparentchange()
818 repo.setparents(repo['.'].node(), nullid) 825 repo.setparents(repo['.'].node(), nullid)
819 repo.dirstate.write() 826 repo.dirstate.write()
820 # fix up dirstate for copies and renames 827 # fix up dirstate for copies and renames
1339 if dryrun: 1346 if dryrun:
1340 repo.ui.write(todo) 1347 repo.ui.write(todo)
1341 else: 1348 else:
1342 repo.ui.note(todo) 1349 repo.ui.note(todo)
1343 if progresscb: progresscb() 1350 if progresscb: progresscb()
1351 keepbranch = orig.p1().branch() != orig.branch()
1344 try: 1352 try:
1345 relocate(repo, orig, target) 1353 relocate(repo, orig, target, keepbranch)
1346 except MergeFailure: 1354 except MergeFailure:
1347 repo.opener.write('graftstate', orig.hex() + '\n') 1355 repo.opener.write('graftstate', orig.hex() + '\n')
1348 repo.ui.write_err(_('evolve failed!\n')) 1356 repo.ui.write_err(_('evolve failed!\n'))
1349 repo.ui.write_err( 1357 repo.ui.write_err(
1350 _('fix conflict and run "hg evolve --continue"\n')) 1358 _('fix conflict and run "hg evolve --continue"\n'))