comparison hgsubversion/stupid.py @ 814:d32735c507cd

stupid: use new patching facility introduced by adbf5e7df96d
author Patrick Mezard <pmezard@gmail.com>
date Wed, 15 Jun 2011 14:44:14 +0200
parents ccefff0c4f91
children 033b86e0f56d
comparison
equal deleted inserted replaced
813:f07bfd66db13 814:d32735c507cd
113 assert data[0] != 'git', 'Filtering git hunks not supported.' 113 assert data[0] != 'git', 'Filtering git hunks not supported.'
114 if applycurrent: 114 if applycurrent:
115 yield data 115 yield data
116 return filterhunks 116 return filterhunks
117 117
118 def patchrepo(ui, meta, parentctx, patchfp): 118 def patchrepoold(ui, meta, parentctx, patchfp):
119 files = {} 119 files = {}
120 try: 120 try:
121 oldpatchfile = patch.patchfile 121 oldpatchfile = patch.patchfile
122 olditerhunks = patch.iterhunks 122 olditerhunks = patch.iterhunks
123 patch.patchfile = mempatchproxy(parentctx, files) 123 patch.patchfile = mempatchproxy(parentctx, files)
145 # When converting Django, I saw fuzz on .po files that was 145 # When converting Django, I saw fuzz on .po files that was
146 # causing revisions to end up failing verification. If that 146 # causing revisions to end up failing verification. If that
147 # can be fixed, maybe this won't ever be reached. 147 # can be fixed, maybe this won't ever be reached.
148 raise BadPatchApply('patching succeeded with fuzz') 148 raise BadPatchApply('patching succeeded with fuzz')
149 return files 149 return files
150
151 try:
152 class svnbackend(patch.repobackend):
153 def getfile(self, fname):
154 data, (islink, isexec) = super(svnbackend, self).getfile(fname)
155 if islink:
156 data = 'link ' + data
157 return data, (islink, isexec)
158 except AttributeError:
159 svnbackend = None
160
161 def patchrepo(ui, meta, parentctx, patchfp):
162 if not svnbackend:
163 return patchrepoold(ui, meta, parentctx, patchfp)
164 store = patch.filestore()
165 try:
166 touched = set()
167 backend = svnbackend(ui, meta.repo, parentctx, store)
168 ret = patch.patchbackend(ui, backend, patchfp, 0, touched)
169 if ret < 0:
170 raise BadPatchApply('patching failed')
171 if ret > 0:
172 raise BadPatchApply('patching succeeded with fuzz')
173 files = {}
174 for f in touched:
175 try:
176 data, mode, copied = store.getfile(f)
177 files[f] = data
178 except IOError:
179 files[f] = None
180 return files
181 finally:
182 store.close()
150 183
151 def diff_branchrev(ui, svn, meta, branch, branchpath, r, parentctx): 184 def diff_branchrev(ui, svn, meta, branch, branchpath, r, parentctx):
152 """Extract all 'branch' content at a given revision. 185 """Extract all 'branch' content at a given revision.
153 186
154 Return a tuple (files, filectxfn) where 'files' is the list of all files 187 Return a tuple (files, filectxfn) where 'files' is the list of all files