Mercurial > hgsubversion
diff 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 |
line wrap: on
line diff
--- a/fetch_command.py +++ b/fetch_command.py @@ -200,6 +200,22 @@ def mempatchproxy(parentctx, files): return mempatch + +def filteriterhunks(hg_editor): + iterhunks = patch.iterhunks + def filterhunks(ui, fp, sourcefile=None): + applycurrent = False + for data in iterhunks(ui, fp, sourcefile): + if data[0] == 'file': + if hg_editor._is_file_included(data[1][1]): + applycurrent = True + else: + applycurrent = False + assert data[0] != 'git', 'Filtering git hunks not supported.' + if applycurrent: + yield data + return filterhunks + def stupid_diff_branchrev(ui, svn, hg_editor, branch, r, parentctx): """Extract all 'branch' content at a given revision. @@ -254,7 +270,9 @@ def stupid_diff_branchrev(ui, svn, hg_ed if d2.strip() and len(re.findall('\n[-+]', d2.strip())) > 0: try: oldpatchfile = patch.patchfile + olditerhunks = patch.iterhunks patch.patchfile = mempatchproxy(parentctx, files_data) + patch.iterhunks = filteriterhunks(hg_editor) try: # We can safely ignore the changed list since we are # handling non-git patches. Touched files are known @@ -263,6 +281,7 @@ def stupid_diff_branchrev(ui, svn, hg_ed {}, strip=0) finally: patch.patchfile = oldpatchfile + patch.iterhunks = olditerhunks except patch.PatchError: # TODO: this happens if the svn server has the wrong mime # type stored and doesn't know a file is binary. It would