branches: change handling again, but this time a little less magic.

This change means that files located in the actual branches directory will now be wholly
ignored. If we want to handle those correctly, it will take a reasonably large amount of work
and probably a configuration flag. Also, any non-related paths outside of branches/trunk will
be explicitly ignored, which is similar to the somewhat accidental pre-branch-refactor
behavior. Finally, any unrelated files located as children of branches will cause the directory
in branches to be used as the branch - not, as recently was the case, the directory immediately
containing that file.
This commit is contained in:
Augie Fackler 2009-03-28 16:38:57 -05:00
parent 786e73be71
commit 648006ec19
5 changed files with 21 additions and 13 deletions

View File

@ -115,6 +115,7 @@ def cleanup_file_handles(svn, count):
if count % 50 == 0:
svn.init_ra_and_client()
def replay_convert_rev(hg_editor, svn, r):
hg_editor.set_current_rev(r)
svn.get_replay(r.revnum, hg_editor)

View File

@ -225,6 +225,8 @@ class HgChangeReceiver(delta.Editor):
if branchpath.startswith('trunk/'):
branches[self._localname('trunk')] = 'trunk'
continue
if branchname and branchname.startswith('../'):
continue
branches[branchname] = branchpath
return branches
@ -276,10 +278,17 @@ class HgChangeReceiver(delta.Editor):
if path.startswith('trunk/'):
path = test.split('/')[1:]
test = 'trunk'
elif path.startswith('branches/'):
elts = path.split('/')
test = '/'.join(elts[:2])
path = '/'.join(elts[2:])
else:
path = test.split('/')[-1]
test = '/'.join(test.split('/')[:-1])
return path, self._localname(test), test
ln = self._localname(test)
if ln and ln.startswith('../'):
return None, None, None
return path, ln, test
def set_current_rev(self, rev):
"""Set the revision we're currently converting.

View File

@ -108,7 +108,7 @@ def rebuildmeta(ui, repo, hg_repo_path, args, **opts):
continue
else:
source = determinebranch(source)
if rev <= last_rev:
if rev <= last_rev and (source or 'default') in repo.branchtags():
tagsinfo[tag] = source, rev
tagsinfofile = open(os.path.join(svnmetadir, 'tag_info'), 'w')
pickle.dump(tagsinfo, tagsinfofile)

View File

@ -34,12 +34,12 @@ class TestFetchExternals(test_util.TestBase):
ref0 = """[.]
^/externals/project1 deps/project1
"""
self.assertEqual(ref0, repo[0+2]['.hgsvnexternals'].data())
self.assertEqual(ref0, repo[0]['.hgsvnexternals'].data())
ref1 = """[.]
^/externals/project1 deps/project1
^/externals/project2 deps/project2
"""
self.assertEqual(ref1, repo[1+2]['.hgsvnexternals'].data())
self.assertEqual(ref1, repo[1]['.hgsvnexternals'].data())
ref2 = """[.]
^/externals/project2 deps/project2
@ -48,7 +48,7 @@ class TestFetchExternals(test_util.TestBase):
[subdir2]
^/externals/project1 deps/project1
"""
actual = repo[2+2]['.hgsvnexternals'].data()
actual = repo[2]['.hgsvnexternals'].data()
self.assertEqual(ref2, actual)
ref3 = """[.]
@ -56,24 +56,24 @@ class TestFetchExternals(test_util.TestBase):
[subdir]
^/externals/project1 deps/project1
"""
self.assertEqual(ref3, repo[3+2]['.hgsvnexternals'].data())
self.assertEqual(ref3, repo[3]['.hgsvnexternals'].data())
ref4 = """[subdir]
^/externals/project1 deps/project1
"""
self.assertEqual(ref4, repo[4+2]['.hgsvnexternals'].data())
self.assertEqual(ref4, repo[4]['.hgsvnexternals'].data())
ref5 = """[.]
^/externals/project2 deps/project2
[subdir2]
^/externals/project1 deps/project1
"""
self.assertEqual(ref5, repo[5+2]['.hgsvnexternals'].data())
self.assertEqual(ref5, repo[5]['.hgsvnexternals'].data())
ref6 = """[.]
^/externals/project2 deps/project2
"""
self.assertEqual(ref6, repo[6+2]['.hgsvnexternals'].data())
self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data())
def test_externals_stupid(self):
self.test_externals(True)

View File

@ -85,16 +85,14 @@ class TestBasicRepoLayout(test_util.TestBase):
self.assertEqual(node.hex(repo['default'].node()),
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
assert 'README' not in repo
self.assertEqual(repo['tip'].branch(),
'../branches')
assert '../branches' not in repo
def test_files_copied_from_outside_btt(self):
repo = self._load_fixture_and_fetch(
'test_files_copied_from_outside_btt.svndump')
self.assertEqual(node.hex(repo['tip'].node()),
'3c78170e30ddd35f2c32faa0d8646ab75bba4f73')
self.assertEqual(len(repo.changelog), 3)
self.assertEqual(len(repo.changelog), 2)
def test_file_renamed_in_from_outside_btt(self):
repo = self._load_fixture_and_fetch(