diff tests/test_externals.py @ 763:6463b34bbcb6

svnexternals: support subrepos based externals checkout
author Patrick Mezard <pmezard@gmail.com>
date Thu, 25 Nov 2010 21:55:21 +0100
parents c31a1f92e1c6
children bc5c176b63eb
line wrap: on
line diff
--- a/tests/test_externals.py
+++ b/tests/test_externals.py
@@ -1,8 +1,17 @@
 import test_util
 
-import os, unittest
+import os, unittest, sys
 
 from mercurial import commands
+from mercurial import util as hgutil
+try:
+    from mercurial import subrepo
+    # require svnsubrepo and hg >= 1.7.1
+    subrepo.svnsubrepo
+    hgutil.checknlink
+except (ImportError, AttributeError), e:
+    print >>sys.stderr, 'test_externals: skipping .hgsub tests'
+    subrepo = None
 
 from hgsubversion import svnexternals
 
@@ -205,6 +214,33 @@ 2 deps/project2
     def test_hgsub_stupid(self):
         self.test_hgsub(True)
 
+    def test_updatehgsub(self):
+        def checkdeps(ui, repo, rev, deps, nodeps):
+            commands.update(ui, repo, node=str(rev))
+            for d in deps:
+                p = os.path.join(repo.root, d)
+                self.assertTrue(os.path.isdir(p),
+                                'missing: %s@%r' % (d, repo[None].rev()))
+            for d in nodeps:
+                p = os.path.join(repo.root, d)
+                self.assertTrue(not os.path.isdir(p),
+                                'unexpected: %s@%r' % (d, repo[None].rev()))
+
+        if subrepo is None:
+            return
+
+        ui = self.ui()
+        repo = self._load_fixture_and_fetch('externals.svndump',
+                                            stupid=0, externals='subrepos')
+        checkdeps(ui, repo, 0, ['deps/project1'], [])
+        checkdeps(ui, repo, 1, ['deps/project1', 'deps/project2'], [])
+        checkdeps(ui, repo, 2, ['subdir/deps/project1', 'subdir2/deps/project1',
+                   'deps/project2'],
+                  ['deps/project1'])
+        checkdeps(ui, repo, 3, ['subdir/deps/project1', 'deps/project2'],
+                  ['subdir2/deps/project1'])
+        checkdeps(ui, repo, 4, ['subdir/deps/project1'], ['deps/project2'])
+
 class TestPushExternals(test_util.TestBase):
     def setUp(self):
         test_util.TestBase.setUp(self)