# HG changeset patch # User Augie Fackler # Date 1238190967 18000 # Node ID b5ef9a404f5dc488cb70d48586b222fdb5732161 # Parent 1416429584b23032778dbbf5438d53d89f761014 Stopped idiotic filtering of revisions that did not edit something branches/tags/trunk. Fixed a bunch of tests as a result. This likely will make new conversions of some repos have new revisions in them. diff --git a/rebuildmeta.py b/rebuildmeta.py --- a/rebuildmeta.py +++ b/rebuildmeta.py @@ -85,6 +85,8 @@ def rebuildmeta(ui, repo, hg_repo_path, branchinfofile = open(os.path.join(svnmetadir, 'branch_info'), 'w') pickle.dump(branchinfo, branchinfofile) branchinfofile.close() + + # now handle tags tagsinfo = {} realtags = svn.tags tagsleft = realtags.items() @@ -103,10 +105,11 @@ def rebuildmeta(ui, repo, hg_repo_path, older_tags = svn.tags_at_rev(rev) newsrc, newrev = older_tags[src] tagsleft.append((tag, (newsrc, newrev))) - if source.startswith('branches/') or source == 'trunk': + continue + else: source = determinebranch(source) - if rev <= last_rev: - tagsinfo[tag] = source, rev + if rev <= last_rev: + tagsinfo[tag] = source, rev tagsinfofile = open(os.path.join(svnmetadir, 'tag_info'), 'w') pickle.dump(tagsinfo, tagsinfofile) tagsinfofile.close() @@ -114,10 +117,11 @@ rebuildmeta = util.register_subcommand(' rebuildmeta = util.command_needs_no_url(rebuildmeta) def determinebranch(branch): - if branch.startswith('branches'): + assert not branch.startswith('tags/'), "Tags can't be tags of other tags." + if branch.startswith('branches/'): branch = branch[len('branches/'):] elif branch == 'trunk': branch = None else: - assert False, 'Unhandled case while regenerating metadata.' + branch = '../' + branch return branch diff --git a/svnwrap/svn_swig_wrapper.py b/svnwrap/svn_swig_wrapper.py --- a/svnwrap/svn_swig_wrapper.py +++ b/svnwrap/svn_swig_wrapper.py @@ -211,6 +211,8 @@ class SubversionRepo(object): source = hist.paths[path].copyfrom_path source_rev = 0 for p in hist.paths: + if not p.startswith(path): + continue if hist.paths[p].copyfrom_rev: # We assume that the revision of the source tree as it was # copied was actually the revision of the highest revision @@ -247,26 +249,8 @@ class SubversionRepo(object): The reason this is lazy is so that you can use the same repo object to perform RA calls to get deltas. """ - # NB: you'd think this would work, but you'd be wrong. I'm pretty - # convinced there must be some kind of svn bug here. - #return self.fetch_history_at_paths(['tags', 'trunk', 'branches'], - # start=start) - # this does the same thing, but at the repo root + filtering. It's - # kind of tough cookies, sadly. - for r in self.fetch_history_at_paths([''], start=start, - chunk_size=chunk_size): - should_yield = False - i = 0 - paths = list(r.paths.keys()) - while i < len(paths) and not should_yield: - p = paths[i] - if (p.startswith('trunk') or p.startswith('tags') - or p.startswith('branches')): - should_yield = True - i += 1 - if should_yield: - yield r - + return self.fetch_history_at_paths([''], start=start, + chunk_size=chunk_size) def fetch_history_at_paths(self, paths, start=None, stop=None, chunk_size=1000): diff --git a/tests/test_externals.py b/tests/test_externals.py --- a/tests/test_externals.py +++ b/tests/test_externals.py @@ -10,9 +10,8 @@ class TestFetchExternals(test_util.TestB f['t1'] = 'dir1 -r10 svn://foobar' f['t 2'] = 'dir2 -r10 svn://foobar' f['t3'] = ['dir31 -r10 svn://foobar', 'dir32 -r10 svn://foobar'] - - refext = """\ -[t 2] + + refext = """[t 2] dir2 -r10 svn://foobar [t1] dir1 -r10 svn://foobar @@ -32,55 +31,49 @@ class TestFetchExternals(test_util.TestB def test_externals(self, stupid=False): repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) - ref0 = """\ -[.] + ref0 = """[.] ^/externals/project1 deps/project1 """ - self.assertEqual(ref0, repo[0]['.hgsvnexternals'].data()) - ref1 = """\ -[.] + self.assertEqual(ref0, repo[0+2]['.hgsvnexternals'].data()) + ref1 = """[.] ^/externals/project1 deps/project1 ^/externals/project2 deps/project2 """ - self.assertEqual(ref1, repo[1]['.hgsvnexternals'].data()) + self.assertEqual(ref1, repo[1+2]['.hgsvnexternals'].data()) - ref2 = """\ -[.] + ref2 = """[.] ^/externals/project2 deps/project2 [subdir] ^/externals/project1 deps/project1 [subdir2] ^/externals/project1 deps/project1 """ - self.assertEqual(ref2, repo[2]['.hgsvnexternals'].data()) + actual = repo[2+2]['.hgsvnexternals'].data() + self.assertEqual(ref2, actual) - ref3 = """\ -[.] + ref3 = """[.] ^/externals/project2 deps/project2 [subdir] ^/externals/project1 deps/project1 """ - self.assertEqual(ref3, repo[3]['.hgsvnexternals'].data()) + self.assertEqual(ref3, repo[3+2]['.hgsvnexternals'].data()) - ref4 = """\ -[subdir] + ref4 = """[subdir] ^/externals/project1 deps/project1 """ - self.assertEqual(ref4, repo[4]['.hgsvnexternals'].data()) + self.assertEqual(ref4, repo[4+2]['.hgsvnexternals'].data()) - ref5 = """\ -[.] + ref5 = """[.] ^/externals/project2 deps/project2 [subdir2] ^/externals/project1 deps/project1 """ - self.assertEqual(ref5, repo[5]['.hgsvnexternals'].data()) + self.assertEqual(ref5, repo[5+2]['.hgsvnexternals'].data()) - ref6 = """\ -[.] + ref6 = """[.] ^/externals/project2 deps/project2 """ - self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) + self.assertEqual(ref6, repo[6+2]['.hgsvnexternals'].data()) def test_externals_stupid(self): self.test_externals(True) @@ -96,9 +89,8 @@ class TestPushExternals(test_util.TestBa def test_push_externals(self, stupid=False): # Add a new reference on an existing and non-existing directory changes = [ - ('.hgsvnexternals', '.hgsvnexternals', - """\ -[dir] + ('.hgsvnexternals', '.hgsvnexternals', + """[dir] ../externals/project2 deps/project2 [subdir1] ../externals/project1 deps/project1 @@ -115,9 +107,8 @@ class TestPushExternals(test_util.TestBa # Remove all references from one directory, add a new one # to the other (test multiline entries) changes = [ - ('.hgsvnexternals', '.hgsvnexternals', - """\ -[subdir1] + ('.hgsvnexternals', '.hgsvnexternals', + """[subdir1] ../externals/project1 deps/project1 ../externals/project2 deps/project2 """), 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 @@ -94,12 +94,12 @@ class TestBasicRepoLayout(test_util.Test 'test_files_copied_from_outside_btt.svndump') self.assertEqual(node.hex(repo['tip'].node()), '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') - self.assertEqual(len(repo.changelog), 2) + self.assertEqual(len(repo.changelog), 3) def test_file_renamed_in_from_outside_btt(self): repo = self._load_fixture_and_fetch( 'file_renamed_in_from_outside_btt.svndump') - self.assert_('LICENSE.file' in repo['tip']) + self.assert_('LICENSE.file' in repo['default']) def test_renamed_dir_in_from_outside_btt_not_repo_root(self): repo = self._load_fixture_and_fetch(