merge with crew-stable
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Sun, 31 Aug 2008 12:05:29 +0200
changeset 6951 c8c9ce0ed3ee
parent 6948 359e93ceee3a (current diff)
parent 6950 381a892159d9 (diff)
child 6952 3fffba1c87d0
merge with crew-stable
hgext/record.py
--- a/hgext/record.py	Sun Aug 31 11:41:52 2008 +0200
+++ b/hgext/record.py	Sun Aug 31 12:05:29 2008 +0200
@@ -155,6 +155,8 @@
 
     def write(self, fp):
         delta = len(self.before) + len(self.after)
+        if self.after and self.after[-1] == '\\ No newline at end of file\n':
+            delta -= 1
         fromlen = delta + self.removed
         tolen = delta + self.added
         fp.write('@@ -%d,%d +%d,%d @@%s\n' %
@@ -206,7 +208,7 @@
             if self.context:
                 self.before = self.context
                 self.context = []
-            self.hunk = data
+            self.hunk = hunk
 
         def newfile(self, hdr):
             self.addcontext([])
@@ -467,9 +469,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.