Mercurial > hgsubversion
comparison tests/test_externals.py @ 291:ba8e91a7c077
Add 'updateexternals' to synchronize externals with remote repo.
To synchronize definitions in working copy .hgexternals with remote svn
repository:
$ hg svn updateexternals
To synchronize them with .hgexternals at revision REV:
$ hg svn updateexternals REV
Last synchronized externals referenced are stored in .hg/svn/externals (a dump
of the synchronized .hgexternals).
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 22 Apr 2009 23:24:58 +0200 |
parents | a360ddc97719 |
children | 963d27a0b1c2 |
comparison
equal
deleted
inserted
replaced
290:153266401676 | 291:ba8e91a7c077 |
---|---|
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' |
25 f2 = svnexternals.externalsfile() | 26 f2 = svnexternals.externalsfile() |
26 f2.read(value) | 27 f2.read(value) |
27 self.assertEqual(sorted(f), sorted(f2)) | 28 self.assertEqual(sorted(f), sorted(f2)) |
28 for t in f: | 29 for t in f: |
29 self.assertEqual(f[t], f2[t]) | 30 self.assertEqual(f[t], f2[t]) |
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)) | |
30 | 53 |
31 def test_externals(self, stupid=False): | 54 def test_externals(self, stupid=False): |
32 repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) | 55 repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) |
33 | 56 |
34 ref0 = """[.] | 57 ref0 = """[.] |
76 self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) | 99 self.assertEqual(ref6, repo[6]['.hgsvnexternals'].data()) |
77 | 100 |
78 def test_externals_stupid(self): | 101 def test_externals_stupid(self): |
79 self.test_externals(True) | 102 self.test_externals(True) |
80 | 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) | |
81 | 127 |
82 class TestPushExternals(test_util.TestBase): | 128 class TestPushExternals(test_util.TestBase): |
83 def setUp(self): | 129 def setUp(self): |
84 test_util.TestBase.setUp(self) | 130 test_util.TestBase.setUp(self) |
85 test_util.load_fixture_and_fetch('pushexternals.svndump', | 131 test_util.load_fixture_and_fetch('pushexternals.svndump', |