Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
30818:4c0a5a256ae8 | 30819:897726622877 |
---|---|
2182 hlen = None | 2182 hlen = None |
2183 try: | 2183 try: |
2184 # the hash config could be an integer (for length of hash) or a | 2184 # the hash config could be an integer (for length of hash) or a |
2185 # word (e.g. short, full, none) | 2185 # word (e.g. short, full, none) |
2186 hlen = int(hconf) | 2186 hlen = int(hconf) |
2187 if hlen < 0 or hlen > 40: | |
2188 msg = _("invalid length for extendedheader.index: '%d'\n") | |
2189 ui.warn(msg % hlen) | |
2187 except ValueError: | 2190 except ValueError: |
2188 # default value | 2191 # default value |
2189 if hconf == 'short' or hconf == '': | 2192 if hconf == 'short' or hconf == '': |
2190 hlen = 12 | 2193 hlen = 12 |
2191 elif hconf == 'full': | 2194 elif hconf == 'full': |
2192 hlen = 40 | 2195 hlen = 40 |
2193 elif hconf != 'none': | 2196 elif hconf != 'none': |
2194 msg = _("invalid value for extendedheader.index: '%s'\n") | 2197 msg = _("invalid value for extendedheader.index: '%s'\n") |
2195 ui.warn(msg % hconf) | 2198 ui.warn(msg % hconf) |
2196 finally: | 2199 finally: |
2197 if hlen < 0 or hlen > 40: | |
2198 msg = _("invalid length for extendedheader.index: '%d'\n") | |
2199 ui.warn(msg % hlen) | |
2200 buildopts['index'] = hlen | 2200 buildopts['index'] = hlen |
2201 | 2201 |
2202 if whitespace: | 2202 if whitespace: |
2203 buildopts['ignorews'] = get('ignore_all_space', 'ignorews') | 2203 buildopts['ignorews'] = get('ignore_all_space', 'ignorews') |
2204 buildopts['ignorewsamount'] = get('ignore_space_change', | 2204 buildopts['ignorewsamount'] = get('ignore_space_change', |