# HG changeset patch # User Patrick Mezard # Date 1349511035 -7200 # Node ID a80b01ceb1fca28b42784f29c27a9807121bc0ea # Parent 297e2b4a6e2cd7fdab0160b3491a3393e3edff1a editor: relax copyfrom dir checks to avoid extra missing entries When renaming a branch you get something like: D /branch/bar A /branch/foo (from /branch/foo:42) Unfortunately, the branch layout for the revision being converted is computed before starting to convert it. It means the copyfrom path supplied in the add_directory() for /branch/foo will be be considered invalid, be added to missing and fetched the slow way despite being in the repository history. Avoid that by checking the path looks like a branch path and matching it with the filemap. It will be resolved afterwards anyway. diff --git a/hgsubversion/editor.py b/hgsubversion/editor.py --- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -406,7 +406,11 @@ class HgEditor(svnwrap.Editor): tag = self.meta.get_path_tag(copyfrom_path) if tag not in self.meta.tags: tag = None - if not self.meta.is_path_valid(copyfrom_path): + if not self.meta.is_path_valid(copyfrom_path, existing=False): + # The source path only exists at copyfrom_revision, use + # existing=False to guess a possible branch location and + # test it against the filemap. The actual path and + # revision will be resolved below if necessary. self.current.addmissing('%s/' % path) return path if tag: diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py --- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -393,10 +393,10 @@ class SVNMeta(object): return {ln: (src_branch, src_rev, revnum)} return {} - def is_path_valid(self, path): + def is_path_valid(self, path, existing=True): if path is None: return False - subpath = self.split_branch_path(path)[0] + subpath = self.split_branch_path(path, existing)[0] if subpath is None: return False return subpath in self.filemap diff --git a/tests/test_fetch_branches.py b/tests/test_fetch_branches.py --- a/tests/test_fetch_branches.py +++ b/tests/test_fetch_branches.py @@ -58,8 +58,9 @@ class TestFetchBranches(test_util.TestBa self.test_unorderedbranch(True) def test_renamed_branch_to_trunk(self, stupid=False): + config = {'hgsubversion.failonmissing': 'true'} repo = self._load_fixture_and_fetch('branch_rename_to_trunk.svndump', - stupid=stupid) + stupid=stupid, config=config) self.assertEqual(repo['default'].parents()[0].branch(), 'dev_branch') self.assert_('iota' in repo['default']) self.assertEqual(repo['old_trunk'].parents()[0].branch(), 'default') diff --git a/tests/test_fetch_command.py b/tests/test_fetch_command.py --- a/tests/test_fetch_command.py +++ b/tests/test_fetch_command.py @@ -95,13 +95,16 @@ class TestBasicRepoLayout(test_util.Test assert 'README' not in repo assert '../branches' not in repo - def test_files_copied_from_outside_btt(self): + def test_files_copied_from_outside_btt(self, stupid=False): repo = self._load_fixture_and_fetch( - 'test_files_copied_from_outside_btt.svndump') + 'test_files_copied_from_outside_btt.svndump', stupid=stupid) self.assertEqual(node.hex(repo['tip'].node()), '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') self.assertEqual(len(repo.changelog), 2) + def test_files_copied_from_outside_btt_stupid(self): + self.test_files_copied_from_outside_btt(stupid=True) + def test_file_renamed_in_from_outside_btt(self): repo = self._load_fixture_and_fetch( 'file_renamed_in_from_outside_btt.svndump')