[PATCH 4 of 5] patch: handle binary copies as regular ones

Patrick Mezard pmezard at gmail.com
Wed May 18 15:57:17 CDT 2011


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1305751514 -7200
# Node ID af7c13d7a0f23b3e2b1498ea9b602aff06ed50e9
# Parent  8f2ad395b7417584efe22f0c27e141854198f28f
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.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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:


More information about the Mercurial-devel mailing list