Mercurial > hgsubversion
comparison tests/test_pull.py @ 283:521d9c1bb11d
Implement -u/--update support when pulling.
Status messages now more closely follow standard hg pull. Added generic pull
tests as well as specific tests for this change.
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Mon, 27 Apr 2009 09:39:39 -0500 |
parents | |
children | 75f082b5897e |
comparison
equal
deleted
inserted
replaced
282:77892f67b1cd | 283:521d9c1bb11d |
---|---|
1 import test_util | |
2 | |
3 import os.path | |
4 import subprocess | |
5 from mercurial import ui | |
6 | |
7 import wrappers | |
8 | |
9 | |
10 class TestPull(test_util.TestBase): | |
11 def setUp(self): | |
12 super(TestPull, self).setUp() | |
13 self.svn_wc = None | |
14 | |
15 def _load_fixture_and_fetch(self, fixture_name): | |
16 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, | |
17 self.wc_path, stupid=False, | |
18 noupdate=False) | |
19 | |
20 def _add_svn_rev(self, changes): | |
21 # changes is a dict of filename -> contents | |
22 if self.svn_wc is None: | |
23 self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc') | |
24 subprocess.call([ | |
25 'svn', 'co', '-q', test_util.fileurl(self.repo_path), | |
26 self.svn_wc | |
27 ]) | |
28 | |
29 for filename, contents in changes.iteritems(): | |
30 # filenames are / separated | |
31 filename = filename.replace('/', os.path.sep) | |
32 filename = os.path.join(self.svn_wc, filename) | |
33 open(filename, 'w').write(contents) | |
34 subprocess.call(['svn', 'add', '-q', filename]) # may be redundant | |
35 subprocess.call([ | |
36 'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes']) | |
37 | |
38 def test_nochanges(self): | |
39 repo = self._load_fixture_and_fetch('single_rev.svndump') | |
40 state = repo.parents() | |
41 wrappers.pull(None, ui.ui(), repo) | |
42 self.assertEqual(state, repo.parents()) | |
43 | |
44 def test_onerevision_noupdate(self): | |
45 repo = self._load_fixture_and_fetch('single_rev.svndump') | |
46 state = repo.parents() | |
47 self._add_svn_rev({'trunk/alpha': 'Changed'}) | |
48 wrappers.pull(None, ui.ui(), repo) | |
49 self.assertEqual(state, repo.parents()) | |
50 self.assertTrue('tip' not in repo[None].tags()) | |
51 | |
52 def test_onerevision_doupdate(self): | |
53 repo = self._load_fixture_and_fetch('single_rev.svndump') | |
54 state = repo.parents() | |
55 self._add_svn_rev({'trunk/alpha': 'Changed'}) | |
56 wrappers.pull(None, ui.ui(), repo, update=True) | |
57 self.failIfEqual(state, repo.parents()) | |
58 self.assertTrue('tip' in repo[None].tags()) | |
59 | |
60 def test_onerevision_divergent(self): | |
61 repo = self._load_fixture_and_fetch('single_rev.svndump') | |
62 self.commitchanges((('alpha', 'alpha', 'Changed another way'),)) | |
63 state = repo.parents() | |
64 self._add_svn_rev({'trunk/alpha': 'Changed one way'}) | |
65 wrappers.pull(None, ui.ui(), repo, update=True) | |
66 self.assertEqual(state, repo.parents()) | |
67 self.assertTrue('tip' not in repo[None].tags()) | |
68 self.assertEqual(len(repo.heads()), 2) | |
69 | |
70 def suite(): | |
71 import unittest, sys | |
72 return unittest.findTestCases(sys.modules[__name__]) |