Mercurial > hgsubversion
comparison fetch_command.py @ 200:2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 02 Mar 2009 23:50:40 -0600 |
parents | df4611050286 |
children | 907c160c6289 |
comparison
equal
deleted
inserted
replaced
199:91db8fc049b0 | 200:2e8c527f0456 |
---|---|
198 def unlink(self, fname): | 198 def unlink(self, fname): |
199 files[fname] = None | 199 files[fname] = None |
200 | 200 |
201 return mempatch | 201 return mempatch |
202 | 202 |
203 | |
204 def filteriterhunks(hg_editor): | |
205 iterhunks = patch.iterhunks | |
206 def filterhunks(ui, fp, sourcefile=None): | |
207 applycurrent = False | |
208 for data in iterhunks(ui, fp, sourcefile): | |
209 if data[0] == 'file': | |
210 if hg_editor._is_file_included(data[1][1]): | |
211 applycurrent = True | |
212 else: | |
213 applycurrent = False | |
214 assert data[0] != 'git', 'Filtering git hunks not supported.' | |
215 if applycurrent: | |
216 yield data | |
217 return filterhunks | |
218 | |
203 def stupid_diff_branchrev(ui, svn, hg_editor, branch, r, parentctx): | 219 def stupid_diff_branchrev(ui, svn, hg_editor, branch, r, parentctx): |
204 """Extract all 'branch' content at a given revision. | 220 """Extract all 'branch' content at a given revision. |
205 | 221 |
206 Return a tuple (files, filectxfn) where 'files' is the list of all files | 222 Return a tuple (files, filectxfn) where 'files' is the list of all files |
207 in the branch at the given revision, and 'filectxfn' is a memctx compatible | 223 in the branch at the given revision, and 'filectxfn' is a memctx compatible |
252 # are marked as touched. Content is loaded on demand. | 268 # are marked as touched. Content is loaded on demand. |
253 touched_files[f] = 1 | 269 touched_files[f] = 1 |
254 if d2.strip() and len(re.findall('\n[-+]', d2.strip())) > 0: | 270 if d2.strip() and len(re.findall('\n[-+]', d2.strip())) > 0: |
255 try: | 271 try: |
256 oldpatchfile = patch.patchfile | 272 oldpatchfile = patch.patchfile |
273 olditerhunks = patch.iterhunks | |
257 patch.patchfile = mempatchproxy(parentctx, files_data) | 274 patch.patchfile = mempatchproxy(parentctx, files_data) |
275 patch.iterhunks = filteriterhunks(hg_editor) | |
258 try: | 276 try: |
259 # We can safely ignore the changed list since we are | 277 # We can safely ignore the changed list since we are |
260 # handling non-git patches. Touched files are known | 278 # handling non-git patches. Touched files are known |
261 # by our memory patcher. | 279 # by our memory patcher. |
262 patch_st = patch.applydiff(ui, cStringIO.StringIO(d2), | 280 patch_st = patch.applydiff(ui, cStringIO.StringIO(d2), |
263 {}, strip=0) | 281 {}, strip=0) |
264 finally: | 282 finally: |
265 patch.patchfile = oldpatchfile | 283 patch.patchfile = oldpatchfile |
284 patch.iterhunks = olditerhunks | |
266 except patch.PatchError: | 285 except patch.PatchError: |
267 # TODO: this happens if the svn server has the wrong mime | 286 # TODO: this happens if the svn server has the wrong mime |
268 # type stored and doesn't know a file is binary. It would | 287 # type stored and doesn't know a file is binary. It would |
269 # be better to do one file at a time and only do a | 288 # be better to do one file at a time and only do a |
270 # full fetch on files that had problems. | 289 # full fetch on files that had problems. |