comparison tests/test_tags.py @ 124:291925677a9f

tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
author Luke Opperman <luke@loppear.com>
date Thu, 04 Dec 2008 13:10:40 -0600
parents a3b717e4abf5
children 2242dd1163c6
comparison
equal deleted inserted replaced
123:58de7aea8a77 124:291925677a9f
5 from mercurial import ui 5 from mercurial import ui
6 6
7 import test_util 7 import test_util
8 8
9 import svncommand 9 import svncommand
10 import tag_repo
10 11
11 class TestTags(test_util.TestBase): 12 class TestTags(test_util.TestBase):
12 def _load_fixture_and_fetch(self, fixture_name, stupid=False): 13 def _load_fixture_and_fetch(self, fixture_name, stupid=False):
13 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, 14 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
14 self.wc_path, stupid=stupid) 15 self.wc_path, stupid=stupid)
16
17 def getrepo(self):
18 ui_ = ui.ui()
19 repo = hg.repository(ui_, self.wc_path)
20 repo.__class__ = tag_repo.generate_repo_class(ui_, repo)
21 return repo
15 22
16 def _test_tag_revision_info(self, repo): 23 def _test_tag_revision_info(self, repo):
17 self.assertEqual(node.hex(repo[0].node()), 24 self.assertEqual(node.hex(repo[0].node()),
18 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') 25 'a47d0ce778660a91c31bf2c21c448e9ee296ac90')
19 self.assertEqual(node.hex(repo['tip'].node()), 26 self.assertEqual(node.hex(repo['tip'].node()),
22 29
23 def test_tags(self, stupid=False): 30 def test_tags(self, stupid=False):
24 repo = self._load_fixture_and_fetch('basic_tag_tests.svndump', 31 repo = self._load_fixture_and_fetch('basic_tag_tests.svndump',
25 stupid=stupid) 32 stupid=stupid)
26 self._test_tag_revision_info(repo) 33 self._test_tag_revision_info(repo)
27 svncommand.generate_hg_tags(ui.ui(), self.wc_path) 34 repo = self.getrepo()
28 repo = hg.repository(ui.ui(), self.wc_path)
29 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node()) 35 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
30 self.assertEqual(repo['tip'].node(), repo['tag/copied_tag'].node()) 36 self.assertEqual(repo['tip'].node(), repo['tag/copied_tag'].node())
31 37
32 def test_tags_stupid(self): 38 def test_tags_stupid(self):
33 self.test_tags(stupid=True) 39 self.test_tags(stupid=True)
34 40
35 def test_remove_tag(self, stupid=False): 41 def test_remove_tag(self, stupid=False):
36 repo = self._load_fixture_and_fetch('remove_tag_test.svndump', 42 repo = self._load_fixture_and_fetch('remove_tag_test.svndump',
37 stupid=stupid) 43 stupid=stupid)
38 self._test_tag_revision_info(repo) 44 self._test_tag_revision_info(repo)
39 svncommand.generate_hg_tags(ui.ui(), self.wc_path) 45 repo = self.getrepo()
40 repo = hg.repository(ui.ui(), self.wc_path)
41 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node()) 46 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
42 self.assert_('tag/copied_tag' not in repo.tags()) 47 self.assert_('tag/copied_tag' not in repo.tags())
43 48
44 def test_remove_tag_stupid(self): 49 def test_remove_tag_stupid(self):
45 self.test_remove_tag(stupid=True) 50 self.test_remove_tag(stupid=True)
46 51
47 def test_rename_tag(self, stupid=False): 52 def test_rename_tag(self, stupid=False):
48 repo = self._load_fixture_and_fetch('rename_tag_test.svndump', 53 repo = self._load_fixture_and_fetch('rename_tag_test.svndump',
49 stupid=stupid) 54 stupid=stupid)
50 self._test_tag_revision_info(repo) 55 self._test_tag_revision_info(repo)
51 svncommand.generate_hg_tags(ui.ui(), self.wc_path) 56 repo = self.getrepo()
52 repo = hg.repository(ui.ui(), self.wc_path)
53 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node()) 57 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
54 self.assertEqual(repo['tip'].node(), repo['tag/other_tag_r3'].node()) 58 self.assertEqual(repo['tip'].node(), repo['tag/other_tag_r3'].node())
55 self.assert_('tag/copied_tag' not in repo.tags()) 59 self.assert_('tag/copied_tag' not in repo.tags())
56 60
57 def test_rename_tag_stupid(self): 61 def test_rename_tag_stupid(self):
58 self.test_rename_tag(stupid=True) 62 self.test_rename_tag(stupid=True)
59 63
60 def test_branch_from_tag(self, stupid=False): 64 def test_branch_from_tag(self, stupid=False):
61 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', 65 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
62 stupid=stupid) 66 stupid=stupid)
63 svncommand.generate_hg_tags(ui.ui(), self.wc_path) 67 repo = self.getrepo()
64 repo = hg.repository(ui.ui(), self.wc_path)
65 self.assertEqual(repo['tip'].node(), repo['branch_from_tag'].node()) 68 self.assertEqual(repo['tip'].node(), repo['branch_from_tag'].node())
66 self.assertEqual(repo[1].node(), repo['tag/tag_r3'].node()) 69 self.assertEqual(repo[1].node(), repo['tag/tag_r3'].node())
67 self.assertEqual(repo['branch_from_tag'].parents()[0].node(), 70 self.assertEqual(repo['branch_from_tag'].parents()[0].node(),
68 repo['tag/copied_tag'].node()) 71 repo['tag/copied_tag'].node())
69 72
71 self.test_branch_from_tag(stupid=True) 74 self.test_branch_from_tag(stupid=True)
72 75
73 def test_tag_by_renaming_branch(self, stupid=False): 76 def test_tag_by_renaming_branch(self, stupid=False):
74 repo = self._load_fixture_and_fetch('tag_by_rename_branch.svndump', 77 repo = self._load_fixture_and_fetch('tag_by_rename_branch.svndump',
75 stupid=stupid) 78 stupid=stupid)
76 svncommand.generate_hg_tags(ui.ui(), self.wc_path) 79 repo = self.getrepo()
77 repo = hg.repository(ui.ui(), self.wc_path)
78 self.assertEqual(node.hex(repo['tip'].node()), 80 self.assertEqual(node.hex(repo['tip'].node()),
79 '1b941f92acc343939274bd8bbf25984fa9706bb9') 81 '1b941f92acc343939274bd8bbf25984fa9706bb9')
80 self.assertEqual(node.hex(repo['tag/dummy'].node()), 82 self.assertEqual(node.hex(repo['tag/dummy'].node()),
81 '68f5f7d82b00a2efe3aca28b615ebab98235d55f') 83 '68f5f7d82b00a2efe3aca28b615ebab98235d55f')
82 84