summaryrefslogtreecommitdiff
path: root/tests/test_fetch_mappings.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_fetch_mappings.py')
-rw-r--r--tests/test_fetch_mappings.py51
1 files changed, 48 insertions, 3 deletions
diff --git a/tests/test_fetch_mappings.py b/tests/test_fetch_mappings.py
index f022c6f..f4e373c 100644
--- a/tests/test_fetch_mappings.py
+++ b/tests/test_fetch_mappings.py
@@ -92,7 +92,10 @@ class MapTests(test_util.TestBase):
new = open(os.path.join(repopath, 'authors'), 'w')
new.write(open(orig).read())
new.close()
- test = maps.AuthorMap(self.repo.svnmeta(skiperrorcheck=True))
+ meta = self.repo.svnmeta(skiperrorcheck=True)
+ test = maps.AuthorMap(
+ meta.ui, meta.authormap_file, meta.defaulthost,
+ meta.caseignoreauthors, meta.mapauthorscmd, meta.defaultauthors)
fromself = set(test)
test.load(orig)
all_tests = set(test)
@@ -114,6 +117,15 @@ class MapTests(test_util.TestBase):
self.assertEqual(self.repo['tip'].user(),
'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
+ def test_author_map_mapauthorscmd(self):
+ repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
+ ui = self.ui()
+ ui.setconfig('hgsubversion', 'mapauthorscmd', 'echo "svn: %s"')
+ commands.clone(ui, test_util.fileurl(repo_path),
+ self.wc_path)
+ self.assertEqual(self.repo[0].user(), 'svn: Augie')
+ self.assertEqual(self.repo['tip'].user(), 'svn: evil')
+
def _loadwithfilemap(self, svndump, filemapcontent,
failonmissing=True):
repo_path = self.load_svndump(svndump)
@@ -149,9 +161,9 @@ class MapTests(test_util.TestBase):
# The exclusion of alpha is overridden by the later rule to
# include all of '.', whereas gamma should remain excluded
# because it's excluded after the root directory.
- self.assertEqual(self.repo[0].manifest().keys(),
+ self.assertEqual(sorted(self.repo[0].manifest().keys()),
['alpha', 'beta'])
- self.assertEqual(self.repo['default'].manifest().keys(),
+ self.assertEqual(sorted(self.repo['default'].manifest().keys()),
['alpha', 'beta'])
@test_util.requiresreplay
@@ -200,6 +212,22 @@ class MapTests(test_util.TestBase):
self.assert_('good-name' in branches)
self.assertEquals(self.repo[2].branch(), 'default')
+ def test_branchmap_regex_and_glob(self):
+ repo_path = self.load_svndump('branchmap.svndump')
+ branchmap = open(self.branchmap, 'w')
+ branchmap.write("syntax:re\n")
+ branchmap.write("bad(.*) = good-\\1 # stuffy\n")
+ branchmap.write("glob:feat* = default\n")
+ branchmap.close()
+ ui = self.ui()
+ ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
+ commands.clone(ui, test_util.fileurl(repo_path),
+ self.wc_path, branchmap=self.branchmap)
+ branches = set(self.repo[i].branch() for i in self.repo)
+ self.assert_('badname' not in branches)
+ self.assert_('good-name' in branches)
+ self.assertEquals(self.repo[2].branch(), 'default')
+
def test_branchmap_tagging(self):
'''test tagging a renamed branch, which used to raise an exception'''
repo_path = self.load_svndump('commit-to-tag.svndump')
@@ -290,6 +318,23 @@ class MapTests(test_util.TestBase):
for r in repo:
self.assertEquals(verify.verify(ui, repo, rev=r), 0)
+ def test_branchmap_no_replacement(self):
+ '''test that empty mappings are accepted
+
+ Empty mappings are lines like 'this ='. We check that such branches are
+ not converted.
+ '''
+ repo_path = self.load_svndump('branchmap.svndump')
+ branchmap = open(self.branchmap, 'w')
+ branchmap.write("badname =\n")
+ branchmap.close()
+ ui = self.ui()
+ ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
+ commands.clone(ui, test_util.fileurl(repo_path),
+ self.wc_path, branchmap=self.branchmap)
+ branches = set(self.repo[i].branch() for i in self.repo)
+ self.assertEquals(sorted(branches), ['default', 'feature'])
+
def test_tagmap(self):
repo_path = self.load_svndump('basic_tag_tests.svndump')
tagmap = open(self.tagmap, 'w')