[PATCH 2 of 2] patch: catch unexpected case in _inlinediff

matthieu.laneuville at octobus.net matthieu.laneuville at octobus.net
Fri Dec 8 04:42:12 EST 2017


# HG changeset patch
# User Matthieu Laneuville <matthieu.laneuville at octobus.net>
# Date 1512719699 -32400
#      Fri Dec 08 16:54:59 2017 +0900
# Node ID a1215935559d6e2afa49be0a1601b6ba8eaa7dbf
# Parent  8e3ebafd54d664a1f3ce2032b20cff92b5b399fb
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a1215935559d
# EXP-Topic inline-diff
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.

diff -r 8e3ebafd54d6 -r a1215935559d 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 @@ def _inlinediff(s1, s2, operation):
         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:


More information about the Mercurial-devel mailing list