Mercurial > hg
changeset 27988:61f4d59e9a0b stable
rebase: update working directory when aborting (issue5084)
author | timeless <timeless@mozdev.org> |
---|---|
date | Fri, 05 Feb 2016 01:56:46 +0000 |
parents | b19d8d5d6b51 |
children | a036e1ae1fbe 72f2a19c5f88 |
files | hgext/rebase.py tests/failfilemerge.py tests/test-rebase-abort.t |
diffstat | 3 files changed, 99 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Tue Feb 02 23:49:49 2016 +0900 +++ b/hgext/rebase.py Fri Feb 05 01:56:46 2016 +0000 @@ -975,15 +975,20 @@ cleanup = False if cleanup: + shouldupdate = False + rebased = filter(lambda x: x >= 0 and x != target, state.values()) + if rebased: + strippoints = [ + c.node() for c in repo.set('roots(%ld)', rebased)] + shouldupdate = len([ + c.node() for c in repo.set('. & (%ld)', rebased)]) > 0 + # Update away from the rebase if necessary - if needupdate(repo, state): + if shouldupdate or needupdate(repo, state): merge.update(repo, originalwd, False, True) # Strip from the first rebased revision - rebased = filter(lambda x: x >= 0 and x != target, state.values()) 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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failfilemerge.py Fri Feb 05 01:56:46 2016 +0000 @@ -0,0 +1,18 @@ +# extension to emulate interupting filemerge._filemerge + +from __future__ import absolute_import + +from mercurial import ( + filemerge, + extensions, + error, +) + +def failfilemerge(filemergefn, + premerge, repo, mynode, orig, fcd, fco, fca, labels=None): + raise error.Abort("^C") + return filemergefn(premerge, repo, mynode, orig, fcd, fco, fca, labels) + +def extsetup(ui): + extensions.wrapfunction(filemerge, '_filemerge', + failfilemerge)
--- a/tests/test-rebase-abort.t Tue Feb 02 23:49:49 2016 +0900 +++ b/tests/test-rebase-abort.t Fri Feb 05 01:56:46 2016 +0000 @@ -323,6 +323,78 @@ $ cd .. +test aborting an interrupted series (issue5084) + $ hg init interrupted + $ cd interrupted + $ touch base + $ hg add base + $ hg commit -m base + $ touch a + $ hg add a + $ hg commit -m a + $ echo 1 > a + $ hg commit -m 1 + $ touch b + $ hg add b + $ hg commit -m b + $ echo 2 >> a + $ hg commit -m c + $ touch d + $ hg add d + $ hg commit -m d + $ hg co -q 1 + $ hg rm a + $ hg commit -m no-a + created new head + $ hg co 0 + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg log -G --template "{rev} {desc} {bookmarks}" + o 6 no-a + | + | o 5 d + | | + | o 4 c + | | + | o 3 b + | | + | o 2 1 + |/ + o 1 a + | + @ 0 base + + $ hg --config extensions.n=$TESTDIR/failfilemerge.py rebase -s 3 -d tip + rebasing 3:3a71550954f1 "b" + rebasing 4:e80b69427d80 "c" + abort: ^C + [255] + $ hg rebase --abort + saved backup bundle to $TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg (glob) + rebase aborted + $ hg log -G --template "{rev} {desc} {bookmarks}" + o 6 no-a + | + | o 5 d + | | + | o 4 c + | | + | o 3 b + | | + | o 2 1 + |/ + o 1 a + | + @ 0 base + + $ hg summary + parent: 0:df4f53cec30a + base + branch: default + commit: (clean) + update: 6 new changesets (update) + phases: 7 draft + + $ cd .. On the other hand, make sure we *do* clobber changes whenever we haven't somehow managed to update the repo to a different revision during a rebase (issue4661)