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