patch: catch unexpected case in _inlinediff
authorMatthieu Laneuville <matthieu.laneuville@octobus.net>
Fri, 08 Dec 2017 16:54:59 +0900
changeset 35311 12ce62c72c24
parent 35310 10cce12fdcd3
child 35312 73abb81ccb28
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.
mercurial/patch.py
--- a/mercurial/patch.py	Fri Dec 08 16:47:18 2017 +0900
+++ b/mercurial/patch.py	Fri Dec 08 16:54:59 2017 +0900
@@ -2575,6 +2575,9 @@
         token = '+'
         s2 = s2[1:]
         s1 = s1[1:]
+    else:
+        raise error.ProgrammingError("Case not expected, operation = %s" %
+                                     operation)
 
     s = difflib.ndiff(re.split(br'(\W)', s2), re.split(br'(\W)', s1))
     for part in s: