# HG changeset patch # User Matt Mackall # Date 1375397652 18000 # Node ID 12843143663d412fe8ffc2b7cc4958310319e1dd # Parent eab2ff59481e419e515c20b544b0d1ed1ee3485c rebase: allow aborting when descendants detected With this, all aborts will succeed in removing the state, rather than leaving the user in 'what do I do now?' limbo. diff -r eab2ff59481e -r 12843143663d hgext/rebase.py --- a/hgext/rebase.py Thu Aug 01 17:45:13 2013 -0500 +++ b/hgext/rebase.py Thu Aug 01 17:54:12 2013 -0500 @@ -608,32 +608,36 @@ 'Restore the repository to its original state' dstates = [s for s in state.values() if s != nullrev] immutable = [d for d in dstates if not repo[d].mutable()] + cleanup = True if immutable: repo.ui.warn(_("warning: can't clean up immutable changesets %s\n") % ', '.join(str(repo[r]) for r in immutable), hint=_('see hg help phases for details')) + cleanup = False descendants = set() if dstates: descendants = set(repo.changelog.descendants(dstates)) if descendants - set(dstates): repo.ui.warn(_("warning: new changesets detected on target branch, " - "can't abort\n")) - return -1 - else: + "can't strip\n")) + cleanup = False + + if cleanup: # Update away from the rebase if necessary - if not immutable and inrebase(repo, originalwd, state): + if inrebase(repo, originalwd, state): merge.update(repo, repo[originalwd].rev(), False, True, False) # Strip from the first rebased revision rebased = filter(lambda x: x > -1 and x != target, state.values()) - if rebased and not immutable: + if rebased: strippoints = [c.node() for c in repo.set('roots(%ld)', rebased)] # no backup of rebased cset versions needed repair.strip(repo.ui, repo, strippoints) - clearstatus(repo) - repo.ui.warn(_('rebase aborted\n')) - return 0 + + clearstatus(repo) + repo.ui.warn(_('rebase aborted\n')) + return 0 def buildstate(repo, dest, rebaseset, collapse): '''Define which revisions are going to be rebased and where diff -r eab2ff59481e -r 12843143663d tests/test-rebase-interruptions.t --- a/tests/test-rebase-interruptions.t Thu Aug 01 17:45:13 2013 -0500 +++ b/tests/test-rebase-interruptions.t Thu Aug 01 17:54:12 2013 -0500 @@ -180,8 +180,8 @@ Abort the rebasing: $ hg rebase --abort - warning: new changesets detected on target branch, can't abort - [255] + warning: new changesets detected on target branch, can't strip + rebase aborted $ hg tglog @ 6: 'Extra'