Patchwork [2,of,2] patch: catch unexpected case in _inlinediff

login
register
mail settings
Submitter matthieu.laneuville@octobus.net
Date Dec. 8, 2017, 9:42 a.m.
Message ID <a1215935559d6e2afa49.1512726132@carbon>
Download mbox | patch
Permalink /patch/26088/
State Accepted
Headers show

Comments

matthieu.laneuville@octobus.net - Dec. 8, 2017, 9:42 a.m.
# HG changeset patch
# User Matthieu Laneuville <matthieu.laneuville@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.

Patch

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: