rebase: check for unfinished ops even when inmemory (issue6214)
authorKyle Lippincott <spectral@google.com>
Wed, 06 Nov 2019 18:28:11 -0800
changeset 43591 b56c6647f65e
parent 43590 95d0532ad171
child 43592 61d7bca16dff
rebase: check for unfinished ops even when inmemory (issue6214) When using rebase.experimental.inmemory, we should be able to work well with a dirty working directory, but we can not reliably work if we're in the middle of another operation (such as another rebase), as we'll potentially stomp on some state that the other operation needs. Differential Revision: https://phab.mercurial-scm.org/D7298
hgext/rebase.py
tests/test-rebase-inmemory.t
--- a/hgext/rebase.py	Fri Oct 18 23:18:47 2019 -0700
+++ b/hgext/rebase.py	Wed Nov 06 18:28:11 2019 -0800
@@ -1274,8 +1274,8 @@
     if revf and srcf:
         raise error.Abort(_(b'cannot specify both a revision and a source'))
 
+    cmdutil.checkunfinished(repo)
     if not inmemory:
-        cmdutil.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
     if ui.configbool(b'commands', b'rebase.requiredest') and not destf:
--- a/tests/test-rebase-inmemory.t	Fri Oct 18 23:18:47 2019 -0700
+++ b/tests/test-rebase-inmemory.t	Wed Nov 06 18:28:11 2019 -0800
@@ -249,6 +249,10 @@
   rebasing 8:e147e6e3c490 "c/subdir/file.txt" (tip)
   abort: error: 'c/subdir/file.txt' conflicts with file 'c' in 3.
   [255]
+FIXME: shouldn't need this, but when we hit path conflicts in dryrun mode, we
+don't clean up rebasestate.
+  $ hg rebase --abort
+  rebase aborted
   $ hg rebase -r 3 -d . -n
   starting dry-run rebase; repository will not be changed
   rebasing 3:844a7de3e617 "c"
@@ -504,9 +508,8 @@
   $ hg resolve -l
   U e
   $ hg rebase -s 2 -d 7
-  rebasing 2:177f92b77385 "c"
-  abort: outstanding merge conflicts
-  (use 'hg resolve' to resolve)
+  abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg resolve -l
   U e
@@ -862,3 +865,58 @@
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
+
+  $ cd $TESTTMP
+
+Test rebasing when we're in the middle of a rebase already
+  $ hg init test_issue6214
+  $ cd test_issue6214
+  $ echo r0 > r0
+  $ hg ci -qAm 'r0'
+  $ echo hi > foo
+  $ hg ci -qAm 'hi from foo'
+  $ hg co -q '.^'
+  $ echo bye > foo
+  $ hg ci -qAm 'bye from foo'
+  $ hg co -q '.^'
+  $ echo unrelated > some_other_file
+  $ hg ci -qAm 'some unrelated changes'
+  $ hg log -G -T'{rev}: {desc}\n{files%"{file}\n"}'
+  @  3: some unrelated changes
+  |  some_other_file
+  | o  2: bye from foo
+  |/   foo
+  | o  1: hi from foo
+  |/   foo
+  o  0: r0
+     r0
+  $ hg rebase -r 2 -d 1 -t:merge3
+  rebasing 2:b4d249fbf8dd "bye from foo"
+  merging foo
+  hit merge conflicts; re-running rebase without in-memory merge
+  rebasing 2:b4d249fbf8dd "bye from foo"
+  merging foo
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase -r 3 -d 1 -t:merge3
+  abort: rebase in progress
+  (use 'hg rebase --continue' or 'hg rebase --abort')
+  [255]
+  $ hg resolve --list
+  U foo
+  $ hg resolve --all --re-merge -t:other
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase --continue
+  rebasing 2:b4d249fbf8dd "bye from foo"
+  saved backup bundle to $TESTTMP/test_issue6214/.hg/strip-backup/b4d249fbf8dd-299ec25c-rebase.hg
+  $ hg log -G -T'{rev}: {desc}\n{files%"{file}\n"}'
+  o  3: bye from foo
+  |  foo
+  | @  2: some unrelated changes
+  | |  some_other_file
+  o |  1: hi from foo
+  |/   foo
+  o  0: r0
+     r0