Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 48364:220506bb213e
patch: add hint about mangled whitespace on bad patch
One of the most common reasons that a patch doesn't apply is because
its whitespace has been mangled (e.g. by their mail client or though
copy&paste). Let's provide a hint about that.
Differential Revision: https://phab.mercurial-scm.org/D11825
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 19 Nov 2021 09:17:30 -0800 |
parents | 6a454e7053a1 |
children | 9f1b9e128788 |
comparison
equal
deleted
inserted
replaced
48363:6a454e7053a1 | 48364:220506bb213e |
---|---|
2023 files=files, | 2023 files=files, |
2024 eolmode=None, | 2024 eolmode=None, |
2025 similarity=sim / 100.0, | 2025 similarity=sim / 100.0, |
2026 ) | 2026 ) |
2027 except error.PatchParseError as e: | 2027 except error.PatchParseError as e: |
2028 raise error.InputError(pycompat.bytestr(e)) | 2028 raise error.InputError( |
2029 pycompat.bytestr(e), | |
2030 hint=_( | |
2031 b'check that whitespace in the patch has not been mangled' | |
2032 ), | |
2033 ) | |
2029 except error.PatchApplicationError as e: | 2034 except error.PatchApplicationError as e: |
2030 if not partial: | 2035 if not partial: |
2031 raise error.StateError(pycompat.bytestr(e)) | 2036 raise error.StateError(pycompat.bytestr(e)) |
2032 if partial: | 2037 if partial: |
2033 rejects = True | 2038 rejects = True |
2084 prefix, | 2089 prefix, |
2085 files, | 2090 files, |
2086 eolmode=None, | 2091 eolmode=None, |
2087 ) | 2092 ) |
2088 except error.PatchParseError as e: | 2093 except error.PatchParseError as e: |
2089 raise error.InputError(stringutil.forcebytestr(e)) | 2094 raise error.InputError( |
2095 stringutil.forcebytestr(e), | |
2096 hint=_( | |
2097 b'check that whitespace in the patch has not been mangled' | |
2098 ), | |
2099 ) | |
2090 except error.PatchApplicationError as e: | 2100 except error.PatchApplicationError as e: |
2091 raise error.StateError(stringutil.forcebytestr(e)) | 2101 raise error.StateError(stringutil.forcebytestr(e)) |
2092 if opts.get(b'exact'): | 2102 if opts.get(b'exact'): |
2093 editor = None | 2103 editor = None |
2094 else: | 2104 else: |