diff tests/test_fetch_mappings.py @ 574:8e025a6f0db4

add basic branchmap functionality, to rename branches
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 01 Mar 2010 22:10:18 +0100
parents 2851b81c65ce
children d96aa92d9ad9
line wrap: on
line diff
--- a/tests/test_fetch_mappings.py
+++ b/tests/test_fetch_mappings.py
@@ -20,6 +20,10 @@ class MapTests(test_util.TestBase):
     def filemap(self):
         return os.path.join(self.tmpdir, 'filemap')
 
+    @property
+    def branchmap(self):
+        return os.path.join(self.tmpdir, 'branchmap')
+
     def test_author_map(self, stupid=False):
         test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
         authormap = open(self.authors, 'w')
@@ -101,6 +105,25 @@ class MapTests(test_util.TestBase):
     def test_file_map_exclude_stupid(self):
         self.test_file_map_exclude(True)
 
+    def test_branchmap(self, stupid=False):
+        test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump')
+        branchmap = open(self.branchmap, 'w')
+        branchmap.write("badname = good-name # stuffy\n")
+        branchmap.write("feature = default\n")
+        branchmap.close()
+        _ui = ui.ui()
+        _ui.setconfig('hgsubversion', 'stupid', str(stupid))
+        _ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
+        commands.clone(_ui, test_util.fileurl(self.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_stupid(self):
+        self.test_branchmap(True)
+
 
 def suite():
     return unittest.TestLoader().loadTestsFromTestCase(MapTests)