comparison tests/test_tags.py @ 1106:5cb6c95e0283 stable

Merge default and stable so I can do stable releases again.
author Augie Fackler <raf@durin42.com>
date Tue, 11 Feb 2014 12:48:49 -0500
parents 6e1dbf6cbc92
children f06bb42bd2b2
comparison
equal deleted inserted replaced
1020:b5b1fce26f1f 1106:5cb6c95e0283
6 from mercurial import commands 6 from mercurial import commands
7 from mercurial import hg 7 from mercurial import hg
8 from mercurial import node 8 from mercurial import node
9 from mercurial import ui 9 from mercurial import ui
10 10
11 from hgsubversion import compathacks
11 from hgsubversion import svncommands 12 from hgsubversion import svncommands
12 from hgsubversion import svnrepo 13 from hgsubversion import svnrepo
13 14
14 class TestTags(test_util.TestBase): 15 class TestTags(test_util.TestBase):
15 def test_tags(self, stupid=False): 16 stupid_mode_tests = True
16 repo = self._load_fixture_and_fetch('basic_tag_tests.svndump', 17
17 stupid=stupid) 18 def test_tags(self):
19 repo = self._load_fixture_and_fetch('basic_tag_tests.svndump')
18 self.assertEqual(sorted(repo.tags()), ['copied_tag', 'tag_r3', 'tip']) 20 self.assertEqual(sorted(repo.tags()), ['copied_tag', 'tag_r3', 'tip'])
19 self.assertEqual(repo['tag_r3'], repo['copied_tag']) 21 self.assertEqual(repo['tag_r3'], repo['copied_tag'])
20 self.assertEqual(repo['tag_r3'].rev(), 1) 22 self.assertEqual(repo['tag_r3'].rev(), 1)
21 23
22 def test_tags_stupid(self): 24 def test_remove_tag(self):
23 self.test_tags(stupid=True) 25 repo = self._load_fixture_and_fetch('remove_tag_test.svndump')
24
25 def test_remove_tag(self, stupid=False):
26 repo = self._load_fixture_and_fetch('remove_tag_test.svndump',
27 stupid=stupid)
28 self.assertEqual(repo['tag_r3'].rev(), 1) 26 self.assertEqual(repo['tag_r3'].rev(), 1)
29 self.assert_('copied_tag' not in repo.tags()) 27 self.assert_('copied_tag' not in repo.tags())
30 28
31 def test_remove_tag_stupid(self): 29 def test_rename_tag(self):
32 self.test_remove_tag(stupid=True)
33
34 def test_rename_tag(self, stupid=False):
35 expected = """\ 30 expected = """\
36 node: hg=default@2:svn=trunk@4 31 node: hg=default@2:svn=trunk@4
37 tagging r3 32 tagging r3
38 tag_r3: hg=default@1:svn=trunk@3 33 tag_r3: hg=default@1:svn=trunk@3
39 34
47 tag_r3: hg=default@1:svn=trunk@3 42 tag_r3: hg=default@1:svn=trunk@3
48 copied_tag: hg=default@1:svn=trunk@3 43 copied_tag: hg=default@1:svn=trunk@3
49 copied_tag: hg=default@-1:svn=unk@unk 44 copied_tag: hg=default@-1:svn=unk@unk
50 other_tag_r3: hg=default@1:svn=trunk@3 45 other_tag_r3: hg=default@1:svn=trunk@3
51 """ 46 """
52 self._test_tags('rename_tag_test.svndump', expected, stupid) 47 self._test_tags('rename_tag_test.svndump', expected)
53 48
54 def test_rename_tag_stupid(self): 49 def test_branch_from_tag(self):
55 self.test_rename_tag(stupid=True) 50 repo = self._load_fixture_and_fetch('branch_from_tag.svndump')
56 51 self.assert_('branch_from_tag' in compathacks.branchset(repo))
57 def test_branch_from_tag(self, stupid=False):
58 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
59 stupid=stupid)
60 self.assert_('branch_from_tag' in repo.branchtags())
61 self.assertEqual(repo[1], repo['tag_r3']) 52 self.assertEqual(repo[1], repo['tag_r3'])
62 self.assertEqual(repo['branch_from_tag'].parents()[0], repo['copied_tag']) 53 self.assertEqual(repo['branch_from_tag'].parents()[0], repo['copied_tag'])
63 54
64 def test_branch_from_tag_stupid(self): 55 def test_tag_by_renaming_branch(self):
65 self.test_branch_from_tag(stupid=True) 56 repo = self._load_fixture_and_fetch('tag_by_rename_branch.svndump')
66
67 def test_tag_by_renaming_branch(self, stupid=False):
68 repo = self._load_fixture_and_fetch('tag_by_rename_branch.svndump',
69 stupid=stupid)
70 branches = set(repo[h] for h in repo.heads()) 57 branches = set(repo[h] for h in repo.heads())
71 self.assert_('dummy' not in branches) 58 self.assert_('dummy' not in branches)
72 self.assertEqual(repo['dummy'], repo['tip'].parents()[0], 59 self.assertEqual(repo['dummy'], repo['tip'].parents()[0],
73 '%r != %r[0]' % (repo['dummy'], 60 '%r != %r[0]' % (repo['dummy'],
74 repo['tip'].parents())) 61 repo['tip'].parents()))
75 extra = repo['tip'].extra().copy() 62 extra = repo['tip'].extra().copy()
76 extra.pop('convert_revision', None) 63 extra.pop('convert_revision', None)
77 self.assertEqual(extra, {'branch': 'dummy', 'close': '1'}) 64 self.assertEqual(extra, {'branch': 'dummy', 'close': '1'})
78
79 def test_tag_by_renaming_branch_stupid(self):
80 self.test_tag_by_renaming_branch(stupid=True)
81 65
82 def test_deletion_of_tag_on_trunk_after_branching(self): 66 def test_deletion_of_tag_on_trunk_after_branching(self):
83 repo = self._load_fixture_and_fetch('tag_deletion_tag_branch.svndump') 67 repo = self._load_fixture_and_fetch('tag_deletion_tag_branch.svndump')
84 branches = set(repo[h].extra()['branch'] for h in repo.heads()) 68 branches = set(repo[h].extra()['branch'] for h in repo.heads())
85 self.assertEqual(branches, set(['default', 'from_2', ])) 69 self.assertEqual(branches, set(['default', 'from_2', ]))
99 tags, 83 tags,
100 {'blah/trunktag': '\xd3$@\xd7\xd8Nu\xce\xa6%\xf1u\xd9b\x1a\xb2\x81\xc2\xb0\xb1', 84 {'blah/trunktag': '\xd3$@\xd7\xd8Nu\xce\xa6%\xf1u\xd9b\x1a\xb2\x81\xc2\xb0\xb1',
101 'versions/branch_version': 'I\x89\x1c>z#\xfc._K#@:\xd6\x1f\x96\xd6\x83\x1b|', 85 'versions/branch_version': 'I\x89\x1c>z#\xfc._K#@:\xd6\x1f\x96\xd6\x83\x1b|',
102 }) 86 })
103 87
104 def test_most_recent_is_edited_stupid(self): 88 def test_most_recent_is_edited(self):
105 self.test_most_recent_is_edited(True) 89 repo, repo_path = self.load_and_fetch('most-recent-is-edit-tag.svndump')
106
107 def test_most_recent_is_edited(self, stupid=False):
108 repo, repo_path = self.load_and_fetch('most-recent-is-edit-tag.svndump',
109 stupid=stupid)
110 self.repo.ui.status( 90 self.repo.ui.status(
111 "Note: this test failing may be because of a rebuildmeta failure.\n" 91 "Note: this test failing may be because of a rebuildmeta failure.\n"
112 "You should check that before assuming issues with this test.\n") 92 "You should check that before assuming issues with this test.\n")
113 wc2_path = self.wc_path + '2' 93 wc2_path = self.wc_path + '2'
114 src, dest = test_util.hgclone(repo.ui, self.wc_path, wc2_path, update=False) 94 src, dest = test_util.hgclone(repo.ui, self.wc_path, wc2_path, update=False)
115 dest = test_util.getlocalpeer(dest) 95 dest = test_util.getlocalpeer(dest)
116 svncommands.rebuildmeta(repo.ui, 96 svncommands.rebuildmeta(repo.ui,
117 dest, 97 dest,
118 args=[test_util.fileurl(repo_path), ]) 98 args=[test_util.fileurl(repo_path), ])
119 commands.pull(self.repo.ui, self.repo, stupid=stupid) 99 commands.pull(self.repo.ui, self.repo)
120 dtags, srctags = dest.tags(), self.repo.tags() 100 dtags, srctags = dest.tags(), self.repo.tags()
121 dtags.pop('tip') 101 dtags.pop('tip')
122 srctags.pop('tip') 102 srctags.pop('tip')
123 self.assertEqual(dtags, srctags) 103 self.assertEqual(dtags, srctags)
124 self.assertEqual(dest.heads(), self.repo.heads()) 104 self.assertEqual(dest.heads(), self.repo.heads())
125 105
126 def test_edited_tag_stupid(self): 106 def test_edited_tag(self):
127 self.test_edited_tag(True) 107 repo = self._load_fixture_and_fetch('commit-to-tag.svndump')
128
129 def test_edited_tag(self, stupid=False):
130 repo = self._load_fixture_and_fetch('commit-to-tag.svndump',
131 stupid=stupid)
132 headcount = 6 108 headcount = 6
133 self.assertEqual(len(repo.heads()), headcount) 109 self.assertEqual(len(repo.heads()), headcount)
134 heads = repo.heads() 110 heads = repo.heads()
135 openheads = [h for h in heads if not repo[h].extra().get('close', False)] 111 openheads = [h for h in heads if not repo[h].extra().get('close', False)]
136 closedheads = set(heads) - set(openheads) 112 closedheads = set(heads) - set(openheads)
219 for line in ctx['.hgtags'].data().splitlines(False): 195 for line in ctx['.hgtags'].data().splitlines(False):
220 node, name = line.split(None, 1) 196 node, name = line.split(None, 1)
221 w(' %s: %s\n' % (name, formatnode(repo[node]))) 197 w(' %s: %s\n' % (name, formatnode(repo[node])))
222 w('\n') 198 w('\n')
223 199
224 def _test_tags(self, testpath, expected, stupid=False): 200 def _test_tags(self, testpath, expected):
225 repo = self._load_fixture_and_fetch(testpath, stupid=stupid) 201 repo = self._load_fixture_and_fetch(testpath)
226 fp = cStringIO.StringIO() 202 fp = cStringIO.StringIO()
227 for r in repo: 203 for r in repo:
228 self._debug_print_tags(repo, repo[r], fp=fp) 204 self._debug_print_tags(repo, repo[r], fp=fp)
229 output = fp.getvalue().strip() 205 output = fp.getvalue().strip()
230 expected = expected.strip() 206 expected = expected.strip()
233 expected = expected.splitlines() 209 expected = expected.splitlines()
234 output = output.splitlines() 210 output = output.splitlines()
235 diff = difflib.unified_diff(expected, output, 'expected', 'output') 211 diff = difflib.unified_diff(expected, output, 'expected', 'output')
236 self.assert_(False, '\n' + '\n'.join(diff)) 212 self.assert_(False, '\n' + '\n'.join(diff))
237 213
238 def test_tagging_into_tag(self, stupid=False): 214 def test_tagging_into_tag(self):
239 expected = """\ 215 expected = """\
240 node: hg=test@2:svn=branches/test@4 216 node: hg=test@2:svn=branches/test@4
241 First tag. 217 First tag.
242 test-0.1: hg=test@1:svn=branches/test@3 218 test-0.1: hg=test@1:svn=branches/test@3
243 219
269 test-0.1-real: hg=test@1:svn=branches/test@3 245 test-0.1-real: hg=test@1:svn=branches/test@3
270 test-0.1: hg=default@-1:svn=unk@unk 246 test-0.1: hg=default@-1:svn=unk@unk
271 test-0.1-real: hg=default@-1:svn=unk@unk 247 test-0.1-real: hg=default@-1:svn=unk@unk
272 test-0.1: hg=test@1:svn=branches/test@3 248 test-0.1: hg=test@1:svn=branches/test@3
273 """ 249 """
274 self._test_tags('renametagdir.svndump', expected, stupid=stupid) 250 self._test_tags('renametagdir.svndump', expected)
275
276 def test_tagging_into_tag_stupid(self):
277 self.test_tagging_into_tag(True)
278
279
280 def suite():
281 return unittest.TestLoader().loadTestsFromTestCase(TestTags)