Mercurial > hgsubversion
comparison tests/test_externals.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 | 7d82131e7801 |
children | 258fb67fb956 |
comparison
equal
deleted
inserted
replaced
1020:b5b1fce26f1f | 1106:5cb6c95e0283 |
---|---|
14 subrepo = None | 14 subrepo = None |
15 | 15 |
16 from hgsubversion import svnexternals | 16 from hgsubversion import svnexternals |
17 | 17 |
18 class TestFetchExternals(test_util.TestBase): | 18 class TestFetchExternals(test_util.TestBase): |
19 stupid_mode_tests = True | |
20 | |
19 def test_externalsfile(self): | 21 def test_externalsfile(self): |
20 f = svnexternals.externalsfile() | 22 f = svnexternals.externalsfile() |
21 f['t1'] = 'dir1 -r10 svn://foobar' | 23 f['t1'] = 'dir1 -r10 svn://foobar' |
22 f['t 2'] = 'dir2 -r10 svn://foobar' | 24 f['t 2'] = 'dir2 -r10 svn://foobar' |
23 f['t3'] = ['dir31 -r10 svn://foobar', 'dir32 -r10 svn://foobar'] | 25 f['t3'] = ['dir31 -r10 svn://foobar', 'dir32 -r10 svn://foobar'] |
72 ] | 74 ] |
73 | 75 |
74 for line, expected in samples: | 76 for line, expected in samples: |
75 self.assertEqual(expected, svnexternals.parsedefinition(line)) | 77 self.assertEqual(expected, svnexternals.parsedefinition(line)) |
76 | 78 |
77 def test_externals(self, stupid=False): | 79 def test_externals(self): |
78 repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) | 80 repo = self._load_fixture_and_fetch('externals.svndump') |
79 | 81 |
80 ref0 = """[.] | 82 ref0 = """[.] |
81 ^/externals/project1 deps/project1 | 83 ^/externals/project1 deps/project1 |
82 """ | 84 """ |
83 self.assertMultiLineEqual(ref0, repo[0]['.hgsvnexternals'].data()) | 85 self.assertMultiLineEqual(ref0, repo[0]['.hgsvnexternals'].data()) |
122 | 124 |
123 ref6 = """[.] | 125 ref6 = """[.] |
124 -r2 ^/externals/project2@2 deps/project2 | 126 -r2 ^/externals/project2@2 deps/project2 |
125 """ | 127 """ |
126 self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) | 128 self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) |
127 | |
128 def test_externals_stupid(self): | |
129 self.test_externals(True) | |
130 | 129 |
131 def test_updateexternals(self): | 130 def test_updateexternals(self): |
132 def checkdeps(deps, nodeps, repo, rev=None): | 131 def checkdeps(deps, nodeps, repo, rev=None): |
133 svnexternals.updateexternals(ui, [rev], repo) | 132 svnexternals.updateexternals(ui, [rev], repo) |
134 for d in deps: | 133 for d in deps: |
139 p = os.path.join(repo.root, d) | 138 p = os.path.join(repo.root, d) |
140 self.assertTrue(not os.path.isdir(p), | 139 self.assertTrue(not os.path.isdir(p), |
141 'unexpected: %s@%r' % (d, rev)) | 140 'unexpected: %s@%r' % (d, rev)) |
142 | 141 |
143 ui = self.ui() | 142 ui = self.ui() |
144 repo = self._load_fixture_and_fetch('externals.svndump', stupid=0) | 143 repo = self._load_fixture_and_fetch('externals.svndump') |
145 commands.update(ui, repo) | 144 commands.update(ui, repo) |
146 checkdeps(['deps/project1'], [], repo, 0) | 145 checkdeps(['deps/project1'], [], repo, 0) |
147 checkdeps(['deps/project1', 'deps/project2'], [], repo, 1) | 146 checkdeps(['deps/project1', 'deps/project2'], [], repo, 1) |
148 checkdeps(['subdir/deps/project1', 'subdir2/deps/project1', | 147 checkdeps(['subdir/deps/project1', 'subdir2/deps/project1', |
149 'deps/project2'], | 148 'deps/project2'], |
150 ['deps/project1'], repo, 2) | 149 ['deps/project1'], repo, 2) |
151 checkdeps(['subdir/deps/project1', 'deps/project2'], | 150 checkdeps(['subdir/deps/project1', 'deps/project2'], |
152 ['subdir2/deps/project1'], repo, 3) | 151 ['subdir2/deps/project1'], repo, 3) |
153 checkdeps(['subdir/deps/project1'], ['deps/project2'], repo, 4) | 152 checkdeps(['subdir/deps/project1'], ['deps/project2'], repo, 4) |
154 | 153 |
155 def test_hgsub(self, stupid=False): | 154 def test_hgsub(self): |
156 if subrepo is None: | 155 if subrepo is None: |
157 return | 156 return |
158 repo = self._load_fixture_and_fetch('externals.svndump', | 157 repo = self._load_fixture_and_fetch('externals.svndump', |
159 externals='subrepos', | 158 externals='subrepos') |
160 stupid=stupid) | |
161 self.assertEqual("""\ | 159 self.assertEqual("""\ |
162 deps/project1 = [hgsubversion] :^/externals/project1 deps/project1 | 160 deps/project1 = [hgsubversion] :^/externals/project1 deps/project1 |
163 """, repo[0]['.hgsub'].data()) | 161 """, repo[0]['.hgsub'].data()) |
164 self.assertEqual("""\ | 162 self.assertEqual("""\ |
165 HEAD deps/project1 | 163 HEAD deps/project1 |
214 deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2 | 212 deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2 |
215 """, repo[6]['.hgsub'].data()) | 213 """, repo[6]['.hgsub'].data()) |
216 self.assertEqual("""\ | 214 self.assertEqual("""\ |
217 2 deps/project2 | 215 2 deps/project2 |
218 """, repo[6]['.hgsubstate'].data()) | 216 """, repo[6]['.hgsubstate'].data()) |
219 | |
220 def test_hgsub_stupid(self): | |
221 self.test_hgsub(True) | |
222 | 217 |
223 def test_ignore(self): | 218 def test_ignore(self): |
224 repo = self._load_fixture_and_fetch('externals.svndump', | 219 repo = self._load_fixture_and_fetch('externals.svndump', |
225 externals='ignore') | 220 externals='ignore') |
226 for rev in repo: | 221 for rev in repo: |
244 if subrepo is None: | 239 if subrepo is None: |
245 return | 240 return |
246 | 241 |
247 ui = self.ui() | 242 ui = self.ui() |
248 repo = self._load_fixture_and_fetch('externals.svndump', | 243 repo = self._load_fixture_and_fetch('externals.svndump', |
249 stupid=0, externals='subrepos') | 244 externals='subrepos') |
250 checkdeps(ui, repo, 0, ['deps/project1'], []) | 245 checkdeps(ui, repo, 0, ['deps/project1'], []) |
251 checkdeps(ui, repo, 1, ['deps/project1', 'deps/project2'], []) | 246 checkdeps(ui, repo, 1, ['deps/project1', 'deps/project2'], []) |
252 checkdeps(ui, repo, 2, ['subdir/deps/project1', 'subdir2/deps/project1', | 247 checkdeps(ui, repo, 2, ['subdir/deps/project1', 'subdir2/deps/project1', |
253 'deps/project2'], | 248 'deps/project2'], |
254 ['deps/project1']) | 249 ['deps/project1']) |
258 | 253 |
259 # Test update --clean, used to crash | 254 # Test update --clean, used to crash |
260 repo.wwrite('subdir/deps/project1/a', 'foobar', '') | 255 repo.wwrite('subdir/deps/project1/a', 'foobar', '') |
261 commands.update(ui, repo, node='4', clean=True) | 256 commands.update(ui, repo, node='4', clean=True) |
262 | 257 |
263 def test_mergeexternals(self, stupid=False): | 258 def test_mergeexternals(self): |
264 if subrepo is None: | 259 if subrepo is None: |
265 return | 260 return |
266 repo = self._load_fixture_and_fetch('mergeexternals.svndump', | 261 repo = self._load_fixture_and_fetch('mergeexternals.svndump', |
267 externals='subrepos', | 262 externals='subrepos') |
268 stupid=stupid) | |
269 # Check merged directories externals are fine | 263 # Check merged directories externals are fine |
270 self.assertEqual("""\ | 264 self.assertEqual("""\ |
271 d1/ext = [hgsubversion] d1:^/trunk/common/ext ext | 265 d1/ext = [hgsubversion] d1:^/trunk/common/ext ext |
272 d2/ext = [hgsubversion] d2:^/trunk/common/ext ext | 266 d2/ext = [hgsubversion] d2:^/trunk/common/ext ext |
273 d3/ext3 = [hgsubversion] d3:^/trunk/common/ext ext3 | 267 d3/ext3 = [hgsubversion] d3:^/trunk/common/ext ext3 |
274 """, repo['tip']['.hgsub'].data()) | 268 """, repo['tip']['.hgsub'].data()) |
275 | 269 |
276 def test_mergeexternals_stupid(self): | |
277 self.test_mergeexternals(True) | |
278 | |
279 class TestPushExternals(test_util.TestBase): | 270 class TestPushExternals(test_util.TestBase): |
280 def test_push_externals(self, stupid=False): | 271 stupid_mode_tests = True |
272 obsolete_mode_tests = True | |
273 | |
274 def test_push_externals(self): | |
281 repo = self._load_fixture_and_fetch('pushexternals.svndump') | 275 repo = self._load_fixture_and_fetch('pushexternals.svndump') |
282 # Add a new reference on an existing and non-existing directory | 276 # Add a new reference on an existing and non-existing directory |
283 changes = [ | 277 changes = [ |
284 ('.hgsvnexternals', '.hgsvnexternals', | 278 ('.hgsvnexternals', '.hgsvnexternals', |
285 """[dir] | 279 """[dir] |
291 """), | 285 """), |
292 ('subdir1/a', 'subdir1/a', 'a'), | 286 ('subdir1/a', 'subdir1/a', 'a'), |
293 ('subdir2/a', 'subdir2/a', 'a'), | 287 ('subdir2/a', 'subdir2/a', 'a'), |
294 ] | 288 ] |
295 self.commitchanges(changes) | 289 self.commitchanges(changes) |
296 self.pushrevisions(stupid) | 290 self.pushrevisions() |
297 self.assertchanges(changes, self.repo['tip']) | 291 self.assertchanges(changes, self.repo['tip']) |
298 | 292 |
299 # Remove all references from one directory, add a new one | 293 # Remove all references from one directory, add a new one |
300 # to the other (test multiline entries) | 294 # to the other (test multiline entries) |
301 changes = [ | 295 changes = [ |
306 """), | 300 """), |
307 # This removal used to trigger the parent directory removal | 301 # This removal used to trigger the parent directory removal |
308 ('subdir1/a', None, None), | 302 ('subdir1/a', None, None), |
309 ] | 303 ] |
310 self.commitchanges(changes) | 304 self.commitchanges(changes) |
311 self.pushrevisions(stupid) | 305 self.pushrevisions() |
312 self.assertchanges(changes, self.repo['tip']) | 306 self.assertchanges(changes, self.repo['tip']) |
313 # Check subdir2/a is still there even if the externals were removed | 307 # Check subdir2/a is still there even if the externals were removed |
314 self.assertTrue('subdir2/a' in self.repo['tip']) | 308 self.assertTrue('subdir2/a' in self.repo['tip']) |
315 self.assertTrue('subdir1/a' not in self.repo['tip']) | 309 self.assertTrue('subdir1/a' not in self.repo['tip']) |
316 | 310 |
317 # Test externals removal | 311 # Test externals removal |
318 changes = [ | 312 changes = [ |
319 ('.hgsvnexternals', None, None), | 313 ('.hgsvnexternals', None, None), |
320 ] | 314 ] |
321 self.commitchanges(changes) | 315 self.commitchanges(changes) |
322 self.pushrevisions(stupid) | 316 self.pushrevisions() |
323 self.assertchanges(changes, self.repo['tip']) | 317 self.assertchanges(changes, self.repo['tip']) |
324 | 318 |
325 def test_push_externals_stupid(self): | 319 def test_push_hgsub(self): |
326 self.test_push_externals(True) | |
327 | |
328 def test_push_hgsub(self, stupid=False): | |
329 if subrepo is None: | 320 if subrepo is None: |
330 return | 321 return |
331 | 322 |
332 repo, repo_path = self.load_and_fetch('pushexternals.svndump', | 323 repo, repo_path = self.load_and_fetch('pushexternals.svndump', |
333 externals='subrepos') | 324 externals='subrepos') |
348 ] | 339 ] |
349 self.svnco(repo_path, 'externals/project2', '2', 'dir/deps/project2') | 340 self.svnco(repo_path, 'externals/project2', '2', 'dir/deps/project2') |
350 self.svnco(repo_path, 'externals/project1', '2', 'subdir1/deps/project1') | 341 self.svnco(repo_path, 'externals/project1', '2', 'subdir1/deps/project1') |
351 self.svnco(repo_path, 'externals/project2', '2', 'subdir2/deps/project2') | 342 self.svnco(repo_path, 'externals/project2', '2', 'subdir2/deps/project2') |
352 self.commitchanges(changes) | 343 self.commitchanges(changes) |
353 self.pushrevisions(stupid) | 344 self.pushrevisions() |
354 self.assertchanges(changes, self.repo['tip']) | 345 self.assertchanges(changes, self.repo['tip']) |
355 | 346 |
356 # Check .hgsub and .hgsubstate were not pushed | 347 # Check .hgsub and .hgsubstate were not pushed |
357 self.assertEqual(['dir', 'subdir1', 'subdir1/a', 'subdir2', | 348 self.assertEqual(['dir', 'subdir1', 'subdir1/a', 'subdir2', |
358 'subdir2/a'], test_util.svnls(repo_path, 'trunk')) | 349 'subdir2/a'], test_util.svnls(repo_path, 'trunk')) |
372 ('subdir1/a', None, None), | 363 ('subdir1/a', None, None), |
373 ] | 364 ] |
374 self.svnco(repo_path, 'externals/project1', '2', 'subdir1/deps/project1') | 365 self.svnco(repo_path, 'externals/project1', '2', 'subdir1/deps/project1') |
375 self.svnco(repo_path, 'externals/project2', '2', 'subdir1/deps/project2') | 366 self.svnco(repo_path, 'externals/project2', '2', 'subdir1/deps/project2') |
376 self.commitchanges(changes) | 367 self.commitchanges(changes) |
377 self.pushrevisions(stupid) | 368 self.pushrevisions() |
378 self.assertchanges(changes, self.repo['tip']) | 369 self.assertchanges(changes, self.repo['tip']) |
379 # Check subdir2/a is still there even if the externals were removed | 370 # Check subdir2/a is still there even if the externals were removed |
380 self.assertTrue('subdir2/a' in self.repo['tip']) | 371 self.assertTrue('subdir2/a' in self.repo['tip']) |
381 self.assertTrue('subdir1/a' not in self.repo['tip']) | 372 self.assertTrue('subdir1/a' not in self.repo['tip']) |
382 | 373 |
389 ('.hgsubstate', '.hgsubstate', """\ | 380 ('.hgsubstate', '.hgsubstate', """\ |
390 HEAD subdir1/deps/project1 | 381 HEAD subdir1/deps/project1 |
391 """), | 382 """), |
392 ] | 383 ] |
393 self.commitchanges(changes) | 384 self.commitchanges(changes) |
394 self.pushrevisions(stupid) | 385 self.pushrevisions() |
395 self.assertchanges(changes, self.repo['tip']) | 386 self.assertchanges(changes, self.repo['tip']) |
396 | 387 |
397 # Test externals removal | 388 # Test externals removal |
398 changes = [ | 389 changes = [ |
399 ('.hgsub', None, None), | 390 ('.hgsub', None, None), |
400 ('.hgsubstate', None, None), | 391 ('.hgsubstate', None, None), |
401 ] | 392 ] |
402 self.commitchanges(changes) | 393 self.commitchanges(changes) |
403 self.pushrevisions(stupid) | 394 self.pushrevisions() |
404 self.assertchanges(changes, self.repo['tip']) | 395 self.assertchanges(changes, self.repo['tip']) |
405 | |
406 def suite(): | |
407 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestFetchExternals), | |
408 unittest.TestLoader().loadTestsFromTestCase(TestPushExternals), | |
409 ] | |
410 return unittest.TestSuite(all_tests) |