comparison mercurial/patch.py @ 35320:12ce62c72c24

patch: catch unexpected case in _inlinediff If operation is neither 'diff.inserted' or 'diff.deleted', label and token won't be define. This patch explicitely catches that exception.
author Matthieu Laneuville <matthieu.laneuville@octobus.net>
date Fri, 08 Dec 2017 16:54:59 +0900
parents 10cce12fdcd3
children 4937db58b663
comparison
equal deleted inserted replaced
35319:10cce12fdcd3 35320:12ce62c72c24
2573 elif operation == 'diff.inserted' and s1.startswith('+'): 2573 elif operation == 'diff.inserted' and s1.startswith('+'):
2574 label = operation 2574 label = operation
2575 token = '+' 2575 token = '+'
2576 s2 = s2[1:] 2576 s2 = s2[1:]
2577 s1 = s1[1:] 2577 s1 = s1[1:]
2578 else:
2579 raise error.ProgrammingError("Case not expected, operation = %s" %
2580 operation)
2578 2581
2579 s = difflib.ndiff(re.split(br'(\W)', s2), re.split(br'(\W)', s1)) 2582 s = difflib.ndiff(re.split(br'(\W)', s2), re.split(br'(\W)', s1))
2580 for part in s: 2583 for part in s:
2581 if part[0] in operation_skip: 2584 if part[0] in operation_skip:
2582 continue 2585 continue