comparison tests/test_fetch_command.py @ 1570:d55c9d0ba350

tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
author Paul Morelle <paul.morelle@octobus.net>
date Fri, 25 May 2018 11:52:03 +0200
parents 86ae03f889a4
children 68965b2e3401
comparison
equal deleted inserted replaced
1569:4afe8d7e4602 1570:d55c9d0ba350
8 from mercurial import hg 8 from mercurial import hg
9 from mercurial import node 9 from mercurial import node
10 from mercurial import ui 10 from mercurial import ui
11 from mercurial import encoding 11 from mercurial import encoding
12 12
13 revsymbol = test_util.revsymbol
14
13 class TestBasicRepoLayout(test_util.TestBase): 15 class TestBasicRepoLayout(test_util.TestBase):
14 stupid_mode_tests = True 16 stupid_mode_tests = True
15 17
16 def test_no_dates(self): 18 def test_no_dates(self):
17 repo = self._load_fixture_and_fetch('test_no_dates.svndump') 19 repo = self._load_fixture_and_fetch('test_no_dates.svndump')
19 self.assertEqual(local_epoch[0], local_epoch[1]) 21 self.assertEqual(local_epoch[0], local_epoch[1])
20 self.assertEqual(repo[1].date(), repo[2].date()) 22 self.assertEqual(repo[1].date(), repo[2].date())
21 23
22 def test_fresh_fetch_single_rev(self): 24 def test_fresh_fetch_single_rev(self):
23 repo = self._load_fixture_and_fetch('single_rev.svndump') 25 repo = self._load_fixture_and_fetch('single_rev.svndump')
24 self.assertEqual(node.hex(repo['tip'].node()), 26 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
25 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') 27 '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
26 self.assertEqual(repo['tip'].extra()['convert_revision'], 28 self.assertEqual(revsymbol(repo, 'tip').extra()['convert_revision'],
27 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@2') 29 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@2')
28 self.assertEqual(repo['tip'], repo[0]) 30 self.assertEqual(revsymbol(repo, 'tip'), repo[0])
29 31
30 def test_fresh_fetch_two_revs(self): 32 def test_fresh_fetch_two_revs(self):
31 repo = self._load_fixture_and_fetch('two_revs.svndump') 33 repo = self._load_fixture_and_fetch('two_revs.svndump')
32 self.assertEqual(node.hex(repo[0].node()), 34 self.assertEqual(node.hex(repo[0].node()),
33 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') 35 '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
34 self.assertEqual(node.hex(repo['tip'].node()), 36 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
35 'c95251e0dd04697deee99b79cc407d7db76e6a5f') 37 'c95251e0dd04697deee99b79cc407d7db76e6a5f')
36 self.assertEqual(repo['tip'], repo[1]) 38 self.assertEqual(revsymbol(repo, 'tip'), repo[1])
37 39
38 def test_branches(self): 40 def test_branches(self):
39 repo = self._load_fixture_and_fetch('simple_branch.svndump') 41 repo = self._load_fixture_and_fetch('simple_branch.svndump')
40 self.assertEqual(node.hex(repo[0].node()), 42 self.assertEqual(node.hex(repo[0].node()),
41 'a1ff9f5d90852ce7f8e607fa144066b0a06bdc57') 43 'a1ff9f5d90852ce7f8e607fa144066b0a06bdc57')
42 self.assertEqual(node.hex(repo['tip'].node()), 44 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
43 '545e36ed13615e39c5c8fb0c325109d8cb8e00c3') 45 '545e36ed13615e39c5c8fb0c325109d8cb8e00c3')
44 self.assertEqual(len(repo['tip'].parents()), 1) 46 self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
45 self.assertEqual(repo['tip'].parents()[0], repo['default']) 47 self.assertEqual(revsymbol(repo, 'tip').parents()[0], revsymbol(repo, 'default'))
46 self.assertEqual(repo['tip'].extra()['convert_revision'], 48 self.assertEqual(revsymbol(repo, 'tip').extra()['convert_revision'],
47 'svn:3cd547df-371e-4add-bccf-aba732a2baf5/branches/the_branch@4') 49 'svn:3cd547df-371e-4add-bccf-aba732a2baf5/branches/the_branch@4')
48 self.assertEqual(repo['default'].extra()['convert_revision'], 50 self.assertEqual(revsymbol(repo, 'default').extra()['convert_revision'],
49 'svn:3cd547df-371e-4add-bccf-aba732a2baf5/trunk@3') 51 'svn:3cd547df-371e-4add-bccf-aba732a2baf5/trunk@3')
50 self.assertEqual(len(repo.heads()), 1) 52 self.assertEqual(len(repo.heads()), 1)
51 53
52 def test_two_branches_with_heads(self): 54 def test_two_branches_with_heads(self):
53 repo = self._load_fixture_and_fetch('two_heads.svndump') 55 repo = self._load_fixture_and_fetch('two_heads.svndump')
54 self.assertEqual(node.hex(repo[0].node()), 56 self.assertEqual(node.hex(repo[0].node()),
55 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') 57 '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
56 self.assertEqual(node.hex(repo['tip'].node()), 58 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
57 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') 59 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f')
58 self.assertEqual(node.hex(repo['the_branch'].node()), 60 self.assertEqual(node.hex(revsymbol(repo, 'the_branch').node()),
59 '4e256962fc5df545e2e0a51d0d1dc61c469127e6') 61 '4e256962fc5df545e2e0a51d0d1dc61c469127e6')
60 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), 62 self.assertEqual(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()),
61 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') 63 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
62 self.assertEqual(len(repo['tip'].parents()), 1) 64 self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
63 self.assertEqual(repo['tip'], repo['default']) 65 self.assertEqual(revsymbol(repo, 'tip'), revsymbol(repo, 'default'))
64 self.assertEqual(len(repo.heads()), 2) 66 self.assertEqual(len(repo.heads()), 2)
65 67
66 def test_many_special_cases(self): 68 def test_many_special_cases(self):
67 repo = self._load_fixture_and_fetch('many_special_cases.svndump') 69 repo = self._load_fixture_and_fetch('many_special_cases.svndump')
68 70
69 self.assertEquals(node.hex(repo[0].node()), 71 self.assertEquals(node.hex(repo[0].node()),
70 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') 72 '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
71 # two possible hashes for bw compat to hg < 1.5, since hg 1.5 73 # two possible hashes for bw compat to hg < 1.5, since hg 1.5
72 # sorts entries in extra() 74 # sorts entries in extra()
73 self.assertTrue(node.hex(repo['tip'].node()) in 75 self.assertTrue(node.hex(revsymbol(repo, 'tip').node()) in
74 ('e92012d8c170a0236c84166167f149c2e28548c6', 76 ('e92012d8c170a0236c84166167f149c2e28548c6',
75 'b7bdc73041b1852563deb1ef3f4153c2fe4484f2')) 77 'b7bdc73041b1852563deb1ef3f4153c2fe4484f2'))
76 self.assertEqual(node.hex(repo['the_branch'].node()), 78 self.assertEqual(node.hex(revsymbol(repo, 'the_branch').node()),
77 '4e256962fc5df545e2e0a51d0d1dc61c469127e6') 79 '4e256962fc5df545e2e0a51d0d1dc61c469127e6')
78 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), 80 self.assertEqual(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()),
79 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') 81 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
80 self.assertEqual(len(repo['tip'].parents()), 1) 82 self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
81 self.assertEqual(repo['tip'], repo['default']) 83 self.assertEqual(revsymbol(repo, 'tip'), revsymbol(repo, 'default'))
82 self.assertEqual(len(repo.heads()), 2) 84 self.assertEqual(len(repo.heads()), 2)
83 85
84 def test_file_mixed_with_branches(self): 86 def test_file_mixed_with_branches(self):
85 repo = self._load_fixture_and_fetch('file_mixed_with_branches.svndump') 87 repo = self._load_fixture_and_fetch('file_mixed_with_branches.svndump')
86 self.assertEqual(node.hex(repo['default'].node()), 88 self.assertEqual(node.hex(revsymbol(repo, 'default').node()),
87 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') 89 '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
88 assert 'README' not in repo 90 assert 'README' not in repo
89 assert '../branches' not in repo 91 assert '../branches' not in repo
90 92
91 def test_files_copied_from_outside_btt(self): 93 def test_files_copied_from_outside_btt(self):
92 repo = self._load_fixture_and_fetch( 94 repo = self._load_fixture_and_fetch(
93 'test_files_copied_from_outside_btt.svndump') 95 'test_files_copied_from_outside_btt.svndump')
94 self.assertEqual(node.hex(repo['tip'].node()), 96 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
95 '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') 97 '3c78170e30ddd35f2c32faa0d8646ab75bba4f73')
96 self.assertEqual(test_util.repolen(repo), 2) 98 self.assertEqual(test_util.repolen(repo), 2)
97 99
98 def test_file_renamed_in_from_outside_btt(self): 100 def test_file_renamed_in_from_outside_btt(self):
99 repo = self._load_fixture_and_fetch( 101 repo = self._load_fixture_and_fetch(
100 'file_renamed_in_from_outside_btt.svndump') 102 'file_renamed_in_from_outside_btt.svndump')
101 self.assert_('LICENSE.file' in repo['default']) 103 self.assert_('LICENSE.file' in revsymbol(repo, 'default'))
102 104
103 def test_renamed_dir_in_from_outside_btt_not_repo_root(self): 105 def test_renamed_dir_in_from_outside_btt_not_repo_root(self):
104 repo = self._load_fixture_and_fetch( 106 repo = self._load_fixture_and_fetch(
105 'fetch_missing_files_subdir.svndump', subdir='foo') 107 'fetch_missing_files_subdir.svndump', subdir='foo')
106 self.assertEqual(node.hex(repo['tip'].node()), 108 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
107 '269dcdd4361b2847e9f4288d4500e55d35df1f52') 109 '269dcdd4361b2847e9f4288d4500e55d35df1f52')
108 self.assert_('bar/alpha' in repo['tip']) 110 self.assert_('bar/alpha' in revsymbol(repo, 'tip'))
109 self.assert_('foo' in repo['tip']) 111 self.assert_('foo' in revsymbol(repo, 'tip'))
110 self.assert_('bar/alpha' not in repo['tip'].parents()[0]) 112 self.assert_('bar/alpha' not in revsymbol(repo, 'tip').parents()[0])
111 self.assert_('foo' in repo['tip'].parents()[0]) 113 self.assert_('foo' in revsymbol(repo, 'tip').parents()[0])
112 114
113 def test_oldest_not_trunk_and_tag_vendor_branch(self): 115 def test_oldest_not_trunk_and_tag_vendor_branch(self):
114 repo = self._load_fixture_and_fetch( 116 repo = self._load_fixture_and_fetch(
115 'tagged_vendor_and_oldest_not_trunk.svndump') 117 'tagged_vendor_and_oldest_not_trunk.svndump')
116 self.assertEqual(node.hex(repo['oldest'].node()), 118 self.assertEqual(node.hex(revsymbol(repo, 'oldest').node()),
117 '926671740dec045077ab20f110c1595f935334fa') 119 '926671740dec045077ab20f110c1595f935334fa')
118 self.assertEqual(repo['tip'].parents()[0].parents()[0], 120 self.assertEqual(revsymbol(repo, 'tip').parents()[0].parents()[0],
119 repo['oldest']) 121 revsymbol(repo, 'oldest'))
120 self.assertEqual(node.hex(repo['tip'].node()), 122 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
121 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') 123 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
122 124
123 def test_propedit_with_nothing_else(self): 125 def test_propedit_with_nothing_else(self):
124 repo = self._load_fixture_and_fetch('branch_prop_edit.svndump') 126 repo = self._load_fixture_and_fetch('branch_prop_edit.svndump')
125 self.assertEqual(repo['tip'].description(), 'Commit bogus propchange.') 127 self.assertEqual(revsymbol(repo, 'tip').description(), 'Commit bogus propchange.')
126 self.assertEqual(repo['tip'].branch(), 'dev_branch') 128 self.assertEqual(revsymbol(repo, 'tip').branch(), 'dev_branch')
127 129
128 def test_entry_deletion(self): 130 def test_entry_deletion(self):
129 repo = self._load_fixture_and_fetch('delentries.svndump') 131 repo = self._load_fixture_and_fetch('delentries.svndump')
130 files = list(sorted(repo['tip'].manifest())) 132 files = list(sorted(revsymbol(repo, 'tip').manifest()))
131 self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files) 133 self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files)
132 134
133 def test_fetch_when_trunk_has_no_files(self): 135 def test_fetch_when_trunk_has_no_files(self):
134 repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump') 136 repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump')
135 self.assertEqual(repo['tip'].branch(), 'default') 137 self.assertEqual(revsymbol(repo, 'tip').branch(), 'default')
136 138
137 def test_path_quoting(self): 139 def test_path_quoting(self):
138 repo_path = self.load_svndump('non_ascii_path_1.svndump') 140 repo_path = self.load_svndump('non_ascii_path_1.svndump')
139 subdir = '/b\xC3\xB8b' 141 subdir = '/b\xC3\xB8b'
140 quoted_subdir = urllib.quote(subdir) 142 quoted_subdir = urllib.quote(subdir)
148 commands.clone(ui, repo_url + subdir, wc_path) 150 commands.clone(ui, repo_url + subdir, wc_path)
149 commands.clone(ui, repo_url + quoted_subdir, wc2_path) 151 commands.clone(ui, repo_url + quoted_subdir, wc2_path)
150 repo = hg.repository(ui, wc_path) 152 repo = hg.repository(ui, wc_path)
151 repo2 = hg.repository(ui, wc2_path) 153 repo2 = hg.repository(ui, wc2_path)
152 154
153 self.assertEqual(repo['tip'].extra()['convert_revision'], 155 self.assertEqual(revsymbol(repo, 'tip').extra()['convert_revision'],
154 repo2['tip'].extra()['convert_revision']) 156 repo2['tip'].extra()['convert_revision'])
155 self.assertEqual(test_util.repolen(repo), test_util.repolen(repo2)) 157 self.assertEqual(test_util.repolen(repo), test_util.repolen(repo2))
156 158
157 for r in repo: 159 for r in repo:
158 self.assertEqual(repo[r].hex(), repo2[r].hex()) 160 self.assertEqual(repo[r].hex(), repo2[r].hex())
179 181
180 def test_stupid(self): 182 def test_stupid(self):
181 repo = self._load_fixture_and_fetch('two_heads.svndump') 183 repo = self._load_fixture_and_fetch('two_heads.svndump')
182 self.assertEqual(node.hex(repo[0].node()), 184 self.assertEqual(node.hex(repo[0].node()),
183 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') 185 '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
184 self.assertEqual(node.hex(repo['tip'].node()), 186 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
185 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') 187 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f')
186 self.assertEqual(node.hex(repo['the_branch'].node()), 188 self.assertEqual(node.hex(revsymbol(repo, 'the_branch').node()),
187 '4e256962fc5df545e2e0a51d0d1dc61c469127e6') 189 '4e256962fc5df545e2e0a51d0d1dc61c469127e6')
188 self.assertEqual(repo['the_branch'].extra()['convert_revision'], 190 self.assertEqual(revsymbol(repo, 'the_branch').extra()['convert_revision'],
189 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@5') 191 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@5')
190 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), 192 self.assertEqual(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()),
191 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') 193 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
192 self.assertEqual(len(repo['tip'].parents()), 1) 194 self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
193 self.assertEqual(repo['default'].extra()['convert_revision'], 195 self.assertEqual(revsymbol(repo, 'default').extra()['convert_revision'],
194 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@6') 196 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@6')
195 self.assertEqual(repo['tip'], repo['default']) 197 self.assertEqual(revsymbol(repo, 'tip'), revsymbol(repo, 'default'))
196 self.assertEqual(len(repo.heads()), 2) 198 self.assertEqual(len(repo.heads()), 2)
197 199
198 def test_oldest_not_trunk_and_tag_vendor_branch(self): 200 def test_oldest_not_trunk_and_tag_vendor_branch(self):
199 repo = self._load_fixture_and_fetch( 201 repo = self._load_fixture_and_fetch(
200 'tagged_vendor_and_oldest_not_trunk.svndump') 202 'tagged_vendor_and_oldest_not_trunk.svndump')
201 self.assertEqual(node.hex(repo['oldest'].node()), 203 self.assertEqual(node.hex(revsymbol(repo, 'oldest').node()),
202 '926671740dec045077ab20f110c1595f935334fa') 204 '926671740dec045077ab20f110c1595f935334fa')
203 self.assertEqual(repo['tip'].parents()[0].parents()[0], 205 self.assertEqual(revsymbol(repo, 'tip').parents()[0].parents()[0],
204 repo['oldest']) 206 revsymbol(repo, 'oldest'))
205 self.assertEqual(node.hex(repo['tip'].node()), 207 self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
206 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') 208 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
207 209
208 def test_empty_repo(self): 210 def test_empty_repo(self):
209 # This used to crash HgEditor because it could be closed without 211 # This used to crash HgEditor because it could be closed without
210 # having been initialized again. 212 # having been initialized again.