comparison mercurial/patch.py @ 14369:f8932d540088

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.
author Patrick Mezard <pmezard@gmail.com>
date Wed, 18 May 2011 23:48:13 +0200
parents baf2807b9a7d
children 17cea10c343e
comparison
equal deleted inserted replaced
14368:baf2807b9a7d 14369:f8932d540088
921 self.gitpatch = gitpatch 921 self.gitpatch = gitpatch
922 self.text = None 922 self.text = None
923 self.hunk = ['GIT binary patch\n'] 923 self.hunk = ['GIT binary patch\n']
924 924
925 def createfile(self): 925 def createfile(self):
926 return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') 926 return self.gitpatch.op == 'ADD'
927 927
928 def rmfile(self): 928 def rmfile(self):
929 return self.gitpatch.op == 'DELETE' 929 return self.gitpatch.op == 'DELETE'
930 930
931 def complete(self): 931 def complete(self):
1207 elif state == 'git': 1207 elif state == 'git':
1208 for gp in values: 1208 for gp in values:
1209 gp.path = pathstrip(gp.path, strip - 1)[1] 1209 gp.path = pathstrip(gp.path, strip - 1)[1]
1210 if gp.oldpath: 1210 if gp.oldpath:
1211 gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1] 1211 gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1]
1212 # Binary patches really overwrite target files, copying them 1212 if gp.op in ('COPY', 'RENAME'):
1213 # will just make it fails with "target file exists"
1214 if gp.op in ('COPY', 'RENAME') and not gp.binary:
1215 backend.copy(gp.oldpath, gp.path) 1213 backend.copy(gp.oldpath, gp.path)
1216 changed[gp.path] = gp 1214 changed[gp.path] = gp
1217 else: 1215 else:
1218 raise util.Abort(_('unsupported parser state: %s') % state) 1216 raise util.Abort(_('unsupported parser state: %s') % state)
1219 1217