diff mercurial/patch.py @ 12577:05210e955bef

Merge with stable
author Patrick Mezard <pmezard@gmail.com>
date Tue, 28 Sep 2010 01:11:24 +0200
parents e0ee3e822a9a 1c9bb7e00f71
children d7452292f9d3
line wrap: on
line diff
--- a/mercurial/patch.py	Mon Sep 27 22:49:30 2010 +0200
+++ b/mercurial/patch.py	Tue Sep 28 01:11:24 2010 +0200
@@ -1184,7 +1184,9 @@
                 gp.path = pathstrip(gp.path, strip - 1)[1]
                 if gp.oldpath:
                     gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1]
-                if gp.op in ('COPY', 'RENAME'):
+                # Binary patches really overwrite target files, copying them
+                # will just make it fails with "target file exists"
+                if gp.op in ('COPY', 'RENAME') and not gp.binary:
                     copyfn(gp.oldpath, gp.path, cwd)
                 changed[gp.path] = gp
         else:
@@ -1530,6 +1532,9 @@
                         header.append('new file mode %s\n' % mode)
                     elif ctx2.flags(f):
                         losedatafn(f)
+                # In theory, if tn was copied or renamed we should check
+                # if the source is binary too but the copy record already
+                # forces git mode.
                 if util.binary(tn):
                     if opts.git:
                         dodiff = 'binary'
@@ -1549,7 +1554,7 @@
                     else:
                         header.append('deleted file mode %s\n' %
                                       gitmode[man1.flags(f)])
-                elif not to:
+                elif not to or util.binary(to):
                     # regular diffs cannot represent empty file deletion
                     losedatafn(f)
             else: