Mercurial > hgsubversion
annotate tests/test_externals.py @ 174:f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 02 Jan 2009 15:54:05 -0600 |
parents | |
children | 2412800b1258 |
rev | line source |
---|---|
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 import cStringIO |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 import os |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 import shutil |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
4 import sys |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 import tempfile |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
6 import unittest |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
8 from mercurial import hg |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 from mercurial import ui |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
10 from mercurial import node |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 import fetch_command |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
13 import svnexternals |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 import test_util |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
16 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
17 class TestFetchExternals(test_util.TestBase): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
18 def test_externalsfile(self): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 f = svnexternals.externalsfile() |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
20 f['t1'] = 'dir1 -r10 svn://foobar' |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
21 f['t 2'] = 'dir2 -r10 svn://foobar' |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
22 f['t3'] = ['dir31 -r10 svn://foobar', 'dir32 -r10 svn://foobar'] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 refext = """\ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 [t 2] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
26 dir2 -r10 svn://foobar |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 [t1] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 dir1 -r10 svn://foobar |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
29 [t3] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
30 dir31 -r10 svn://foobar |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 dir32 -r10 svn://foobar |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 value = f.write() |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
34 self.assertEqual(refext, value) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
35 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
36 f2 = svnexternals.externalsfile() |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
37 f2.read(value) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
38 self.assertEqual(sorted(f), sorted(f2)) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
39 for t in f: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
40 self.assertEqual(f[t], f2[t]) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
41 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
42 def test_externals(self, stupid=False): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
43 repo = self._load_fixture_and_fetch('externals.svndump', stupid=stupid) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
44 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
45 ref0 = """\ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
46 [.] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
47 ../externals/project1 deps/project1 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
48 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
49 self.assertEqual(ref0, repo[0]['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
50 ref1 = """\ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
51 [.] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
52 ../externals/project1 deps/project1 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
53 ../externals/project2 deps/project2 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
55 self.assertEqual(ref1, repo[1]['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
56 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
57 ref2 = """\ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
58 [.] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
59 ../externals/project2 deps/project2 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
60 [subdir] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
61 ../externals/project1 deps/project1 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
62 [subdir2] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
63 ../externals/project1 deps/project1 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
64 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
65 self.assertEqual(ref2, repo[2]['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
66 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
67 ref3 = """\ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
68 [.] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
69 ../externals/project2 deps/project2 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
70 [subdir2] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
71 ../externals/project1 deps/project1 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
72 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
73 self.assertEqual(ref3, repo[3]['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
74 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
75 ref4 = """\ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
76 [.] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
77 ../externals/project2 deps/project2 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
78 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
79 self.assertEqual(ref4, repo[4]['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
80 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
81 def test_externals_stupid(self): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
82 self.test_externals(True) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
83 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
84 def suite(): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
85 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchExternals), |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
86 ] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
87 return unittest.TestSuite(all) |