diff mercurial/patch.py @ 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 8540967cd9e0
children 48dea083f66d
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: