Mercurial > hgsubversion
comparison tests/test_externals.py @ 304:ce676eff002b
First merge, totally untested.
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Fri, 01 May 2009 10:28:59 +0200 |
| parents | ba8e91a7c077 |
| children | 963d27a0b1c2 |
comparison
equal
deleted
inserted
replaced
| 303:f423a8780832 | 304:ce676eff002b |
|---|---|
| 1 import unittest | 1 import os, unittest |
| 2 | |
| 3 from mercurial import commands | |
| 2 | 4 |
| 3 import svnexternals | 5 import svnexternals |
| 4 import test_util | 6 import test_util |
| 5 | |
| 6 | 7 |
| 7 class TestFetchExternals(test_util.TestBase): | 8 class TestFetchExternals(test_util.TestBase): |
| 8 def test_externalsfile(self): | 9 def test_externalsfile(self): |
| 9 f = svnexternals.externalsfile() | 10 f = svnexternals.externalsfile() |
| 10 f['t1'] = 'dir1 -r10 svn://foobar' | 11 f['t1'] = 'dir1 -r10 svn://foobar' |
| 11 f['t 2'] = 'dir2 -r10 svn://foobar' | 12 f['t 2'] = 'dir2 -r10 svn://foobar' |
| 12 f['t3'] = ['dir31 -r10 svn://foobar', 'dir32 -r10 svn://foobar'] | 13 f['t3'] = ['dir31 -r10 svn://foobar', 'dir32 -r10 svn://foobar'] |
| 13 | 14 |
| 14 refext = """\ | 15 refext = """[t 2] |
| 15 [t 2] | |
| 16 dir2 -r10 svn://foobar | 16 dir2 -r10 svn://foobar |
| 17 [t1] | 17 [t1] |
| 18 dir1 -r10 svn://foobar | 18 dir1 -r10 svn://foobar |
| 19 [t3] | 19 [t3] |
| 20 dir31 -r10 svn://foobar | 20 dir31 -r10 svn://foobar |
| 27 f2.read(value) | 27 f2.read(value) |
| 28 self.assertEqual(sorted(f), sorted(f2)) | 28 self.assertEqual(sorted(f), sorted(f2)) |
| 29 for t in f: | 29 for t in f: |
| 30 self.assertEqual(f[t], f2[t]) | 30 self.assertEqual(f[t], f2[t]) |
| 31 | 31 |
| 32 def test_parsedefinitions(self): | |
| 33 # Taken from svn book | |
| 34 samples = [ | |
| 35 ('third-party/sounds http://svn.example.com/repos/sounds', | |
| 36 ('third-party/sounds', None, 'http://svn.example.com/repos/sounds')), | |
| 37 ('third-party/skins -r148 http://svn.example.com/skinproj', | |
| 38 ('third-party/skins', '148', 'http://svn.example.com/skinproj')), | |
| 39 ('third-party/skins -r 148 http://svn.example.com/skinproj', | |
| 40 ('third-party/skins', '148', 'http://svn.example.com/skinproj')), | |
| 41 ('http://svn.example.com/repos/sounds third-party/sounds', | |
| 42 ('third-party/sounds', None, 'http://svn.example.com/repos/sounds')), | |
| 43 ('-r148 http://svn.example.com/skinproj third-party/skins', | |
| 44 ('third-party/skins', '148', 'http://svn.example.com/skinproj')), | |
| 45 ('-r 148 http://svn.example.com/skinproj third-party/skins', | |
| 46 ('third-party/skins', '148', 'http://svn.example.com/skinproj')), | |
| 47 ('http://svn.example.com/skin-maker@21 third-party/skins/toolkit', | |
| 48 ('third-party/skins/toolkit', '21', 'http://svn.example.com/skin-maker')), | |
| 49 ] | |
| 50 | |
| 51 for line, expected in samples: | |
| 52 self.assertEqual(expected, svnexternals.parsedefinition(line)) | |
| 53 | |
| 32 def test_externals(self, stupid=False): | 54 def test_externals(self, stupid=False): |
| 33 repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) | 55 repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) |
| 34 | 56 |
| 35 ref0 = """\ | 57 ref0 = """[.] |
| 36 [.] | |
| 37 ^/externals/project1 deps/project1 | 58 ^/externals/project1 deps/project1 |
| 38 """ | 59 """ |
| 39 self.assertEqual(ref0, repo[0]['.hgsvnexternals'].data()) | 60 self.assertEqual(ref0, repo[0]['.hgsvnexternals'].data()) |
| 40 ref1 = """\ | 61 ref1 = """[.] |
| 41 [.] | |
| 42 ^/externals/project1 deps/project1 | 62 ^/externals/project1 deps/project1 |
| 43 ^/externals/project2 deps/project2 | 63 ^/externals/project2 deps/project2 |
| 44 """ | 64 """ |
| 45 self.assertEqual(ref1, repo[1]['.hgsvnexternals'].data()) | 65 self.assertEqual(ref1, repo[1]['.hgsvnexternals'].data()) |
| 46 | 66 |
| 47 ref2 = """\ | 67 ref2 = """[.] |
| 48 [.] | |
| 49 ^/externals/project2 deps/project2 | 68 ^/externals/project2 deps/project2 |
| 50 [subdir] | 69 [subdir] |
| 51 ^/externals/project1 deps/project1 | 70 ^/externals/project1 deps/project1 |
| 52 [subdir2] | 71 [subdir2] |
| 53 ^/externals/project1 deps/project1 | 72 ^/externals/project1 deps/project1 |
| 54 """ | 73 """ |
| 55 self.assertEqual(ref2, repo[2]['.hgsvnexternals'].data()) | 74 actual = repo[2]['.hgsvnexternals'].data() |
| 75 self.assertEqual(ref2, actual) | |
| 56 | 76 |
| 57 ref3 = """\ | 77 ref3 = """[.] |
| 58 [.] | |
| 59 ^/externals/project2 deps/project2 | 78 ^/externals/project2 deps/project2 |
| 60 [subdir] | 79 [subdir] |
| 61 ^/externals/project1 deps/project1 | 80 ^/externals/project1 deps/project1 |
| 62 """ | 81 """ |
| 63 self.assertEqual(ref3, repo[3]['.hgsvnexternals'].data()) | 82 self.assertEqual(ref3, repo[3]['.hgsvnexternals'].data()) |
| 64 | 83 |
| 65 ref4 = """\ | 84 ref4 = """[subdir] |
| 66 [subdir] | |
| 67 ^/externals/project1 deps/project1 | 85 ^/externals/project1 deps/project1 |
| 68 """ | 86 """ |
| 69 self.assertEqual(ref4, repo[4]['.hgsvnexternals'].data()) | 87 self.assertEqual(ref4, repo[4]['.hgsvnexternals'].data()) |
| 70 | 88 |
| 71 ref5 = """\ | 89 ref5 = """[.] |
| 72 [.] | |
| 73 ^/externals/project2 deps/project2 | 90 ^/externals/project2 deps/project2 |
| 74 [subdir2] | 91 [subdir2] |
| 75 ^/externals/project1 deps/project1 | 92 ^/externals/project1 deps/project1 |
| 76 """ | 93 """ |
| 77 self.assertEqual(ref5, repo[5]['.hgsvnexternals'].data()) | 94 self.assertEqual(ref5, repo[5]['.hgsvnexternals'].data()) |
| 78 | 95 |
| 79 ref6 = """\ | 96 ref6 = """[.] |
| 80 [.] | |
| 81 ^/externals/project2 deps/project2 | 97 ^/externals/project2 deps/project2 |
| 82 """ | 98 """ |
| 83 self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) | 99 self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) |
| 84 | 100 |
| 85 def test_externals_stupid(self): | 101 def test_externals_stupid(self): |
| 86 self.test_externals(True) | 102 self.test_externals(True) |
| 87 | 103 |
| 104 def test_updateexternals(self): | |
| 105 def checkdeps(deps, nodeps, repo, rev=None): | |
| 106 svnexternals.updateexternals(ui, [rev], repo) | |
| 107 for d in deps: | |
| 108 p = os.path.join(repo.root, d) | |
| 109 self.assertTrue(os.path.isdir(p), | |
| 110 'missing: %s@%r' % (d, rev)) | |
| 111 for d in nodeps: | |
| 112 p = os.path.join(repo.root, d) | |
| 113 self.assertTrue(not os.path.isdir(p), | |
| 114 'unexpected: %s@%r' % (d, rev)) | |
| 115 | |
| 116 ui = test_util.ui.ui() | |
| 117 repo = self._load_fixture_and_fetch('externals.svndump', stupid=0) | |
| 118 commands.update(ui, repo) | |
| 119 checkdeps(['deps/project1'], [], repo, 0) | |
| 120 checkdeps(['deps/project1', 'deps/project2'], [], repo, 1) | |
| 121 checkdeps(['subdir/deps/project1', 'subdir2/deps/project1', | |
| 122 'deps/project2'], | |
| 123 ['deps/project1'], repo, 2) | |
| 124 checkdeps(['subdir/deps/project1', 'deps/project2'], | |
| 125 ['subdir2/deps/project1'], repo, 3) | |
| 126 checkdeps(['subdir/deps/project1'], ['deps/project2'], repo, 4) | |
| 88 | 127 |
| 89 class TestPushExternals(test_util.TestBase): | 128 class TestPushExternals(test_util.TestBase): |
| 90 def setUp(self): | 129 def setUp(self): |
| 91 test_util.TestBase.setUp(self) | 130 test_util.TestBase.setUp(self) |
| 92 test_util.load_fixture_and_fetch('pushexternals.svndump', | 131 test_util.load_fixture_and_fetch('pushexternals.svndump', |
| 94 self.wc_path) | 133 self.wc_path) |
| 95 | 134 |
| 96 def test_push_externals(self, stupid=False): | 135 def test_push_externals(self, stupid=False): |
| 97 # Add a new reference on an existing and non-existing directory | 136 # Add a new reference on an existing and non-existing directory |
| 98 changes = [ | 137 changes = [ |
| 99 ('.hgsvnexternals', '.hgsvnexternals', | 138 ('.hgsvnexternals', '.hgsvnexternals', |
| 100 """\ | 139 """[dir] |
| 101 [dir] | |
| 102 ../externals/project2 deps/project2 | 140 ../externals/project2 deps/project2 |
| 103 [subdir1] | 141 [subdir1] |
| 104 ../externals/project1 deps/project1 | 142 ../externals/project1 deps/project1 |
| 105 [subdir2] | 143 [subdir2] |
| 106 ../externals/project2 deps/project2 | 144 ../externals/project2 deps/project2 |
| 113 self.assertchanges(changes, self.repo['tip']) | 151 self.assertchanges(changes, self.repo['tip']) |
| 114 | 152 |
| 115 # Remove all references from one directory, add a new one | 153 # Remove all references from one directory, add a new one |
| 116 # to the other (test multiline entries) | 154 # to the other (test multiline entries) |
| 117 changes = [ | 155 changes = [ |
| 118 ('.hgsvnexternals', '.hgsvnexternals', | 156 ('.hgsvnexternals', '.hgsvnexternals', |
| 119 """\ | 157 """[subdir1] |
| 120 [subdir1] | |
| 121 ../externals/project1 deps/project1 | 158 ../externals/project1 deps/project1 |
| 122 ../externals/project2 deps/project2 | 159 ../externals/project2 deps/project2 |
| 123 """), | 160 """), |
| 124 # This removal used to trigger the parent directory removal | 161 # This removal used to trigger the parent directory removal |
| 125 ('subdir1/a', None, None), | 162 ('subdir1/a', None, None), |
