Mercurial > hgsubversion
annotate tests/test_pull.py @ 323:067914ecb4eb
push: Fix a bug in deletion of an entire tree.
This bug meant that if an entire subtree of the repo was
deleted and there were files at varying levels of the
hierarchy, then some of the files at higher levels
might escape deletion when the revision was pushed to svn.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 08 May 2009 16:26:33 -0500 |
parents | 521d9c1bb11d |
children | 75f082b5897e |
rev | line source |
---|---|
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
1 import test_util |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
2 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
3 import os.path |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
4 import subprocess |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
5 from mercurial import ui |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
6 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
7 import wrappers |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
8 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
9 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
10 class TestPull(test_util.TestBase): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
11 def setUp(self): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
12 super(TestPull, self).setUp() |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
13 self.svn_wc = None |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
14 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
15 def _load_fixture_and_fetch(self, fixture_name): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
16 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
17 self.wc_path, stupid=False, |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
18 noupdate=False) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
19 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
20 def _add_svn_rev(self, changes): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
21 # changes is a dict of filename -> contents |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
22 if self.svn_wc is None: |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
23 self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc') |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
24 subprocess.call([ |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
25 'svn', 'co', '-q', test_util.fileurl(self.repo_path), |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
26 self.svn_wc |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
27 ]) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
28 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
29 for filename, contents in changes.iteritems(): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
30 # filenames are / separated |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
31 filename = filename.replace('/', os.path.sep) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
32 filename = os.path.join(self.svn_wc, filename) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
33 open(filename, 'w').write(contents) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
34 subprocess.call(['svn', 'add', '-q', filename]) # may be redundant |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
35 subprocess.call([ |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
36 'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes']) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
37 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
38 def test_nochanges(self): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
39 repo = self._load_fixture_and_fetch('single_rev.svndump') |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
40 state = repo.parents() |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
41 wrappers.pull(None, ui.ui(), repo) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
42 self.assertEqual(state, repo.parents()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
43 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
44 def test_onerevision_noupdate(self): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
45 repo = self._load_fixture_and_fetch('single_rev.svndump') |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
46 state = repo.parents() |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
47 self._add_svn_rev({'trunk/alpha': 'Changed'}) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
48 wrappers.pull(None, ui.ui(), repo) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
49 self.assertEqual(state, repo.parents()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
50 self.assertTrue('tip' not in repo[None].tags()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
51 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
52 def test_onerevision_doupdate(self): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
53 repo = self._load_fixture_and_fetch('single_rev.svndump') |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
54 state = repo.parents() |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
55 self._add_svn_rev({'trunk/alpha': 'Changed'}) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
56 wrappers.pull(None, ui.ui(), repo, update=True) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
57 self.failIfEqual(state, repo.parents()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
58 self.assertTrue('tip' in repo[None].tags()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
59 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
60 def test_onerevision_divergent(self): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
61 repo = self._load_fixture_and_fetch('single_rev.svndump') |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
62 self.commitchanges((('alpha', 'alpha', 'Changed another way'),)) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
63 state = repo.parents() |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
64 self._add_svn_rev({'trunk/alpha': 'Changed one way'}) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
65 wrappers.pull(None, ui.ui(), repo, update=True) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
66 self.assertEqual(state, repo.parents()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
67 self.assertTrue('tip' not in repo[None].tags()) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
68 self.assertEqual(len(repo.heads()), 2) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
69 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
70 def suite(): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
71 import unittest, sys |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
72 return unittest.findTestCases(sys.modules[__name__]) |