Mercurial > hgsubversion
comparison tests/test_push_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 | b33940d54fe2 |
children | 83179a183927 |
comparison
equal
deleted
inserted
replaced
77:ed3dd5bf45da | 78:072010a271c6 |
---|---|
1 import os | 1 import os |
2 import shutil | |
3 import socket | 2 import socket |
3 import subprocess | |
4 import tempfile | 4 import tempfile |
5 import unittest | 5 import unittest |
6 | 6 |
7 from mercurial import context | 7 from mercurial import context |
8 from mercurial import commands | 8 from mercurial import commands |
39 pass | 39 pass |
40 if user_has_own_svnserve: | 40 if user_has_own_svnserve: |
41 assert False, ('You appear to be running your own svnserve!' | 41 assert False, ('You appear to be running your own svnserve!' |
42 ' You can probably ignore this test failure.') | 42 ' You can probably ignore this test failure.') |
43 args = ['svnserve', '-d', '--foreground', '-r', self.repo_path] | 43 args = ['svnserve', '-d', '--foreground', '-r', self.repo_path] |
44 self.svnserve_pid = os.spawnvp(os.P_NOWAIT, 'svnserve', args) | 44 self.svnserve_pid = subprocess.Popen(args).pid |
45 time.sleep(2) | 45 time.sleep(2) |
46 fetch_command.fetch_revisions(ui.ui(), | 46 fetch_command.fetch_revisions(ui.ui(), |
47 svn_url='svn://localhost/', | 47 svn_url='svn://localhost/', |
48 hg_repo_path=self.wc_path) | 48 hg_repo_path=self.wc_path) |
49 | 49 |
50 def tearDown(self): | 50 def tearDown(self): |
51 shutil.rmtree(self.tmpdir) | 51 test_util.rmtree(self.tmpdir) |
52 os.chdir(self.oldwd) | 52 os.chdir(self.oldwd) |
53 os.system('kill -9 %d' % self.svnserve_pid) | 53 os.system('kill -9 %d' % self.svnserve_pid) |
54 | 54 |
55 # define this as a property so that it reloads anytime we need it | 55 # define this as a property so that it reloads anytime we need it |
56 @property | 56 @property |
95 def setUp(self): | 95 def setUp(self): |
96 self.oldwd = os.getcwd() | 96 self.oldwd = os.getcwd() |
97 self.tmpdir = tempfile.mkdtemp('svnwrap_test') | 97 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
98 self.repo_path = '%s/testrepo' % self.tmpdir | 98 self.repo_path = '%s/testrepo' % self.tmpdir |
99 self.wc_path = '%s/testrepo_wc' % self.tmpdir | 99 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
100 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') | 100 test_util.load_fixture_and_fetch('simple_branch.svndump', |
101 fetch_command.fetch_revisions(ui.ui(), | 101 self.repo_path, |
102 svn_url='file://%s' % self.repo_path, | 102 self.wc_path) |
103 hg_repo_path=self.wc_path) | |
104 | 103 |
105 # define this as a property so that it reloads anytime we need it | 104 # define this as a property so that it reloads anytime we need it |
106 @property | 105 @property |
107 def repo(self): | 106 def repo(self): |
108 return hg.repository(ui.ui(), self.wc_path) | 107 return hg.repository(ui.ui(), self.wc_path) |
109 | 108 |
109 def pushrevisions(self): | |
110 push_cmd.push_revisions_to_subversion( | |
111 ui.ui(), repo=self.repo, hg_repo_path=self.wc_path, | |
112 svn_url=test_util.fileurl(self.repo_path)) | |
113 | |
110 def tearDown(self): | 114 def tearDown(self): |
111 shutil.rmtree(self.tmpdir) | 115 test_util.rmtree(self.tmpdir) |
112 os.chdir(self.oldwd) | 116 os.chdir(self.oldwd) |
113 | 117 |
114 def test_push_to_default(self, commit=True): | 118 def test_push_to_default(self, commit=True): |
115 repo = self.repo | 119 repo = self.repo |
116 old_tip = repo['tip'].node() | 120 old_tip = repo['tip'].node() |
133 {'branch': 'default',}) | 137 {'branch': 'default',}) |
134 new_hash = repo.commitctx(ctx) | 138 new_hash = repo.commitctx(ctx) |
135 if not commit: | 139 if not commit: |
136 return # some tests use this test as an extended setup. | 140 return # some tests use this test as an extended setup. |
137 hg.update(repo, repo['tip'].node()) | 141 hg.update(repo, repo['tip'].node()) |
138 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 142 self.pushrevisions() |
139 hg_repo_path=self.wc_path, | |
140 svn_url='file://'+self.repo_path) | |
141 tip = self.repo['tip'] | 143 tip = self.repo['tip'] |
142 self.assertNotEqual(tip.node(), old_tip) | 144 self.assertNotEqual(tip.node(), old_tip) |
143 self.assertEqual(tip.parents()[0].node(), expected_parent) | 145 self.assertEqual(tip.parents()[0].node(), expected_parent) |
144 self.assertEqual(tip['adding_file'].data(), 'foo') | 146 self.assertEqual(tip['adding_file'].data(), 'foo') |
145 self.assertEqual(tip.branch(), 'default') | 147 self.assertEqual(tip.branch(), 'default') |
166 'an_author', | 168 'an_author', |
167 '2008-10-07 20:59:48 -0500', | 169 '2008-10-07 20:59:48 -0500', |
168 {'branch': 'default',}) | 170 {'branch': 'default',}) |
169 new_hash = repo.commitctx(ctx) | 171 new_hash = repo.commitctx(ctx) |
170 hg.update(repo, repo['tip'].node()) | 172 hg.update(repo, repo['tip'].node()) |
171 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 173 self.pushrevisions() |
172 hg_repo_path=self.wc_path, | |
173 svn_url='file://'+self.repo_path) | |
174 tip = self.repo['tip'] | 174 tip = self.repo['tip'] |
175 self.assertNotEqual(tip.node(), old_tip) | 175 self.assertNotEqual(tip.node(), old_tip) |
176 self.assertNotEqual(tip.parents()[0].node(), old_tip) | 176 self.assertNotEqual(tip.parents()[0].node(), old_tip) |
177 self.assertEqual(tip.parents()[0].parents()[0].node(), expected_parent) | 177 self.assertEqual(tip.parents()[0].parents()[0].node(), expected_parent) |
178 self.assertEqual(tip['adding_file2'].data(), 'foo2') | 178 self.assertEqual(tip['adding_file2'].data(), 'foo2') |
204 '2008-10-07 20:59:48 -0500', | 204 '2008-10-07 20:59:48 -0500', |
205 {'branch': 'the_branch',}) | 205 {'branch': 'the_branch',}) |
206 new_hash = repo.commitctx(ctx) | 206 new_hash = repo.commitctx(ctx) |
207 #commands.update(ui.ui(), self.repo, node='tip') | 207 #commands.update(ui.ui(), self.repo, node='tip') |
208 hg.update(repo, repo['tip'].node()) | 208 hg.update(repo, repo['tip'].node()) |
209 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 209 self.pushrevisions() |
210 hg_repo_path=self.wc_path, | |
211 svn_url='file://'+self.repo_path) | |
212 tip = self.repo['tip'] | 210 tip = self.repo['tip'] |
213 self.assertNotEqual(tip.node(), new_hash) | 211 self.assertNotEqual(tip.node(), new_hash) |
214 self.assertEqual(tip['adding_file'].data(), 'foo') | 212 self.assertEqual(tip['adding_file'].data(), 'foo') |
215 self.assertEqual(tip.branch(), 'the_branch') | 213 self.assertEqual(tip.branch(), 'the_branch') |
216 | 214 |
227 'an author', | 225 'an author', |
228 '2008-10-29 21:26:00 -0500', | 226 '2008-10-29 21:26:00 -0500', |
229 {'branch': 'default', }) | 227 {'branch': 'default', }) |
230 new_hash = repo.commitctx(ctx) | 228 new_hash = repo.commitctx(ctx) |
231 hg.update(repo, repo['tip'].node()) | 229 hg.update(repo, repo['tip'].node()) |
232 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 230 self.pushrevisions() |
233 hg_repo_path=self.wc_path, | |
234 svn_url='file://' + self.repo_path) | |
235 tip = self.repo['tip'] | 231 tip = self.repo['tip'] |
236 self.assertEqual(old_files, | 232 self.assertEqual(old_files, |
237 set(tip.manifest().keys() + ['alpha'])) | 233 set(tip.manifest().keys() + ['alpha'])) |
238 self.assert_('alpha' not in tip.manifest()) | 234 self.assert_('alpha' not in tip.manifest()) |
239 | 235 |
256 'author', | 252 'author', |
257 '2008-10-29 21:26:00 -0500', | 253 '2008-10-29 21:26:00 -0500', |
258 {'branch': 'default', }) | 254 {'branch': 'default', }) |
259 new_hash = repo.commitctx(ctx) | 255 new_hash = repo.commitctx(ctx) |
260 hg.update(repo, repo['tip'].node()) | 256 hg.update(repo, repo['tip'].node()) |
261 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 257 self.pushrevisions() |
262 hg_repo_path=self.wc_path, | |
263 svn_url='file://' + self.repo_path) | |
264 tip = self.repo['tip'] | 258 tip = self.repo['tip'] |
265 self.assertNotEqual(tip.node(), new_hash) | 259 self.assertNotEqual(tip.node(), new_hash) |
266 self.assert_('@' in tip.user()) | 260 self.assert_('@' in tip.user()) |
267 self.assertEqual(tip['gamma'].flags(), 'x') | 261 self.assertEqual(tip['gamma'].flags(), 'x') |
268 self.assertEqual(tip['gamma'].data(), 'foo') | 262 self.assertEqual(tip['gamma'].data(), 'foo') |
288 'author', | 282 'author', |
289 '2008-10-29 21:26:00 -0500', | 283 '2008-10-29 21:26:00 -0500', |
290 {'branch': 'default', }) | 284 {'branch': 'default', }) |
291 new_hash = repo.commitctx(ctx) | 285 new_hash = repo.commitctx(ctx) |
292 hg.update(repo, repo['tip'].node()) | 286 hg.update(repo, repo['tip'].node()) |
293 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 287 self.pushrevisions() |
294 hg_repo_path=self.wc_path, | |
295 svn_url='file://' + self.repo_path) | |
296 tip = self.repo['tip'] | 288 tip = self.repo['tip'] |
297 self.assertNotEqual(tip.node(), new_hash) | 289 self.assertNotEqual(tip.node(), new_hash) |
298 self.assertEqual(tip['gamma'].flags(), 'l') | 290 self.assertEqual(tip['gamma'].flags(), 'l') |
299 self.assertEqual(tip['gamma'].data(), 'foo') | 291 self.assertEqual(tip['gamma'].data(), 'foo') |
300 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in | 292 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in |
319 'author', | 311 'author', |
320 '2008-10-29 21:26:00 -0500', | 312 '2008-10-29 21:26:00 -0500', |
321 {'branch': 'default', }) | 313 {'branch': 'default', }) |
322 new_hash = repo.commitctx(ctx) | 314 new_hash = repo.commitctx(ctx) |
323 hg.update(repo, repo['tip'].node()) | 315 hg.update(repo, repo['tip'].node()) |
324 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 316 self.pushrevisions() |
325 hg_repo_path=self.wc_path, | |
326 svn_url='file://' + self.repo_path) | |
327 tip = self.repo['tip'] | 317 tip = self.repo['tip'] |
328 self.assertNotEqual(tip.node(), new_hash) | 318 self.assertNotEqual(tip.node(), new_hash) |
329 self.assertEqual(tip['newdir/gamma'].data(), 'foo') | 319 self.assertEqual(tip['newdir/gamma'].data(), 'foo') |
330 | 320 |
331 def test_push_with_new_subdir(self): | 321 def test_push_with_new_subdir(self): |
380 'author', | 370 'author', |
381 '2008-1-1 00:00:00 -0500', | 371 '2008-1-1 00:00:00 -0500', |
382 {'branch': 'default', }) | 372 {'branch': 'default', }) |
383 new_hash = repo.commitctx(ctx) | 373 new_hash = repo.commitctx(ctx) |
384 hg.update(repo, repo['tip'].node()) | 374 hg.update(repo, repo['tip'].node()) |
385 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 375 self.pushrevisions() |
386 hg_repo_path=self.wc_path, | |
387 svn_url='file://' + self.repo_path) | |
388 tip = self.repo['tip'] | 376 tip = self.repo['tip'] |
389 self.assertNotEqual(tip.node(), new_hash) | 377 self.assertNotEqual(tip.node(), new_hash) |
390 self.assertEqual(tip['alpha'].data(), 'foo') | 378 self.assertEqual(tip['alpha'].data(), 'foo') |
391 self.assertEqual(tip.parents()[0]['alpha'].flags(), '') | 379 self.assertEqual(tip.parents()[0]['alpha'].flags(), '') |
392 self.assertEqual(tip['alpha'].flags(), expected_flags) | 380 self.assertEqual(tip['alpha'].flags(), expected_flags) |
407 'author', | 395 'author', |
408 '2008-1-1 00:00:00 -0500', | 396 '2008-1-1 00:00:00 -0500', |
409 {'branch': 'default', }) | 397 {'branch': 'default', }) |
410 new_hash = repo.commitctx(ctx) | 398 new_hash = repo.commitctx(ctx) |
411 hg.update(repo, repo['tip'].node()) | 399 hg.update(repo, repo['tip'].node()) |
412 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 400 self.pushrevisions() |
413 hg_repo_path=self.wc_path, | |
414 svn_url='file://' + self.repo_path) | |
415 tip = self.repo['tip'] | 401 tip = self.repo['tip'] |
416 self.assertNotEqual(tip.node(), new_hash) | 402 self.assertNotEqual(tip.node(), new_hash) |
417 self.assertEqual(tip['alpha'].data(), 'bar') | 403 self.assertEqual(tip['alpha'].data(), 'bar') |
418 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) | 404 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) |
419 self.assertEqual(tip['alpha'].flags(), expected_flags) | 405 self.assertEqual(tip['alpha'].flags(), expected_flags) |
433 'author', | 419 'author', |
434 '2008-01-01 00:00:00 -0500', | 420 '2008-01-01 00:00:00 -0500', |
435 {'branch': 'default', }) | 421 {'branch': 'default', }) |
436 new_hash = repo.commitctx(ctx) | 422 new_hash = repo.commitctx(ctx) |
437 hg.update(repo, repo['tip'].node()) | 423 hg.update(repo, repo['tip'].node()) |
438 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 424 self.pushrevisions() |
439 hg_repo_path=self.wc_path, | |
440 svn_url='file://' + self.repo_path) | |
441 tip = self.repo['tip'] | 425 tip = self.repo['tip'] |
442 self.assertNotEqual(tip.node(), new_hash) | 426 self.assertNotEqual(tip.node(), new_hash) |
443 self.assertEqual(tip['alpha'].data(), 'bar') | 427 self.assertEqual(tip['alpha'].data(), 'bar') |
444 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) | 428 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) |
445 self.assertEqual(tip['alpha'].flags(), '') | 429 self.assertEqual(tip['alpha'].flags(), '') |