diff options
author | Qijiang Fan <fqj1994@gmail.com> | 2012-11-15 17:11:37 +0800 |
---|---|---|
committer | Qijiang Fan <fqj1994@gmail.com> | 2012-11-15 17:11:37 +0800 |
commit | 206ab31e9e0aae6866a27511724298dd00a7d90e (patch) | |
tree | 651928c31b80fee0b7cd4a6213e8c7642e615a7a /tests/test_fetch_mappings.py | |
parent | 41ab46d551a1287a4dfb60d04e132af468923d95 (diff) |
Upstream version 1.5
Diffstat (limited to 'tests/test_fetch_mappings.py')
-rw-r--r-- | tests/test_fetch_mappings.py | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/tests/test_fetch_mappings.py b/tests/test_fetch_mappings.py index 02727f6..267515c 100644 --- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -13,6 +13,7 @@ from mercurial import util as hgutil from hgsubversion import maps from hgsubversion import svncommands from hgsubversion import util +from hgsubversion import verify class MapTests(test_util.TestBase): @property @@ -100,49 +101,43 @@ class MapTests(test_util.TestBase): all_tests = set(test) self.assertEqual(fromself.symmetric_difference(all_tests), set()) - def test_file_map(self, stupid=False): - repo_path = self.load_svndump('replace_trunk_with_branch.svndump') + def _loadwithfilemap(self, svndump, filemapcontent, stupid=False, + failonmissing=True): + repo_path = self.load_svndump(svndump) filemap = open(self.filemap, 'w') - filemap.write("include alpha\n") + filemap.write(filemapcontent) filemap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'filemap', self.filemap) + ui.setconfig('hgsubversion', 'failoninvalidreplayfile', 'true') + ui.setconfig('hgsubversion', 'failonmissing', failonmissing) commands.clone(ui, test_util.fileurl(repo_path), self.wc_path, filemap=self.filemap) - self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') - self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') + return self.repo + + def test_file_map(self, stupid=False): + repo = self._loadwithfilemap('replace_trunk_with_branch.svndump', + "include alpha\n", stupid) + self.assertEqual(node.hex(repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') + self.assertEqual(node.hex(repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') def test_file_map_stupid(self): # TODO: re-enable test if we ever reinstate this feature self.assertRaises(hgutil.Abort, self.test_file_map, True) def test_file_map_exclude(self, stupid=False): - repo_path = self.load_svndump('replace_trunk_with_branch.svndump') - filemap = open(self.filemap, 'w') - filemap.write("exclude alpha\n") - filemap.close() - ui = self.ui(stupid) - ui.setconfig('hgsubversion', 'filemap', self.filemap) - commands.clone(ui, test_util.fileurl(repo_path), - self.wc_path, filemap=self.filemap) - self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') - self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') + repo = self._loadwithfilemap('replace_trunk_with_branch.svndump', + "exclude alpha\n", stupid) + self.assertEqual(node.hex(repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') + self.assertEqual(node.hex(repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') def test_file_map_exclude_stupid(self): # TODO: re-enable test if we ever reinstate this feature self.assertRaises(hgutil.Abort, self.test_file_map_exclude, True) def test_file_map_rule_order(self): - repo_path = self.load_svndump('replace_trunk_with_branch.svndump') - filemap = open(self.filemap, 'w') - filemap.write("exclude alpha\n") - filemap.write("include .\n") - filemap.write("exclude gamma\n") - filemap.close() - ui = self.ui(False) - ui.setconfig('hgsubversion', 'filemap', self.filemap) - commands.clone(ui, test_util.fileurl(repo_path), - self.wc_path, filemap=self.filemap) + repo = self._loadwithfilemap('replace_trunk_with_branch.svndump', + "exclude alpha\ninclude .\nexclude gamma\n") # 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. @@ -151,6 +146,33 @@ class MapTests(test_util.TestBase): self.assertEqual(self.repo['default'].manifest().keys(), ['alpha', 'beta']) + def test_file_map_copy(self): + # Exercise excluding files copied from a non-excluded directory. + # There will be missing files as we are copying from an excluded + # directory. + repo = self._loadwithfilemap('copies.svndump', "exclude dir2\n", + failonmissing=False) + self.assertEqual(['dir/a', 'dir3/a'], list(repo[2])) + + def test_file_map_exclude_copy_source_and_dest(self): + # dir3 is excluded and copied from dir2 which is also excluded. + # dir3 files should not be marked as missing and fetched. + repo = self._loadwithfilemap('copies.svndump', + "exclude dir2\nexclude dir3\n") + self.assertEqual(['dir/a'], list(repo[2])) + + def test_file_map_include_file_exclude_dir(self): + # dir3 is excluded but we want dir3/a, which is also copied from + # an exluded dir2. dir3/a should be fetched. + repo = self._loadwithfilemap('copies.svndump', + "include .\nexclude dir2\nexclude dir3\ninclude dir3/a\n", + failonmissing=False) + self.assertEqual(['dir/a', 'dir3/a'], list(repo[2])) + + def test_file_map_delete_dest(self): + repo = self._loadwithfilemap('copies.svndump', 'exclude dir3\n') + self.assertEqual(['dir/a', 'dir2/a'], list(repo[3])) + def test_branchmap(self, stupid=False): repo_path = self.load_svndump('branchmap.svndump') branchmap = open(self.branchmap, 'w') @@ -244,6 +266,8 @@ class MapTests(test_util.TestBase): ui = self.ui(stupid) src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone', update=False) + src = test_util.getlocalpeer(src) + dest = test_util.getlocalpeer(dest) svncommands.rebuildmeta(ui, dest, args=[test_util.fileurl(repo_path)]) @@ -270,7 +294,7 @@ class MapTests(test_util.TestBase): repo = self.repo for r in repo: - self.assertEquals(svncommands.verify(ui, repo, rev=r), 0) + self.assertEquals(verify.verify(ui, repo, rev=r), 0) def test_branchmap_verify_stupid(self): '''test verify on a branchmapped clone (stupid)''' |