patch: handle binary copies as regular ones
authorPatrick Mezard <pmezard@gmail.com>
Wed, 18 May 2011 23:48:13 +0200
changeset 14369 f8932d540088
parent 14368 baf2807b9a7d
child 14370 17cea10c343e
patch: handle binary copies as regular ones This introduces a performance regression for large files, as they will be copied just to be clobbered afterwards since binary patching does not use deltas. But it simplifies the code and the previous optimization will be reintroduced later in a better way.
mercurial/patch.py
--- a/mercurial/patch.py	Wed May 18 23:48:13 2011 +0200
+++ b/mercurial/patch.py	Wed May 18 23:48:13 2011 +0200
@@ -923,7 +923,7 @@
         self.hunk = ['GIT binary patch\n']
 
     def createfile(self):
-        return self.gitpatch.op in ('ADD', 'RENAME', 'COPY')
+        return self.gitpatch.op == 'ADD'
 
     def rmfile(self):
         return self.gitpatch.op == 'DELETE'
@@ -1209,9 +1209,7 @@
                 gp.path = pathstrip(gp.path, strip - 1)[1]
                 if gp.oldpath:
                     gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1]
-                # 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:
+                if gp.op in ('COPY', 'RENAME'):
                     backend.copy(gp.oldpath, gp.path)
                 changed[gp.path] = gp
         else: