comparison hgext/rebase.py @ 19517:eab2ff59481e stable

rebase: continue abort without strip for immutable csets (issue3997) This causes us to simply discard the rebase state.
author Matt Mackall <mpm@selenic.com>
date Thu, 01 Aug 2013 17:45:13 -0500
parents fe78eb7bcca0
children 12843143663d
comparison
equal deleted inserted replaced
19516:fe78eb7bcca0 19517:eab2ff59481e
607 def abort(repo, originalwd, target, state): 607 def abort(repo, originalwd, target, state):
608 'Restore the repository to its original state' 608 'Restore the repository to its original state'
609 dstates = [s for s in state.values() if s != nullrev] 609 dstates = [s for s in state.values() if s != nullrev]
610 immutable = [d for d in dstates if not repo[d].mutable()] 610 immutable = [d for d in dstates if not repo[d].mutable()]
611 if immutable: 611 if immutable:
612 raise util.Abort(_("can't abort rebase due to immutable changesets %s") 612 repo.ui.warn(_("warning: can't clean up immutable changesets %s\n")
613 % ', '.join(str(repo[r]) for r in immutable), 613 % ', '.join(str(repo[r]) for r in immutable),
614 hint=_('see hg help phases for details')) 614 hint=_('see hg help phases for details'))
615 615
616 descendants = set() 616 descendants = set()
617 if dstates: 617 if dstates:
618 descendants = set(repo.changelog.descendants(dstates)) 618 descendants = set(repo.changelog.descendants(dstates))
619 if descendants - set(dstates): 619 if descendants - set(dstates):
620 repo.ui.warn(_("warning: new changesets detected on target branch, " 620 repo.ui.warn(_("warning: new changesets detected on target branch, "
621 "can't abort\n")) 621 "can't abort\n"))
622 return -1 622 return -1
623 else: 623 else:
624 # Update away from the rebase if necessary 624 # Update away from the rebase if necessary
625 if inrebase(repo, originalwd, state): 625 if not immutable and inrebase(repo, originalwd, state):
626 merge.update(repo, repo[originalwd].rev(), False, True, False) 626 merge.update(repo, repo[originalwd].rev(), False, True, False)
627 627
628 # Strip from the first rebased revision 628 # Strip from the first rebased revision
629 rebased = filter(lambda x: x > -1 and x != target, state.values()) 629 rebased = filter(lambda x: x > -1 and x != target, state.values())
630 if rebased: 630 if rebased and not immutable:
631 strippoints = [c.node() for c in repo.set('roots(%ld)', rebased)] 631 strippoints = [c.node() for c in repo.set('roots(%ld)', rebased)]
632 # no backup of rebased cset versions needed 632 # no backup of rebased cset versions needed
633 repair.strip(repo.ui, repo, strippoints) 633 repair.strip(repo.ui, repo, strippoints)
634 clearstatus(repo) 634 clearstatus(repo)
635 repo.ui.warn(_('rebase aborted\n')) 635 repo.ui.warn(_('rebase aborted\n'))