Mercurial > hg
changeset 30819:897726622877
patch: check length of git index header only if integer is specified
Otherwise TypeError would be raised. Follows up d1901c4c8ec0.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 15 Jan 2017 16:33:15 +0900 |
parents | 4c0a5a256ae8 |
children | 6a70cf94d1b5 |
files | mercurial/patch.py tests/test-diff-unified.t |
diffstat | 2 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Fri Jan 13 20:16:56 2017 -0800 +++ b/mercurial/patch.py Sun Jan 15 16:33:15 2017 +0900 @@ -2184,6 +2184,9 @@ # the hash config could be an integer (for length of hash) or a # word (e.g. short, full, none) hlen = int(hconf) + if hlen < 0 or hlen > 40: + msg = _("invalid length for extendedheader.index: '%d'\n") + ui.warn(msg % hlen) except ValueError: # default value if hconf == 'short' or hconf == '': @@ -2194,9 +2197,6 @@ msg = _("invalid value for extendedheader.index: '%s'\n") ui.warn(msg % hconf) finally: - if hlen < 0 or hlen > 40: - msg = _("invalid length for extendedheader.index: '%d'\n") - ui.warn(msg % hlen) buildopts['index'] = hlen if whitespace:
--- a/tests/test-diff-unified.t Fri Jan 13 20:16:56 2017 -0800 +++ b/tests/test-diff-unified.t Sun Jan 15 16:33:15 2017 +0900 @@ -243,6 +243,28 @@ -a +b + $ hg diff --git --config experimental.extendedheader.index=-1 + invalid length for extendedheader.index: '-1' + diff --git a/f1 b/f 1 + rename from f1 + rename to f 1 + --- a/f1 + +++ b/f 1 + @@ -1,1 +1,1 @@ + -a + +b + + $ hg diff --git --config experimental.extendedheader.index=whatever + invalid value for extendedheader.index: 'whatever' + diff --git a/f1 b/f 1 + rename from f1 + rename to f 1 + --- a/f1 + +++ b/f 1 + @@ -1,1 +1,1 @@ + -a + +b + Git diff with noprefix $ hg --config diff.noprefix=True diff --git --nodates