Mercurial > hgsubversion
comparison tests/test_fetch_command.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 | ca36d5915dc7 |
children | 86ae03f889a4 |
comparison
equal
deleted
inserted
replaced
1020:b5b1fce26f1f | 1106:5cb6c95e0283 |
---|---|
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 class TestBasicRepoLayout(test_util.TestBase): | 13 class TestBasicRepoLayout(test_util.TestBase): |
14 stupid_mode_tests = True | |
14 | 15 |
15 def test_no_dates(self): | 16 def test_no_dates(self): |
16 repo = self._load_fixture_and_fetch('test_no_dates.svndump') | 17 repo = self._load_fixture_and_fetch('test_no_dates.svndump') |
17 local_epoch = repo[0].date() | 18 local_epoch = repo[0].date() |
18 self.assertEqual(local_epoch[0], local_epoch[1]) | 19 self.assertEqual(local_epoch[0], local_epoch[1]) |
60 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') | 61 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') |
61 self.assertEqual(len(repo['tip'].parents()), 1) | 62 self.assertEqual(len(repo['tip'].parents()), 1) |
62 self.assertEqual(repo['tip'], repo['default']) | 63 self.assertEqual(repo['tip'], repo['default']) |
63 self.assertEqual(len(repo.heads()), 2) | 64 self.assertEqual(len(repo.heads()), 2) |
64 | 65 |
65 def test_many_special_cases_replay(self): | 66 def test_many_special_cases(self): |
66 repo = self._load_fixture_and_fetch('many_special_cases.svndump') | 67 repo = self._load_fixture_and_fetch('many_special_cases.svndump') |
67 self._many_special_cases_checks(repo) | 68 |
68 | |
69 | |
70 def test_many_special_cases_diff(self): | |
71 repo = self._load_fixture_and_fetch('many_special_cases.svndump', | |
72 stupid=True) | |
73 self._many_special_cases_checks(repo) | |
74 | |
75 def _many_special_cases_checks(self, repo): | |
76 self.assertEquals(node.hex(repo[0].node()), | 69 self.assertEquals(node.hex(repo[0].node()), |
77 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') | 70 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') |
78 # two possible hashes for bw compat to hg < 1.5, since hg 1.5 | 71 # two possible hashes for bw compat to hg < 1.5, since hg 1.5 |
79 # sorts entries in extra() | 72 # sorts entries in extra() |
80 self.assertTrue(node.hex(repo['tip'].node()) in | 73 self.assertTrue(node.hex(repo['tip'].node()) in |
93 self.assertEqual(node.hex(repo['default'].node()), | 86 self.assertEqual(node.hex(repo['default'].node()), |
94 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') | 87 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') |
95 assert 'README' not in repo | 88 assert 'README' not in repo |
96 assert '../branches' not in repo | 89 assert '../branches' not in repo |
97 | 90 |
98 def test_files_copied_from_outside_btt(self, stupid=False): | 91 def test_files_copied_from_outside_btt(self): |
99 repo = self._load_fixture_and_fetch( | 92 repo = self._load_fixture_and_fetch( |
100 'test_files_copied_from_outside_btt.svndump', stupid=stupid) | 93 'test_files_copied_from_outside_btt.svndump') |
101 self.assertEqual(node.hex(repo['tip'].node()), | 94 self.assertEqual(node.hex(repo['tip'].node()), |
102 '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') | 95 '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') |
103 self.assertEqual(len(repo.changelog), 2) | 96 self.assertEqual(test_util.repolen(repo.changelog), 2) |
104 | |
105 def test_files_copied_from_outside_btt_stupid(self): | |
106 self.test_files_copied_from_outside_btt(stupid=True) | |
107 | 97 |
108 def test_file_renamed_in_from_outside_btt(self): | 98 def test_file_renamed_in_from_outside_btt(self): |
109 repo = self._load_fixture_and_fetch( | 99 repo = self._load_fixture_and_fetch( |
110 'file_renamed_in_from_outside_btt.svndump') | 100 'file_renamed_in_from_outside_btt.svndump') |
111 self.assert_('LICENSE.file' in repo['default']) | 101 self.assert_('LICENSE.file' in repo['default']) |
128 self.assertEqual(repo['tip'].parents()[0].parents()[0], | 118 self.assertEqual(repo['tip'].parents()[0].parents()[0], |
129 repo['oldest']) | 119 repo['oldest']) |
130 self.assertEqual(node.hex(repo['tip'].node()), | 120 self.assertEqual(node.hex(repo['tip'].node()), |
131 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') | 121 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') |
132 | 122 |
133 def test_propedit_with_nothing_else(self, stupid=False): | 123 def test_propedit_with_nothing_else(self): |
134 repo = self._load_fixture_and_fetch('branch_prop_edit.svndump', | 124 repo = self._load_fixture_and_fetch('branch_prop_edit.svndump') |
135 stupid=stupid) | |
136 self.assertEqual(repo['tip'].description(), 'Commit bogus propchange.') | 125 self.assertEqual(repo['tip'].description(), 'Commit bogus propchange.') |
137 self.assertEqual(repo['tip'].branch(), 'dev_branch') | 126 self.assertEqual(repo['tip'].branch(), 'dev_branch') |
138 | 127 |
139 def test_propedit_with_nothing_else_stupid(self): | 128 def test_entry_deletion(self): |
140 self.test_propedit_with_nothing_else(stupid=True) | 129 repo = self._load_fixture_and_fetch('delentries.svndump') |
141 | |
142 def test_entry_deletion(self, stupid=False): | |
143 repo = self._load_fixture_and_fetch('delentries.svndump', | |
144 stupid=stupid) | |
145 files = list(sorted(repo['tip'].manifest())) | 130 files = list(sorted(repo['tip'].manifest())) |
146 self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files) | 131 self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files) |
147 | 132 |
148 def test_entry_deletion_stupid(self): | 133 def test_fetch_when_trunk_has_no_files(self): |
149 self.test_entry_deletion(stupid=True) | 134 repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump') |
150 | |
151 def test_fetch_when_trunk_has_no_files(self, stupid=False): | |
152 repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump', stupid=stupid) | |
153 self.assertEqual(repo['tip'].branch(), 'default') | 135 self.assertEqual(repo['tip'].branch(), 'default') |
154 | 136 |
155 def test_fetch_when_trunk_has_no_files_stupid(self): | 137 def test_path_quoting(self): |
156 self.test_fetch_when_trunk_has_no_files(stupid=True) | |
157 | |
158 def test_path_quoting(self, stupid=False): | |
159 repo_path = self.load_svndump('non_ascii_path_1.svndump') | 138 repo_path = self.load_svndump('non_ascii_path_1.svndump') |
160 subdir = '/b\xC3\xB8b' | 139 subdir = '/b\xC3\xB8b' |
161 quoted_subdir = urllib.quote(subdir) | 140 quoted_subdir = urllib.quote(subdir) |
162 | 141 |
163 repo_url = test_util.fileurl(repo_path) | 142 repo_url = test_util.fileurl(repo_path) |
164 wc_path = self.wc_path | 143 wc_path = self.wc_path |
165 wc2_path = wc_path + '-2' | 144 wc2_path = wc_path + '-2' |
166 | 145 |
167 ui = self.ui(stupid=stupid) | 146 ui = self.ui() |
168 | 147 |
169 commands.clone(ui, repo_url + subdir, wc_path) | 148 commands.clone(ui, repo_url + subdir, wc_path) |
170 commands.clone(ui, repo_url + quoted_subdir, wc2_path) | 149 commands.clone(ui, repo_url + quoted_subdir, wc2_path) |
171 repo = hg.repository(ui, wc_path) | 150 repo = hg.repository(ui, wc_path) |
172 repo2 = hg.repository(ui, wc2_path) | 151 repo2 = hg.repository(ui, wc2_path) |
173 | 152 |
174 self.assertEqual(repo['tip'].extra()['convert_revision'], | 153 self.assertEqual(repo['tip'].extra()['convert_revision'], |
175 repo2['tip'].extra()['convert_revision']) | 154 repo2['tip'].extra()['convert_revision']) |
176 self.assertEqual(len(repo), len(repo2)) | 155 self.assertEqual(test_util.repolen(repo), test_util.repolen(repo2)) |
177 | 156 |
178 for r in repo: | 157 for r in repo: |
179 self.assertEqual(repo[r].hex(), repo2[r].hex()) | 158 self.assertEqual(repo[r].hex(), repo2[r].hex()) |
180 | |
181 def test_path_quoting_stupid(self): | |
182 repo = self.test_path_quoting(True) | |
183 | |
184 | 159 |
185 def test_identical_fixtures(self): | 160 def test_identical_fixtures(self): |
186 '''ensure that the non_ascii_path_N fixtures are identical''' | 161 '''ensure that the non_ascii_path_N fixtures are identical''' |
187 fixturepaths = [ | 162 fixturepaths = [ |
188 os.path.join(test_util.FIXTURES, 'non_ascii_path_1.svndump'), | 163 os.path.join(test_util.FIXTURES, 'non_ascii_path_1.svndump'), |
198 self.assertEqual(desc.decode('utf8'), | 173 self.assertEqual(desc.decode('utf8'), |
199 u'bl\xe5b\xe6rgr\xf8d') | 174 u'bl\xe5b\xe6rgr\xf8d') |
200 | 175 |
201 | 176 |
202 class TestStupidPull(test_util.TestBase): | 177 class TestStupidPull(test_util.TestBase): |
178 stupid_mode_tests = True | |
179 | |
203 def test_stupid(self): | 180 def test_stupid(self): |
204 repo = self._load_fixture_and_fetch('two_heads.svndump', stupid=True) | 181 repo = self._load_fixture_and_fetch('two_heads.svndump') |
205 self.assertEqual(node.hex(repo[0].node()), | 182 self.assertEqual(node.hex(repo[0].node()), |
206 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') | 183 '434ed487136c1b47c1e8f952edb4dc5a8e6328df') |
207 self.assertEqual(node.hex(repo['tip'].node()), | 184 self.assertEqual(node.hex(repo['tip'].node()), |
208 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') | 185 '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') |
209 self.assertEqual(node.hex(repo['the_branch'].node()), | 186 self.assertEqual(node.hex(repo['the_branch'].node()), |
218 self.assertEqual(repo['tip'], repo['default']) | 195 self.assertEqual(repo['tip'], repo['default']) |
219 self.assertEqual(len(repo.heads()), 2) | 196 self.assertEqual(len(repo.heads()), 2) |
220 | 197 |
221 def test_oldest_not_trunk_and_tag_vendor_branch(self): | 198 def test_oldest_not_trunk_and_tag_vendor_branch(self): |
222 repo = self._load_fixture_and_fetch( | 199 repo = self._load_fixture_and_fetch( |
223 'tagged_vendor_and_oldest_not_trunk.svndump', | 200 'tagged_vendor_and_oldest_not_trunk.svndump') |
224 stupid=True) | |
225 self.assertEqual(node.hex(repo['oldest'].node()), | 201 self.assertEqual(node.hex(repo['oldest'].node()), |
226 '926671740dec045077ab20f110c1595f935334fa') | 202 '926671740dec045077ab20f110c1595f935334fa') |
227 self.assertEqual(repo['tip'].parents()[0].parents()[0], | 203 self.assertEqual(repo['tip'].parents()[0].parents()[0], |
228 repo['oldest']) | 204 repo['oldest']) |
229 self.assertEqual(node.hex(repo['tip'].node()), | 205 self.assertEqual(node.hex(repo['tip'].node()), |
230 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') | 206 '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') |
231 | 207 |
232 def test_empty_repo(self, stupid=False): | 208 def test_empty_repo(self): |
233 # This used to crash HgEditor because it could be closed without | 209 # This used to crash HgEditor because it could be closed without |
234 # having been initialized again. | 210 # having been initialized again. |
235 self._load_fixture_and_fetch('emptyrepo2.svndump', stupid=stupid) | 211 self._load_fixture_and_fetch('emptyrepo2.svndump') |
236 | 212 |
237 def test_empty_repo_stupid(self): | 213 def test_fetch_revert(self): |
238 self.test_empty_repo(stupid=True) | 214 repo = self._load_fixture_and_fetch('revert.svndump') |
239 | |
240 def test_fetch_revert(self, stupid=False): | |
241 repo = self._load_fixture_and_fetch('revert.svndump', stupid=stupid) | |
242 graph = self.getgraph(repo) | 215 graph = self.getgraph(repo) |
243 refgraph = """\ | 216 refgraph = """\ |
244 o changeset: 3:937dcd1206d4 | 217 o changeset: 3:937dcd1206d4 (r4) |
245 | branch: | 218 | branch: |
246 | tags: tip | 219 | tags: tip |
247 | summary: revert2 | 220 | summary: revert2 |
248 | files: a dir/b | 221 | files: a dir/b |
249 | | 222 | |
250 o changeset: 2:9317a748b7c3 | 223 o changeset: 2:9317a748b7c3 (r3) |
251 | branch: | 224 | branch: |
252 | tags: | 225 | tags: |
253 | summary: revert | 226 | summary: revert |
254 | files: a dir/b | 227 | files: a dir/b |
255 | | 228 | |
256 o changeset: 1:243259a4138a | 229 o changeset: 1:243259a4138a (r2) |
257 | branch: | 230 | branch: |
258 | tags: | 231 | tags: |
259 | summary: changefiles | 232 | summary: changefiles |
260 | files: a dir/b | 233 | files: a dir/b |
261 | | 234 | |
262 o changeset: 0:ab86791fc857 | 235 o changeset: 0:ab86791fc857 (r1) |
263 branch: | 236 branch: |
264 tags: | 237 tags: |
265 summary: init | 238 summary: init |
266 files: a dir/b | 239 files: a dir/b |
240 | |
267 """ | 241 """ |
268 self.assertEqual(refgraph.strip(), graph.strip()) | 242 self.assertMultiLineEqual(refgraph, graph) |
269 | 243 |
270 def test_fetch_revert_stupid(self): | 244 def test_fetch_movetotrunk(self): |
271 self.test_fetch_revert(stupid=True) | |
272 | |
273 def test_fetch_movetotrunk(self, stupid=False): | |
274 repo = self._load_fixture_and_fetch('movetotrunk.svndump', | 245 repo = self._load_fixture_and_fetch('movetotrunk.svndump', |
275 stupid=stupid, subdir='sub1/sub2') | 246 subdir='sub1/sub2') |
276 graph = self.getgraph(repo) | 247 graph = self.getgraph(repo) |
277 refgraph = """\ | 248 refgraph = """\ |
278 o changeset: 0:02996a5980ba | 249 o changeset: 0:02996a5980ba (r3) |
279 branch: | 250 branch: |
280 tags: tip | 251 tags: tip |
281 summary: move to trunk | 252 summary: move to trunk |
282 files: a dir/b | 253 files: a dir/b |
254 | |
283 """ | 255 """ |
284 self.assertEqual(refgraph.strip(), graph.strip()) | 256 self.assertMultiLineEqual(refgraph, graph) |
285 | 257 |
286 def test_fetch_movetotrunk_stupid(self): | |
287 self.test_fetch_movetotrunk(stupid=True) | |
288 | |
289 def suite(): | |
290 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestBasicRepoLayout), | |
291 unittest.TestLoader().loadTestsFromTestCase(TestStupidPull), | |
292 ] | |
293 return unittest.TestSuite(all_tests) |