comparison tests/test_fetch_command.py @ 78:072010a271c6

Fix basic issues with tests on Windows - shutil.rmtree() fails if there are any read-only files (svn store) - Fix files:// URLs - os.spawnvp()/Popen4() do not exist under Windows, use subprocess
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 Nov 2008 18:08:35 -0600
parents e319c9168910
children 7d10165cf3d9
comparison
equal deleted inserted replaced
77:ed3dd5bf45da 78:072010a271c6
1 import os 1 import os
2 import shutil
3 import tempfile 2 import tempfile
4 import unittest 3 import unittest
5 4
6 from mercurial import hg 5 from mercurial import hg
7 from mercurial import ui 6 from mercurial import ui
17 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 16 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
18 self.repo_path = '%s/testrepo' % self.tmpdir 17 self.repo_path = '%s/testrepo' % self.tmpdir
19 self.wc_path = '%s/testrepo_wc' % self.tmpdir 18 self.wc_path = '%s/testrepo_wc' % self.tmpdir
20 19
21 def tearDown(self): 20 def tearDown(self):
22 shutil.rmtree(self.tmpdir) 21 test_util.rmtree(self.tmpdir)
23 os.chdir(self.oldwd) 22 os.chdir(self.oldwd)
24 23
25 def _load_fixture_and_fetch(self, fixture_name): 24 def _load_fixture_and_fetch(self, fixture_name):
26 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, 25 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
27 self.wc_path) 26 self.wc_path)
127 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 126 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
128 self.repo_path = '%s/testrepo' % self.tmpdir 127 self.repo_path = '%s/testrepo' % self.tmpdir
129 self.wc_path = '%s/testrepo_wc' % self.tmpdir 128 self.wc_path = '%s/testrepo_wc' % self.tmpdir
130 129
131 def tearDown(self): 130 def tearDown(self):
132 shutil.rmtree(self.tmpdir) 131 test_util.rmtree(self.tmpdir)
133 os.chdir(self.oldwd) 132 os.chdir(self.oldwd)
134 133
135 def test_stupid(self): 134 def test_stupid(self):
136 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') 135 repo = test_util.load_fixture_and_fetch('two_heads.svndump',
137 fetch_command.fetch_revisions(ui.ui(), 136 self.repo_path,
138 svn_url='file://%s' % self.repo_path, 137 self.wc_path,
139 hg_repo_path=self.wc_path, 138 True)
140 stupid=True)
141 repo = hg.repository(ui.ui(), self.wc_path)
142 # TODO there must be a better way than repo[0] for this check 139 # TODO there must be a better way than repo[0] for this check
143 self.assertEqual(node.hex(repo[0].node()), 140 self.assertEqual(node.hex(repo[0].node()),
144 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') 141 'a47d0ce778660a91c31bf2c21c448e9ee296ac90')
145 self.assertEqual(node.hex(repo['tip'].node()), 142 self.assertEqual(node.hex(repo['tip'].node()),
146 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf') 143 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf')
151 self.assertEqual(len(repo['tip'].parents()), 1) 148 self.assertEqual(len(repo['tip'].parents()), 1)
152 self.assertEqual(repo['tip'], repo['default']) 149 self.assertEqual(repo['tip'], repo['default'])
153 self.assertEqual(len(repo.heads()), 2) 150 self.assertEqual(len(repo.heads()), 2)
154 151
155 def test_oldest_not_trunk_and_tag_vendor_branch(self): 152 def test_oldest_not_trunk_and_tag_vendor_branch(self):
156 test_util.load_svndump_fixture(self.repo_path, 153 repo = test_util.load_fixture_and_fetch(
157 'tagged_vendor_and_oldest_not_trunk.svndump') 154 'tagged_vendor_and_oldest_not_trunk.svndump',
158 fetch_command.fetch_revisions(ui.ui(), 155 self.repo_path,
159 svn_url='file://%s' % self.repo_path, 156 self.wc_path,
160 hg_repo_path=self.wc_path, 157 True)
161 stupid=True)
162 repo = hg.repository(ui.ui(), self.wc_path) 158 repo = hg.repository(ui.ui(), self.wc_path)
163 self.assertEqual(node.hex(repo['oldest'].node()), 159 self.assertEqual(node.hex(repo['oldest'].node()),
164 'd73002bcdeffe389a8df81ee43303d36e79e8ca4') 160 'd73002bcdeffe389a8df81ee43303d36e79e8ca4')
165 self.assertEqual(repo['tip'].parents()[0].parents()[0], 161 self.assertEqual(repo['tip'].parents()[0].parents()[0],
166 repo['oldest']) 162 repo['oldest'])