changeset 12674:aa2fe1f52ff4

patch: always raise PatchError with a message, simplify handling
author Patrick Mezard <pmezard@gmail.com>
date Sat, 09 Oct 2010 15:13:08 -0500
parents 9ad16d1bce4b
children c6cdc123f6e4
files hgext/record.py mercurial/patch.py
diffstat 2 files changed, 3 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/record.py	Sat Oct 09 15:13:08 2010 -0500
+++ b/hgext/record.py	Sat Oct 09 15:13:08 2010 -0500
@@ -499,11 +499,7 @@
                                         eolmode=None)
                     cmdutil.updatedir(ui, repo, pfiles)
                 except patch.PatchError, err:
-                    s = str(err)
-                    if s:
-                        raise util.Abort(s)
-                    else:
-                        raise util.Abort(_('patch failed to apply'))
+                    raise util.Abort(str(err))
             del fp
 
             # 4. We prepared working directory according to filtered patch.
--- a/mercurial/patch.py	Sat Oct 09 15:13:08 2010 -0500
+++ b/mercurial/patch.py	Sat Oct 09 15:13:08 2010 -0500
@@ -1233,7 +1233,7 @@
         if fp != patchobj:
             fp.close()
     if ret < 0:
-        raise PatchError
+        raise PatchError(_('patch failed to apply'))
     return ret > 0
 
 def patch(patchname, ui, strip=1, cwd=None, files=None, eolmode='strict'):
@@ -1256,11 +1256,7 @@
             return externalpatch(patcher, patchname, ui, strip, cwd, files)
         return internalpatch(patchname, ui, strip, cwd, files, eolmode)
     except PatchError, err:
-        s = str(err)
-        if s:
-            raise util.Abort(s)
-        else:
-            raise util.Abort(_('patch failed to apply'))
+        raise util.Abort(str(err))
 
 def b85diff(to, tn):
     '''print base85-encoded binary diff'''