[Updated] D11825: patch: add hint about mangled whitespace on bad patch

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Nov 30 15:15:17 UTC 2021


Closed by commit rHG220506bb213e: patch: add hint about mangled whitespace on bad patch (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11825?vs=31197&id=31212

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11825/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11825

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-import-git.t
  tests/test-import.t

CHANGE DETAILS

diff --git a/tests/test-import.t b/tests/test-import.t
--- a/tests/test-import.t
+++ b/tests/test-import.t
@@ -234,6 +234,7 @@
   $ hg --cwd b import -mpatch ../broken.patch
   applying ../broken.patch
   abort: bad hunk #1
+  (check that whitespace in the patch has not been mangled)
   [10]
   $ rm -r b
 
@@ -2076,6 +2077,7 @@
   > EOF
   applying patch from stdin
   abort: bad hunk #1: incomplete hunk
+  (check that whitespace in the patch has not been mangled)
   [10]
 
   $ hg import - <<'EOF'
@@ -2087,4 +2089,5 @@
   > EOF
   applying patch from stdin
   abort: bad hunk #1: incomplete hunk
+  (check that whitespace in the patch has not been mangled)
   [10]
diff --git a/tests/test-import-git.t b/tests/test-import-git.t
--- a/tests/test-import-git.t
+++ b/tests/test-import-git.t
@@ -519,6 +519,7 @@
   > EOF
   applying patch from stdin
   abort: could not decode "binary2" binary patch: bad base85 character at position 6
+  (check that whitespace in the patch has not been mangled)
   [10]
 
   $ hg revert -aq
@@ -534,6 +535,7 @@
   > EOF
   applying patch from stdin
   abort: "binary2" length is 5 bytes, should be 6
+  (check that whitespace in the patch has not been mangled)
   [10]
 
   $ hg revert -aq
@@ -548,6 +550,7 @@
   > EOF
   applying patch from stdin
   abort: could not extract "binary2" binary data
+  (check that whitespace in the patch has not been mangled)
   [10]
 
 Simulate a copy/paste turning LF into CRLF (issue2870)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2025,7 +2025,12 @@
                 similarity=sim / 100.0,
             )
         except error.PatchParseError as e:
-            raise error.InputError(pycompat.bytestr(e))
+            raise error.InputError(
+                pycompat.bytestr(e),
+                hint=_(
+                    b'check that whitespace in the patch has not been mangled'
+                ),
+            )
         except error.PatchApplicationError as e:
             if not partial:
                 raise error.StateError(pycompat.bytestr(e))
@@ -2086,7 +2091,12 @@
                     eolmode=None,
                 )
             except error.PatchParseError as e:
-                raise error.InputError(stringutil.forcebytestr(e))
+                raise error.InputError(
+                    stringutil.forcebytestr(e),
+                    hint=_(
+                        b'check that whitespace in the patch has not been mangled'
+                    ),
+                )
             except error.PatchApplicationError as e:
                 raise error.StateError(stringutil.forcebytestr(e))
             if opts.get(b'exact'):



To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211130/e8b1ef47/attachment-0002.html>


More information about the Mercurial-patches mailing list