merge-halt: fix issue with merge.on-failure=halt breaking unshelve stable
authorKyle Lippincott <spectral@google.com>
Tue, 19 Oct 2021 16:14:53 -0700
branchstable
changeset 48271 5228a6dc212b
parent 48270 3e66e4517744
child 48272 f6b045910d82
merge-halt: fix issue with merge.on-failure=halt breaking unshelve Differential Revision: https://phab.mercurial-scm.org/D11706
mercurial/merge.py
tests/test-merge-halt.t
--- a/mercurial/merge.py	Tue Oct 19 16:14:46 2021 -0700
+++ b/mercurial/merge.py	Tue Oct 19 16:14:53 2021 -0700
@@ -1713,6 +1713,10 @@
             progress.increment(item=f, total=numupdates)
             ms.resolve(f, wctx)
 
+    except error.InterventionRequired:
+        # If the user has merge.on-failure=halt, catch the error and close the
+        # merge state "properly".
+        pass
     finally:
         ms.commit()
 
--- a/tests/test-merge-halt.t	Tue Oct 19 16:14:46 2021 -0700
+++ b/tests/test-merge-halt.t	Tue Oct 19 16:14:53 2021 -0700
@@ -44,7 +44,7 @@
   merging a
   merging b
   merging a failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -72,7 +72,7 @@
   continue merge operation (yn)? y
   merging b failed!
   continue merge operation (yn)? n
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -101,7 +101,7 @@
   was merge successful (yn)? n
   merging b failed!
   continue merge operation (yn)? n
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -124,7 +124,7 @@
   merging a
   merging b
   merging a failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -145,7 +145,7 @@
   was merge of 'a' successful (yn)? y
   was merge of 'b' successful (yn)? n
   merging b failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
   [240]
 
   $ hg resolve --list
@@ -167,6 +167,9 @@
   $ cat <<EOS >> $HGRCPATH
   > [extensions]
   > shelve =
+  > [merge-tools]
+  > false.check=conflicts
+  > false.premerge=false
   > EOS
   $ echo foo > shelve_file1
   $ echo foo > shelve_file2
@@ -186,15 +189,14 @@
   merging shelve_file1
   merging shelve_file2
   merging shelve_file1 failed!
-  merge halted after failed merge (see hg resolve)
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [240]
-FIXME: This should claim it's in an 'unshelve' state
   $ hg status --config commands.status.verbose=True
   M shelve_file1
   M shelve_file2
   ? shelve_file1.orig
   ? shelve_file2.orig
-  # The repository is in an unfinished *update* state.
+  # The repository is in an unfinished *unshelve* state.
   
   # Unresolved merge conflicts:
   # 
@@ -203,16 +205,16 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:    hg update .
+  # To continue:    hg unshelve --continue
+  # To abort:       hg unshelve --abort
   
-FIXME: This should not be referencing a stripped commit.
   $ hg resolve --tool false --all --re-merge
-  abort: unknown revision '4a1d727ea5bb6aed9adfacb2a8f776bae44301d6'
-  [255]
-Ensure the shelve is still around, since we haven't finished the operation yet.
+  merging shelve_file1
+  merging shelve_file2
+  merging shelve_file1 failed!
+  merge halted after failed merge (see hg resolve)
+  [240]
   $ hg shelve --list
   default         (* ago)    changes to: foo (glob)
-FIXME: `hg unshelve --abort` should work.
   $ hg unshelve --abort
-  abort: no unshelve in progress
-  [20]
+  unshelve of 'default' aborted