Mercurial > hgsubversion
comparison tests/test_pull.py @ 331:75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
The 'hg svn url' command has been killed; the replacement is
'.hg/hgrc'. More stuff related to its disappearance has been stripped,
including two tests.
HgChangeReceiver now takes a UUID argument, which it uses to ensure
that remote repositories remain unchanged. This is a temporary
solution, and I'm not entirely satisfied with how it's done either.
Access to the UUID file has been isolated in a HgChangeReceiver
property.
Some more tests have been updated to use ui.pushbuffer()/popbuffer(),
and to pass through the Mercurial API.
Moved the arguments to wrappers.pull() to the UI configuration.
Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames'
instance & configuration variable. The name is taken from the
ConvertExtension.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 15 May 2009 19:18:43 +0200 |
parents | 521d9c1bb11d |
children | 76c833526fbc |
comparison
equal
deleted
inserted
replaced
330:5f8f2fd4fd54 | 331:75f082b5897e |
---|---|
1 import test_util | 1 import test_util |
2 | 2 |
3 import os.path | 3 import os.path |
4 import subprocess | 4 import subprocess |
5 from mercurial import ui | 5 from mercurial import ui |
6 | 6 from mercurial import util as hgutil |
7 import wrappers | 7 from mercurial import commands |
8 | |
9 | 8 |
10 class TestPull(test_util.TestBase): | 9 class TestPull(test_util.TestBase): |
11 def setUp(self): | 10 def setUp(self): |
12 super(TestPull, self).setUp() | 11 super(TestPull, self).setUp() |
13 self.svn_wc = None | 12 self.svn_wc = None |
20 def _add_svn_rev(self, changes): | 19 def _add_svn_rev(self, changes): |
21 # changes is a dict of filename -> contents | 20 # changes is a dict of filename -> contents |
22 if self.svn_wc is None: | 21 if self.svn_wc is None: |
23 self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc') | 22 self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc') |
24 subprocess.call([ | 23 subprocess.call([ |
25 'svn', 'co', '-q', test_util.fileurl(self.repo_path), | 24 'svn', 'co', '-q', test_util.fileurl(self.repo_path)[4:], |
26 self.svn_wc | 25 self.svn_wc |
27 ]) | 26 ], |
27 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
28 | 28 |
29 for filename, contents in changes.iteritems(): | 29 for filename, contents in changes.iteritems(): |
30 # filenames are / separated | 30 # filenames are / separated |
31 filename = filename.replace('/', os.path.sep) | 31 filename = filename.replace('/', os.path.sep) |
32 filename = os.path.join(self.svn_wc, filename) | 32 filename = os.path.join(self.svn_wc, filename) |
33 open(filename, 'w').write(contents) | 33 open(filename, 'w').write(contents) |
34 subprocess.call(['svn', 'add', '-q', filename]) # may be redundant | 34 # may be redundant |
35 subprocess.call(['svn', 'add', '-q', filename], | |
36 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
35 subprocess.call([ | 37 subprocess.call([ |
36 'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes']) | 38 'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes'], |
39 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
37 | 40 |
38 def test_nochanges(self): | 41 def test_nochanges(self): |
39 repo = self._load_fixture_and_fetch('single_rev.svndump') | 42 self._load_fixture_and_fetch('single_rev.svndump') |
40 state = repo.parents() | 43 state = self.repo.parents() |
41 wrappers.pull(None, ui.ui(), repo) | 44 commands.pull(self.repo.ui, self.repo) |
42 self.assertEqual(state, repo.parents()) | 45 self.assertEqual(state, self.repo.parents()) |
43 | 46 |
44 def test_onerevision_noupdate(self): | 47 def test_onerevision_noupdate(self): |
45 repo = self._load_fixture_and_fetch('single_rev.svndump') | 48 repo = self._load_fixture_and_fetch('single_rev.svndump') |
46 state = repo.parents() | 49 state = repo.parents() |
47 self._add_svn_rev({'trunk/alpha': 'Changed'}) | 50 self._add_svn_rev({'trunk/alpha': 'Changed'}) |
48 wrappers.pull(None, ui.ui(), repo) | 51 commands.pull(self.repo.ui, repo) |
49 self.assertEqual(state, repo.parents()) | 52 self.assertEqual(state, repo.parents()) |
50 self.assertTrue('tip' not in repo[None].tags()) | 53 self.assertTrue('tip' not in repo[None].tags()) |
51 | 54 |
52 def test_onerevision_doupdate(self): | 55 def test_onerevision_doupdate(self): |
53 repo = self._load_fixture_and_fetch('single_rev.svndump') | 56 repo = self._load_fixture_and_fetch('single_rev.svndump') |
54 state = repo.parents() | 57 state = repo.parents() |
55 self._add_svn_rev({'trunk/alpha': 'Changed'}) | 58 self._add_svn_rev({'trunk/alpha': 'Changed'}) |
56 wrappers.pull(None, ui.ui(), repo, update=True) | 59 commands.pull(self.repo.ui, repo, update=True) |
57 self.failIfEqual(state, repo.parents()) | 60 self.failIfEqual(state, repo.parents()) |
58 self.assertTrue('tip' in repo[None].tags()) | 61 self.assertTrue('tip' in repo[None].tags()) |
59 | 62 |
60 def test_onerevision_divergent(self): | 63 def test_onerevision_divergent(self): |
61 repo = self._load_fixture_and_fetch('single_rev.svndump') | 64 repo = self._load_fixture_and_fetch('single_rev.svndump') |
62 self.commitchanges((('alpha', 'alpha', 'Changed another way'),)) | 65 self.commitchanges((('alpha', 'alpha', 'Changed another way'),)) |
63 state = repo.parents() | 66 state = repo.parents() |
64 self._add_svn_rev({'trunk/alpha': 'Changed one way'}) | 67 self._add_svn_rev({'trunk/alpha': 'Changed one way'}) |
65 wrappers.pull(None, ui.ui(), repo, update=True) | 68 self.assertRaises(hgutil.Abort, commands.pull, |
69 self.repo.ui, repo, update=True) | |
66 self.assertEqual(state, repo.parents()) | 70 self.assertEqual(state, repo.parents()) |
67 self.assertTrue('tip' not in repo[None].tags()) | 71 self.assertTrue('tip' not in repo[None].tags()) |
68 self.assertEqual(len(repo.heads()), 2) | 72 self.assertEqual(len(repo.heads()), 2) |
69 | 73 |
70 def suite(): | 74 def suite(): |