record: catch PatchErrors from internalpatch and display error message
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Sun, 31 Aug 2008 11:36:07 +0200
changeset 6950 381a892159d9
parent 6949 834f7e069cae
child 6951 c8c9ce0ed3ee
child 6969 d76f64cd4cb2
record: catch PatchErrors from internalpatch and display error message This resulted in big ugly tracebacks in issue1282, for example.
hgext/record.py
--- a/hgext/record.py	Sun Aug 31 11:34:52 2008 +0200
+++ b/hgext/record.py	Sun Aug 31 11:36:07 2008 +0200
@@ -468,9 +468,16 @@
 
             # 3b. (apply)
             if dopatch:
-                ui.debug('applying patch\n')
-                ui.debug(fp.getvalue())
-                patch.internalpatch(fp, ui, 1, repo.root)
+                try:
+                    ui.debug('applying patch\n')
+                    ui.debug(fp.getvalue())
+                    patch.internalpatch(fp, ui, 1, repo.root)
+                except patch.PatchError, err:
+                    s = str(err)
+                    if s:
+                        raise util.Abort(s)
+                    else:
+                        raise util.Abort(_('patch failed to apply'))
             del fp
 
             # 4. We prepared working directory according to filtered patch.