comparison tests/test_externals.py @ 764:bc5c176b63eb

svnexternals: support pushing subrepo based externals
author Patrick Mezard <pmezard@gmail.com>
date Thu, 25 Nov 2010 21:55:21 +0100
parents 6463b34bbcb6
children f025d00bfc4a
comparison
equal deleted inserted replaced
763:6463b34bbcb6 764:bc5c176b63eb
240 checkdeps(ui, repo, 3, ['subdir/deps/project1', 'deps/project2'], 240 checkdeps(ui, repo, 3, ['subdir/deps/project1', 'deps/project2'],
241 ['subdir2/deps/project1']) 241 ['subdir2/deps/project1'])
242 checkdeps(ui, repo, 4, ['subdir/deps/project1'], ['deps/project2']) 242 checkdeps(ui, repo, 4, ['subdir/deps/project1'], ['deps/project2'])
243 243
244 class TestPushExternals(test_util.TestBase): 244 class TestPushExternals(test_util.TestBase):
245 def setUp(self): 245 def test_push_externals(self, stupid=False):
246 test_util.TestBase.setUp(self)
247 test_util.load_fixture_and_fetch('pushexternals.svndump', 246 test_util.load_fixture_and_fetch('pushexternals.svndump',
248 self.repo_path, 247 self.repo_path,
249 self.wc_path) 248 self.wc_path)
250
251 def test_push_externals(self, stupid=False):
252 # Add a new reference on an existing and non-existing directory 249 # Add a new reference on an existing and non-existing directory
253 changes = [ 250 changes = [
254 ('.hgsvnexternals', '.hgsvnexternals', 251 ('.hgsvnexternals', '.hgsvnexternals',
255 """[dir] 252 """[dir]
256 ../externals/project2 deps/project2 253 ../externals/project2 deps/project2
293 self.assertchanges(changes, self.repo['tip']) 290 self.assertchanges(changes, self.repo['tip'])
294 291
295 def test_push_externals_stupid(self): 292 def test_push_externals_stupid(self):
296 self.test_push_externals(True) 293 self.test_push_externals(True)
297 294
295 def test_push_hgsub(self, stupid=False):
296 if subrepo is None:
297 return
298
299 test_util.load_fixture_and_fetch('pushexternals.svndump',
300 self.repo_path,
301 self.wc_path,
302 externals='subrepos')
303 # Add a new reference on an existing and non-existing directory
304 changes = [
305 ('.hgsub', '.hgsub', """\
306 dir/deps/project2 = [hgsubversion] dir:^/externals/project2 deps/project2
307 subdir1/deps/project1 = [hgsubversion] subdir1:^/externals/project1 deps/project1
308 subdir2/deps/project2 = [hgsubversion] subdir2:^/externals/project2 deps/project2
309 """),
310 ('.hgsubstate', '.hgsubstate', """\
311 HEAD dir/deps/project2
312 HEAD subdir1/deps/project1
313 HEAD subdir2/deps/project2
314 """),
315 ('subdir1/a', 'subdir1/a', 'a'),
316 ('subdir2/a', 'subdir2/a', 'a'),
317 ]
318 self.svnco('externals/project2', '2', 'dir/deps/project2')
319 self.svnco('externals/project1', '2', 'subdir1/deps/project1')
320 self.svnco('externals/project2', '2', 'subdir2/deps/project2')
321 self.commitchanges(changes)
322 self.pushrevisions(stupid)
323 self.assertchanges(changes, self.repo['tip'])
324
325 # Check .hgsub and .hgsubstate were not pushed
326 self.assertEqual(['dir', 'subdir1', 'subdir1/a','subdir2',
327 'subdir2/a'], self.svnls('trunk'))
328
329 # Remove all references from one directory, add a new one
330 # to the other (test multiline entries)
331 changes = [
332 ('.hgsub', '.hgsub', """\
333 subdir1/deps/project1 = [hgsubversion] subdir1:^/externals/project1 deps/project1
334 subdir1/deps/project2 = [hgsubversion] subdir1:^/externals/project2 deps/project2
335 """),
336 ('.hgsubstate', '.hgsubstate', """\
337 HEAD subdir1/deps/project1
338 HEAD subdir1/deps/project2
339 """),
340 # This removal used to trigger the parent directory removal
341 ('subdir1/a', None, None),
342 ]
343 self.svnco('externals/project1', '2', 'subdir1/deps/project1')
344 self.svnco('externals/project2', '2', 'subdir1/deps/project2')
345 self.commitchanges(changes)
346 self.pushrevisions(stupid)
347 self.assertchanges(changes, self.repo['tip'])
348 # Check subdir2/a is still there even if the externals were removed
349 self.assertTrue('subdir2/a' in self.repo['tip'])
350 self.assertTrue('subdir1/a' not in self.repo['tip'])
351
352 # Test externals removal
353 changes = [
354 ('.hgsub', None, None),
355 ('.hgsubstate', None, None),
356 ]
357 self.commitchanges(changes)
358 self.pushrevisions(stupid)
359 self.assertchanges(changes, self.repo['tip'])
298 360
299 def suite(): 361 def suite():
300 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchExternals), 362 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchExternals),
301 unittest.TestLoader().loadTestsFromTestCase(TestPushExternals), 363 unittest.TestLoader().loadTestsFromTestCase(TestPushExternals),
302 ] 364 ]