errors: use StateError more in merge module
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 29 Jan 2021 15:56:08 -0800
changeset 46418 dc00324e80f4
parent 46417 768056549737
child 46419 6894c9ef4dcd
errors: use StateError more in merge module Differential Revision: https://phab.mercurial-scm.org/D9912
mercurial/merge.py
tests/test-audit-subrepo.t
tests/test-largefiles.t
tests/test-merge-remove.t
tests/test-merge1.t
tests/test-pathconflicts-basic.t
tests/test-pathconflicts-update.t
tests/test-remotefilelog-prefetch.t
tests/test-rename-dir-merge.t
tests/test-resolve.t
tests/test-up-local-change.t
tests/test-update-branches.t
--- a/mercurial/merge.py	Fri Jan 29 12:16:55 2021 -0800
+++ b/mercurial/merge.py	Fri Jan 29 15:56:08 2021 -0800
@@ -233,7 +233,7 @@
         else:
             warn(_(b"%s: untracked file differs\n") % f)
     if abortconflicts:
-        raise error.Abort(
+        raise error.StateError(
             _(
                 b"untracked files in working directory "
                 b"differ from files in requested revision"
@@ -341,7 +341,7 @@
     for f in pmmf:
         fold = util.normcase(f)
         if fold in foldmap:
-            raise error.Abort(
+            raise error.StateError(
                 _(b"case-folding collision between %s and %s")
                 % (f, foldmap[fold])
             )
@@ -352,7 +352,7 @@
     for fold, f in sorted(foldmap.items()):
         if fold.startswith(foldprefix) and not f.startswith(unfoldprefix):
             # the folded prefix matches but actual casing is different
-            raise error.Abort(
+            raise error.StateError(
                 _(b"case-folding collision between %s and directory of %s")
                 % (lastfull, f)
             )
@@ -504,7 +504,9 @@
     if invalidconflicts:
         for p in invalidconflicts:
             repo.ui.warn(_(b"%s: is both a file and a directory\n") % p)
-        raise error.Abort(_(b"destination manifest contains path conflicts"))
+        raise error.StateError(
+            _(b"destination manifest contains path conflicts")
+        )
 
 
 def _filternarrowactions(narrowmatch, branchmerge, mresult):
@@ -1918,10 +1920,10 @@
         ### check phase
         if not overwrite:
             if len(pl) > 1:
-                raise error.Abort(_(b"outstanding uncommitted merge"))
+                raise error.StateError(_(b"outstanding uncommitted merge"))
             ms = wc.mergestate()
             if ms.unresolvedcount():
-                raise error.Abort(
+                raise error.StateError(
                     _(b"outstanding merge conflicts"),
                     hint=_(b"use 'hg resolve' to resolve"),
                 )
@@ -2007,7 +2009,7 @@
             if mresult.hasconflicts():
                 msg = _(b"conflicting changes")
                 hint = _(b"commit or update --clean to discard changes")
-                raise error.Abort(msg, hint=hint)
+                raise error.StateError(msg, hint=hint)
 
         # Prompt and create actions. Most of this is in the resolve phase
         # already, but we can't handle .hgsubstate in filemerge or
--- a/tests/test-audit-subrepo.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-audit-subrepo.t	Fri Jan 29 15:56:08 2021 -0800
@@ -323,7 +323,7 @@
   new changesets 7a2f0e59146f
   .hgsubstate: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ cat main5/.hg/hgrc | grep pwned
   [1]
 
@@ -623,7 +623,7 @@
   new changesets * (glob)
   .hgsubstate: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ ls "$FAKEHOME"
   a
   $ test -d "$FAKEHOME/.hg"
@@ -652,7 +652,7 @@
   new changesets * (glob)
   .hgsubstate: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ ls -A "$FAKEHOME"
   .hg
   a
--- a/tests/test-largefiles.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-largefiles.t	Fri Jan 29 15:56:08 2021 -0800
@@ -1751,7 +1751,7 @@
   $ hg rm sub2/large6
   $ hg up -r.
   abort: outstanding uncommitted merge
-  [255]
+  [20]
 
 - revert should be able to revert files introduced in a pending merge
   $ hg revert --all -r .
--- a/tests/test-merge-remove.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-merge-remove.t	Fri Jan 29 15:56:08 2021 -0800
@@ -95,7 +95,7 @@
   $ hg merge
   bar: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ cat bar
   memories of buried pirate treasure
 
--- a/tests/test-merge1.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-merge1.t	Fri Jan 29 15:56:08 2021 -0800
@@ -113,7 +113,7 @@
   $ hg merge 1
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
 
 #if symlink
 symlinks to directories should be treated as regular files (issue5027)
@@ -122,7 +122,7 @@
   $ hg merge 1
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
 symlinks shouldn't be followed
   $ rm b
   $ echo This is file b1 > .hg/b
@@ -130,7 +130,7 @@
   $ hg merge 1
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
 
   $ rm b
   $ echo This is file b2 > b
@@ -144,7 +144,7 @@
   $ hg merge 1 --config merge.checkunknown=abort
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
 
 this merge should warn
   $ hg merge 1 --config merge.checkunknown=warn
@@ -188,7 +188,7 @@
   $ hg merge 3 --config merge.checkignored=ignore --config merge.checkunknown=abort
   remoteignored: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=ignore
   merging .hgignore
   merging for .hgignore
@@ -210,15 +210,15 @@
   b: untracked file differs
   localignored: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=ignore
   localignored: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg merge 3 --config merge.checkignored=warn --config merge.checkunknown=abort
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg merge 3 --config merge.checkignored=warn --config merge.checkunknown=warn
   b: replacing untracked file
   localignored: replacing untracked file
--- a/tests/test-pathconflicts-basic.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-pathconflicts-basic.t	Fri Jan 29 15:56:08 2021 -0800
@@ -53,7 +53,7 @@
   $ hg up file
   a: untracked directory conflicts with file
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg up --clean file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark file)
--- a/tests/test-pathconflicts-update.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-pathconflicts-update.t	Fri Jan 29 15:56:08 2021 -0800
@@ -49,7 +49,7 @@
   $ hg up dir
   a/b: untracked file conflicts with directory
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg up dir --config merge.checkunknown=warn
   a/b: replacing untracked file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -70,7 +70,7 @@
   $ hg up dir
   a/b: untracked file conflicts with directory
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg up dir --config merge.checkunknown=warn
   a/b: replacing untracked file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -89,7 +89,7 @@
   $ hg up file
   a/b: untracked directory conflicts with file
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg up file --config merge.checkunknown=warn
   a/b: replacing untracked files in directory
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -107,7 +107,7 @@
   $ hg up link
   a/b: untracked directory conflicts with file
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg up link --config merge.checkunknown=warn
   a/b: replacing untracked files in directory
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-remotefilelog-prefetch.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-remotefilelog-prefetch.t	Fri Jan 29 15:56:08 2021 -0800
@@ -180,7 +180,7 @@
   x: untracked file differs
   3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ hg revert --all
 
 # Test batch fetching of lookup files during hg status
--- a/tests/test-rename-dir-merge.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-rename-dir-merge.t	Fri Jan 29 15:56:08 2021 -0800
@@ -110,7 +110,7 @@
   $ hg merge 2
   b/c: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ cat b/c
   target
 but it should succeed if the content matches
--- a/tests/test-resolve.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-resolve.t	Fri Jan 29 15:56:08 2021 -0800
@@ -153,15 +153,15 @@
   $ hg up 0
   abort: outstanding merge conflicts
   (use 'hg resolve' to resolve)
-  [255]
+  [20]
   $ hg merge 2
   abort: outstanding merge conflicts
   (use 'hg resolve' to resolve)
-  [255]
+  [20]
   $ hg merge --force 2
   abort: outstanding merge conflicts
   (use 'hg resolve' to resolve)
-  [255]
+  [20]
 
 set up conflict-free merge
 
--- a/tests/test-up-local-change.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-up-local-change.t	Fri Jan 29 15:56:08 2021 -0800
@@ -175,7 +175,7 @@
   $ hg up 1
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
   $ rm b
 
 test conflicting untracked ignored file
@@ -195,7 +195,7 @@
   $ hg up 'desc("add ignored file")'
   ignored: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
-  [255]
+  [20]
 
 test a local add
 
--- a/tests/test-update-branches.t	Fri Jan 29 12:16:55 2021 -0800
+++ b/tests/test-update-branches.t	Fri Jan 29 15:56:08 2021 -0800
@@ -324,7 +324,7 @@
   $ hg up -q 4
   abort: conflicting changes
   (commit or update --clean to discard changes)
-  [255]
+  [20]
   $ hg up -m 4
   merging a
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')