diff tests/test_externals.py @ 762:c31a1f92e1c6

svnexternals: preliminary support for subrepos based externals At this point, only pulling externals definitions into .hgsub and .hgsubstate is supported. One difference between subrepos and svn:externals is the former separate the source definition and target revision in two files, while svn:externals definitions contain both. To handle this, the svn:externals revision references is replaced with a {REV} placeholder and stored in .hgsub, prefixed with the external base directory separated with a ':', while the revision is extracted in .hgsubstate. For instance, the following external: -r3 ^/externals/proj2@2 deps/proj2 Becomes: (.hgsub) deps/proj2 = [hgsubversion] :-r{REV} ^/externals/proj2@2 deps/proj2 (.hgsubstate) 3 deps/proj2
author Patrick Mezard <pmezard@gmail.com>
date Thu, 25 Nov 2010 21:55:21 +0100
parents 979148947967
children 6463b34bbcb6
line wrap: on
line diff
--- a/tests/test_externals.py
+++ b/tests/test_externals.py
@@ -139,6 +139,72 @@ class TestFetchExternals(test_util.TestB
                   ['subdir2/deps/project1'], repo, 3)
         checkdeps(['subdir/deps/project1'], ['deps/project2'], repo, 4)
 
+    def test_hgsub(self, stupid=False):
+        repo = self._load_fixture_and_fetch('externals.svndump',
+                                            externals='subrepos',
+                                            stupid=stupid)
+        self.assertEqual("""\
+deps/project1 = [hgsubversion] :^/externals/project1 deps/project1
+""", repo[0]['.hgsub'].data())
+        self.assertEqual("""\
+HEAD deps/project1
+""", repo[0]['.hgsubstate'].data())
+
+        self.assertEqual("""\
+deps/project1 = [hgsubversion] :^/externals/project1 deps/project1
+deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2
+""", repo[1]['.hgsub'].data())
+        self.assertEqual("""\
+HEAD deps/project1
+2 deps/project2
+""", repo[1]['.hgsubstate'].data())
+
+        self.assertEqual("""\
+deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2
+subdir/deps/project1 = [hgsubversion] subdir:^/externals/project1 deps/project1
+subdir2/deps/project1 = [hgsubversion] subdir2:^/externals/project1 deps/project1
+""", repo[2]['.hgsub'].data())
+        self.assertEqual("""\
+2 deps/project2
+HEAD subdir/deps/project1
+HEAD subdir2/deps/project1
+""", repo[2]['.hgsubstate'].data())
+
+        self.assertEqual("""\
+deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2
+subdir/deps/project1 = [hgsubversion] subdir:^/externals/project1 deps/project1
+""", repo[3]['.hgsub'].data())
+        self.assertEqual("""\
+2 deps/project2
+HEAD subdir/deps/project1
+""", repo[3]['.hgsubstate'].data())
+
+        self.assertEqual("""\
+subdir/deps/project1 = [hgsubversion] subdir:^/externals/project1 deps/project1
+""", repo[4]['.hgsub'].data())
+        self.assertEqual("""\
+HEAD subdir/deps/project1
+""", repo[4]['.hgsubstate'].data())
+
+        self.assertEqual("""\
+deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2
+subdir2/deps/project1 = [hgsubversion] subdir2:^/externals/project1 deps/project1
+""", repo[5]['.hgsub'].data())
+        self.assertEqual("""\
+2 deps/project2
+HEAD subdir2/deps/project1
+""", repo[5]['.hgsubstate'].data())
+
+        self.assertEqual("""\
+deps/project2 = [hgsubversion] :-r{REV} ^/externals/project2@2 deps/project2
+""", repo[6]['.hgsub'].data())
+        self.assertEqual("""\
+2 deps/project2
+""", repo[6]['.hgsubstate'].data())
+
+    def test_hgsub_stupid(self):
+        self.test_hgsub(True)
+
 class TestPushExternals(test_util.TestBase):
     def setUp(self):
         test_util.TestBase.setUp(self)