Commits

kiilerix committed c3e5866

Abort on malformed patches instead of crashing

(grafted from Mercurial e4ae397595e8)

Comments (0)

Files changed (1)

         diffopts = patch.diffopts(ui, opts={'git': True, 'nodates': True})
         chunks = patch.diff(repo, changes=changes, opts=diffopts)
         fp = cStringIO.StringIO(''.join(chunks))
-        ac = parsepatch(fp)
+
+        try:
+            ac = parsepatch(fp)
+        except patch.PatchError, err:
+            raise util.Abort(_('error parsing patch: %s') % err)
+
         del fp
 
         # 1. filter patch, so we have intending-to apply subset of it