mercurial/patch.py
changeset 37573 49b82cdb5983
parent 37571 0ea8b9576d7c
child 37574 a1bcc7ff0eac
--- a/mercurial/patch.py	Mon Apr 09 20:55:05 2018 +0900
+++ b/mercurial/patch.py	Mon Apr 09 21:06:46 2018 +0900
@@ -1254,8 +1254,11 @@
             self.lenb = int(self.lenb)
         self.starta = int(self.starta)
         self.startb = int(self.startb)
-        diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb, self.a,
-                             self.b)
+        try:
+            diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb,
+                                 self.a, self.b)
+        except error.ParseError as e:
+            raise PatchError(_("bad hunk #%d: %s") % (self.number, e))
         # if we hit eof before finishing out the hunk, the last line will
         # be zero length.  Lets try to fix it up.
         while len(self.hunk[-1]) == 0: