Mercurial > hgsubversion
comparison tests/test_single_dir_clone.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 | a36e87ae2380 |
comparison
equal
deleted
inserted
replaced
1020:b5b1fce26f1f | 1106:5cb6c95e0283 |
---|---|
8 from mercurial import context | 8 from mercurial import context |
9 from mercurial import hg | 9 from mercurial import hg |
10 from mercurial import node | 10 from mercurial import node |
11 from mercurial import ui | 11 from mercurial import ui |
12 | 12 |
13 class TestSingleDir(test_util.TestBase): | 13 from hgsubversion import compathacks |
14 | |
15 class TestSingleDirClone(test_util.TestBase): | |
16 stupid_mode_tests = True | |
17 | |
14 def test_clone_single_dir_simple(self): | 18 def test_clone_single_dir_simple(self): |
15 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', | 19 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
16 stupid=False, | |
17 layout='single', | 20 layout='single', |
18 subdir='') | 21 subdir='') |
19 self.assertEqual(repo.branchtags().keys(), ['default']) | 22 self.assertEqual(compathacks.branchset(repo), |
23 set(['default'])) | |
20 self.assertEqual(repo['tip'].manifest().keys(), | 24 self.assertEqual(repo['tip'].manifest().keys(), |
21 ['trunk/beta', | 25 ['trunk/beta', |
22 'tags/copied_tag/alpha', | 26 'tags/copied_tag/alpha', |
23 'trunk/alpha', | 27 'trunk/alpha', |
24 'tags/copied_tag/beta', | 28 'tags/copied_tag/beta', |
27 'tags/tag_r3/beta', | 31 'tags/tag_r3/beta', |
28 'branches/branch_from_tag/beta']) | 32 'branches/branch_from_tag/beta']) |
29 | 33 |
30 def test_auto_detect_single(self): | 34 def test_auto_detect_single(self): |
31 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', | 35 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
32 stupid=False, | |
33 layout='auto') | 36 layout='auto') |
34 self.assertEqual(repo.branchtags().keys(), ['default', | 37 self.assertEqual(compathacks.branchset(repo), |
35 'branch_from_tag']) | 38 set(['default', 'branch_from_tag'])) |
36 oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys()) | 39 oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys()) |
37 # remove standard layout | 40 # remove standard layout |
38 shutil.rmtree(self.wc_path) | 41 shutil.rmtree(self.wc_path) |
39 # try again with subdir to get single dir clone | 42 # try again with subdir to get single dir clone |
40 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', | 43 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
41 stupid=False, | |
42 layout='auto', | 44 layout='auto', |
43 subdir='trunk') | 45 subdir='trunk') |
44 self.assertEqual(repo.branchtags().keys(), ['default', ]) | 46 self.assertEqual(compathacks.branchset(repo), set(['default', ])) |
45 self.assertEqual(repo['default'].manifest().keys(), oldmanifest) | 47 self.assertEqual(repo['default'].manifest().keys(), oldmanifest) |
46 | 48 |
47 def test_clone_subdir_is_file_prefix(self, stupid=False): | 49 def test_clone_subdir_is_file_prefix(self): |
48 FIXTURE = 'subdir_is_file_prefix.svndump' | 50 FIXTURE = 'subdir_is_file_prefix.svndump' |
49 repo = self._load_fixture_and_fetch(FIXTURE, | 51 repo = self._load_fixture_and_fetch(FIXTURE, |
50 stupid=stupid, | |
51 layout='single', | 52 layout='single', |
52 subdir=test_util.subdir[FIXTURE]) | 53 subdir=test_util.subdir[FIXTURE]) |
53 self.assertEqual(repo.branchtags().keys(), ['default']) | 54 self.assertEqual(compathacks.branchset(repo), set(['default'])) |
54 self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt']) | 55 self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt']) |
55 | 56 |
56 def test_externals_single(self): | 57 def test_externals_single(self): |
57 repo = self._load_fixture_and_fetch('externals.svndump', | 58 repo = self._load_fixture_and_fetch('externals.svndump', |
58 stupid=False, | |
59 layout='single') | 59 layout='single') |
60 for rev in repo: | 60 for rev in repo: |
61 assert '.hgsvnexternals' not in repo[rev].manifest() | 61 assert '.hgsvnexternals' not in repo[rev].manifest() |
62 return # TODO enable test when externals in single are fixed | 62 return # TODO enable test when externals in single are fixed |
63 expect = """[.] | 63 expect = """[.] |
72 | 72 |
73 def test_externals_single_whole_repo(self): | 73 def test_externals_single_whole_repo(self): |
74 # This is the test which demonstrates the brokenness of externals | 74 # This is the test which demonstrates the brokenness of externals |
75 return # TODO enable test when externals in single are fixed | 75 return # TODO enable test when externals in single are fixed |
76 repo = self._load_fixture_and_fetch('externals.svndump', | 76 repo = self._load_fixture_and_fetch('externals.svndump', |
77 stupid=False, | |
78 layout='single', | 77 layout='single', |
79 subdir='') | 78 subdir='') |
80 for rev in repo: | 79 for rev in repo: |
81 rc = repo[rev] | 80 rc = repo[rev] |
82 if '.hgsvnexternals' in rc: | 81 if '.hgsvnexternals' in rc: |
84 assert '[.]' not in extdata | 83 assert '[.]' not in extdata |
85 print extdata | 84 print extdata |
86 expect = '' # Not honestly sure what this should be... | 85 expect = '' # Not honestly sure what this should be... |
87 test = 4 | 86 test = 4 |
88 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) | 87 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) |
89 | |
90 def test_push_single_dir(self): | |
91 # Tests simple pushing from default branch to a single dir repo | |
92 repo, repo_path = self.load_and_fetch('branch_from_tag.svndump', | |
93 stupid=False, | |
94 layout='single', | |
95 subdir='') | |
96 def file_callback(repo, memctx, path): | |
97 if path == 'adding_file': | |
98 return context.memfilectx(path=path, | |
99 data='foo', | |
100 islink=False, | |
101 isexec=False, | |
102 copied=False) | |
103 elif path == 'adding_binary': | |
104 return context.memfilectx(path=path, | |
105 data='\0binary', | |
106 islink=False, | |
107 isexec=False, | |
108 copied=False) | |
109 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | |
110 ctx = context.memctx(repo, | |
111 (repo['tip'].node(), node.nullid), | |
112 'automated test', | |
113 ['adding_file', 'adding_binary'], | |
114 file_callback, | |
115 'an_author', | |
116 '2009-10-19 18:49:30 -0500', | |
117 {'branch': 'default', }) | |
118 repo.commitctx(ctx) | |
119 hg.update(repo, repo['tip'].node()) | |
120 self.pushrevisions() | |
121 self.assertTrue('adding_file' in test_util.svnls(repo_path, '')) | |
122 self.assertEqual('application/octet-stream', | |
123 test_util.svnpropget(repo_path, 'adding_binary', | |
124 'svn:mime-type')) | |
125 # Now add another commit and test mime-type being reset | |
126 changes = [('adding_binary', 'adding_binary', 'no longer binary')] | |
127 self.commitchanges(changes) | |
128 self.pushrevisions() | |
129 self.assertEqual('', test_util.svnpropget(repo_path, 'adding_binary', | |
130 'svn:mime-type')) | |
131 | |
132 def test_push_single_dir_at_subdir(self): | |
133 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', | |
134 stupid=False, | |
135 layout='single', | |
136 subdir='trunk') | |
137 def filectxfn(repo, memctx, path): | |
138 return context.memfilectx(path=path, | |
139 data='contents of %s' % path, | |
140 islink=False, | |
141 isexec=False, | |
142 copied=False) | |
143 ctx = context.memctx(repo, | |
144 (repo['tip'].node(), node.nullid), | |
145 'automated test', | |
146 ['bogus'], | |
147 filectxfn, | |
148 'an_author', | |
149 '2009-10-19 18:49:30 -0500', | |
150 {'branch': 'localhacking', }) | |
151 n = repo.commitctx(ctx) | |
152 self.assertEqual(self.repo['tip']['bogus'].data(), | |
153 'contents of bogus') | |
154 before = repo['tip'].hex() | |
155 hg.update(repo, self.repo['tip'].hex()) | |
156 self.pushrevisions() | |
157 self.assertNotEqual(before, self.repo['tip'].hex()) | |
158 self.assertEqual(self.repo['tip']['bogus'].data(), | |
159 'contents of bogus') | |
160 | |
161 def test_push_single_dir_one_incoming_and_two_outgoing(self): | |
162 # Tests simple pushing from default branch to a single dir repo | |
163 # Pushes two outgoing over one incoming svn rev | |
164 # (used to cause an "unknown revision") | |
165 # This can happen if someone committed to svn since our last pull (race). | |
166 repo, repo_path = self.load_and_fetch('branch_from_tag.svndump', | |
167 stupid=False, | |
168 layout='single', | |
169 subdir='trunk') | |
170 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'}) | |
171 def file_callback(repo, memctx, path): | |
172 return context.memfilectx(path=path, | |
173 data='data of %s' % path, | |
174 islink=False, | |
175 isexec=False, | |
176 copied=False) | |
177 for fn in ['one', 'two']: | |
178 ctx = context.memctx(repo, | |
179 (repo['tip'].node(), node.nullid), | |
180 'automated test', | |
181 [fn], | |
182 file_callback, | |
183 'an_author', | |
184 '2009-10-19 18:49:30 -0500', | |
185 {'branch': 'default', }) | |
186 repo.commitctx(ctx) | |
187 hg.update(repo, repo['tip'].node()) | |
188 self.pushrevisions(expected_extra_back=1) | |
189 self.assertTrue('trunk/one' in test_util.svnls(repo_path, '')) | |
190 self.assertTrue('trunk/two' in test_util.svnls(repo_path, '')) | |
191 | |
192 def test_push_single_dir_branch(self): | |
193 # Tests local branches pushing to a single dir repo. Creates a fork at | |
194 # tip. The default branch adds a file called default, while branch foo | |
195 # adds a file called foo, then tries to push the foo branch and default | |
196 # branch in that order. | |
197 repo, repo_path = self.load_and_fetch('branch_from_tag.svndump', | |
198 stupid=False, | |
199 layout='single', | |
200 subdir='') | |
201 def file_callback(data): | |
202 def cb(repo, memctx, path): | |
203 if path == data: | |
204 return context.memfilectx(path=path, | |
205 data=data, | |
206 islink=False, | |
207 isexec=False, | |
208 copied=False) | |
209 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | |
210 return cb | |
211 | |
212 def commit_to_branch(name, parent): | |
213 repo.commitctx(context.memctx(repo, | |
214 (parent, node.nullid), | |
215 'automated test (%s)' % name, | |
216 [name], | |
217 file_callback(name), | |
218 'an_author', | |
219 '2009-10-19 18:49:30 -0500', | |
220 {'branch': name, })) | |
221 | |
222 parent = repo['tip'].node() | |
223 commit_to_branch('default', parent) | |
224 commit_to_branch('foo', parent) | |
225 hg.update(repo, repo['foo'].node()) | |
226 self.pushrevisions() | |
227 repo = self.repo # repo is outdated after the rebase happens, refresh | |
228 self.assertTrue('foo' in test_util.svnls(repo_path, '')) | |
229 self.assertEqual(repo.branchtags().keys(), ['default']) | |
230 # Have to cross to another branch head, so hg.update doesn't work | |
231 commands.update(ui.ui(), | |
232 self.repo, | |
233 self.repo.branchheads('default')[1], | |
234 clean=True) | |
235 self.pushrevisions() | |
236 self.assertTrue('default' in test_util.svnls(repo_path, '')) | |
237 self.assertEquals(len(self.repo.branchheads('default')), 1) | |
238 | |
239 @test_util.requiresoption('branch') | |
240 def test_push_single_dir_renamed_branch(self, stupid=False): | |
241 # Tests pulling and pushing with a renamed branch | |
242 # Based on test_push_single_dir | |
243 repo_path = self.load_svndump('branch_from_tag.svndump') | |
244 cmd = ['clone', '--layout=single', '--branch=flaf'] | |
245 if stupid: | |
246 cmd.append('--stupid') | |
247 cmd += [test_util.fileurl(repo_path), self.wc_path] | |
248 test_util.dispatch(cmd) | |
249 | |
250 def file_callback(repo, memctx, path): | |
251 if path == 'adding_file': | |
252 return context.memfilectx(path=path, | |
253 data='foo', | |
254 islink=False, | |
255 isexec=False, | |
256 copied=False) | |
257 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | |
258 ctx = context.memctx(self.repo, | |
259 (self.repo['tip'].node(), node.nullid), | |
260 'automated test', | |
261 ['adding_file'], | |
262 file_callback, | |
263 'an_author', | |
264 '2009-10-19 18:49:30 -0500', | |
265 {'branch': 'default', }) | |
266 self.repo.commitctx(ctx) | |
267 hg.update(self.repo, self.repo['tip'].node()) | |
268 self.pushrevisions() | |
269 self.assertTrue('adding_file' in test_util.svnls(repo_path, '')) | |
270 | |
271 self.assertEquals(set(['flaf']), | |
272 set(self.repo[i].branch() for i in self.repo)) | |
273 | |
274 @test_util.requiresoption('branch') | |
275 def test_push_single_dir_renamed_branch_stupid(self): | |
276 self.test_push_single_dir_renamed_branch(True) | |
277 | |
278 def suite(): | |
279 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestSingleDir)] | |
280 return unittest.TestSuite(all_tests) |