Mercurial > hgsubversion
comparison tests/test_utility_commands.py @ 304:ce676eff002b
First merge, totally untested.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 01 May 2009 10:28:59 +0200 |
parents | 112d57bb736e |
children | 75f082b5897e |
comparison
equal
deleted
inserted
replaced
303:f423a8780832 | 304:ce676eff002b |
---|---|
1 import os | 1 import os |
2 import unittest | 2 import unittest |
3 | 3 |
4 from hgext import rebase | |
4 from mercurial import ui | 5 from mercurial import ui |
5 from mercurial import hg | 6 from mercurial import hg |
6 from mercurial import revlog | 7 from mercurial import revlog |
7 from mercurial import context | 8 from mercurial import context |
8 from mercurial import node | 9 from mercurial import node |
9 | 10 |
10 import utility_commands | 11 import utility_commands |
11 import fetch_command | |
12 import test_util | 12 import test_util |
13 import wrappers | |
13 | 14 |
14 expected_info_output = '''URL: %(repourl)s/%(branch)s | 15 expected_info_output = '''URL: %(repourl)s/%(branch)s |
15 Repository Root: %(repourl)s | 16 Repository Root: %(repourl)s |
16 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf | 17 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf |
17 Revision: %(rev)s | 18 Revision: %(rev)s |
24 class UtilityTests(test_util.TestBase): | 25 class UtilityTests(test_util.TestBase): |
25 def test_info_output(self): | 26 def test_info_output(self): |
26 self._load_fixture_and_fetch('two_heads.svndump') | 27 self._load_fixture_and_fetch('two_heads.svndump') |
27 hg.update(self.repo, 'the_branch') | 28 hg.update(self.repo, 'the_branch') |
28 u = ui.ui() | 29 u = ui.ui() |
29 utility_commands.run_svn_info(u, self.repo, self.wc_path) | 30 utility_commands.info(u, self.repo, self.wc_path) |
30 expected = (expected_info_output % | 31 expected = (expected_info_output % |
31 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', | 32 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', |
32 'repourl': test_util.fileurl(self.repo_path), | 33 'repourl': test_util.fileurl(self.repo_path), |
33 'branch': 'branches/the_branch', | 34 'branch': 'branches/the_branch', |
34 'rev': 5, | 35 'rev': 5, |
35 }) | 36 }) |
36 self.assertEqual(u.stream.getvalue(), expected) | 37 self.assertEqual(u.stream.getvalue(), expected) |
37 hg.update(self.repo, 'default') | 38 hg.update(self.repo, 'default') |
38 u = ui.ui() | 39 u = ui.ui() |
39 utility_commands.run_svn_info(u, self.repo, self.wc_path) | 40 utility_commands.info(u, self.repo, self.wc_path) |
40 expected = (expected_info_output % | 41 expected = (expected_info_output % |
41 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', | 42 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', |
42 'repourl': test_util.fileurl(self.repo_path), | 43 'repourl': test_util.fileurl(self.repo_path), |
43 'branch': 'trunk', | 44 'branch': 'trunk', |
44 'rev': 6, | 45 'rev': 6, |
63 'testy', | 64 'testy', |
64 '2008-12-21 16:32:00 -0500', | 65 '2008-12-21 16:32:00 -0500', |
65 {'branch': 'localbranch', }) | 66 {'branch': 'localbranch', }) |
66 new = self.repo.commitctx(ctx) | 67 new = self.repo.commitctx(ctx) |
67 hg.update(self.repo, new) | 68 hg.update(self.repo, new) |
68 utility_commands.print_parent_revision(u, self.repo, self.wc_path) | 69 wrappers.parent(lambda x, y: None, u, self.repo, svn=True) |
69 self.assert_(node.hex(self.repo['the_branch'].node())[:8] in | 70 self.assertEqual(u.stream.getvalue(), |
70 u.stream.getvalue()) | 71 'changeset: 3:4e256962fc5d\n' |
71 self.assert_('the_branch' in u.stream.getvalue()) | 72 'branch: the_branch\n' |
72 self.assert_('r5' in u.stream.getvalue()) | 73 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' |
74 'date: Wed Oct 08 01:39:05 2008 +0000\n' | |
75 'summary: add delta on the branch\n\n') | |
76 | |
73 hg.update(self.repo, 'default') | 77 hg.update(self.repo, 'default') |
74 u = ui.ui() | 78 # Make sure styles work |
75 utility_commands.print_parent_revision(u, self.repo, self.wc_path) | 79 u = ui.ui() |
76 self.assert_(node.hex(self.repo['default'].node())[:8] in | 80 wrappers.parent(lambda x, y: None, u, self.repo, svn=True, style='compact') |
77 u.stream.getvalue()) | 81 self.assertEqual(u.stream.getvalue(), |
78 self.assert_('trunk' in u.stream.getvalue()) | 82 '4:1 1083037b18d8 2008-10-08 01:39 +0000 durin\n' |
79 self.assert_('r6' in u.stream.getvalue()) | 83 ' Add gamma on trunk.\n\n') |
84 # custom templates too | |
85 u = ui.ui() | |
86 wrappers.parent(lambda x, y: None, u, self.repo, svn=True, template='{node}\n') | |
87 self.assertEqual(u.stream.getvalue(), '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') | |
88 | |
89 u = ui.ui() | |
90 wrappers.parent(lambda x, y: None, u, self.repo, svn=True) | |
91 self.assertEqual(u.stream.getvalue(), | |
92 'changeset: 4:1083037b18d8\n' | |
93 'parent: 1:c95251e0dd04\n' | |
94 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' | |
95 'date: Wed Oct 08 01:39:29 2008 +0000\n' | |
96 'summary: Add gamma on trunk.\n\n') | |
80 | 97 |
81 def test_outgoing_output(self): | 98 def test_outgoing_output(self): |
82 self._load_fixture_and_fetch('two_heads.svndump') | 99 self._load_fixture_and_fetch('two_heads.svndump') |
83 u = ui.ui() | 100 u = ui.ui() |
84 parents = (self.repo['the_branch'].node(), revlog.nullid, ) | 101 parents = (self.repo['the_branch'].node(), revlog.nullid, ) |
96 'testy', | 113 'testy', |
97 '2008-12-21 16:32:00 -0500', | 114 '2008-12-21 16:32:00 -0500', |
98 {'branch': 'localbranch', }) | 115 {'branch': 'localbranch', }) |
99 new = self.repo.commitctx(ctx) | 116 new = self.repo.commitctx(ctx) |
100 hg.update(self.repo, new) | 117 hg.update(self.repo, new) |
101 utility_commands.show_outgoing_to_svn(u, self.repo, self.wc_path) | 118 wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True) |
102 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in | 119 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in |
103 u.stream.getvalue()) | 120 u.stream.getvalue()) |
104 self.assert_('testy' in u.stream.getvalue()) | 121 self.assertEqual(u.stream.getvalue(), ('changeset: 5:6de15430fa20\n' |
122 'branch: localbranch\n' | |
123 'tag: tip\n' | |
124 'parent: 3:4e256962fc5d\n' | |
125 'user: testy\n' | |
126 'date: Sun Dec 21 16:32:00 2008 -0500\n' | |
127 'summary: automated test\n' | |
128 '\n')) | |
105 hg.update(self.repo, 'default') | 129 hg.update(self.repo, 'default') |
106 u = ui.ui() | 130 u = ui.ui() |
107 utility_commands.show_outgoing_to_svn(u, self.repo, self.wc_path) | 131 wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True) |
108 self.assertEqual(u.stream.getvalue(), 'No outgoing changes found.\n') | 132 self.assertEqual(u.stream.getvalue(), 'no changes found\n') |
109 | 133 |
110 def test_url_output(self): | 134 def test_url_output(self): |
111 self._load_fixture_and_fetch('two_revs.svndump') | 135 self._load_fixture_and_fetch('two_revs.svndump') |
112 hg.update(self.repo, 'tip') | 136 hg.update(self.repo, 'tip') |
113 u = ui.ui() | 137 u = ui.ui() |
114 utility_commands.print_wc_url(u, self.repo, self.wc_path) | 138 utility_commands.url(u, self.repo, self.wc_path) |
115 expected = test_util.fileurl(self.repo_path) + '\n' | 139 expected = test_util.fileurl(self.repo_path) + '\n' |
116 self.assertEqual(u.stream.getvalue(), expected) | 140 self.assertEqual(u.stream.getvalue(), expected) |
117 | 141 |
118 def test_rebase(self): | 142 def test_rebase(self): |
119 self._load_fixture_and_fetch('two_revs.svndump') | 143 self._load_fixture_and_fetch('two_revs.svndump') |
134 {'branch': 'localbranch', }) | 158 {'branch': 'localbranch', }) |
135 self.repo.commitctx(ctx) | 159 self.repo.commitctx(ctx) |
136 self.assertEqual(self.repo['tip'].branch(), 'localbranch') | 160 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
137 beforerebasehash = self.repo['tip'].node() | 161 beforerebasehash = self.repo['tip'].node() |
138 hg.update(self.repo, 'tip') | 162 hg.update(self.repo, 'tip') |
139 utility_commands.rebase_commits(ui.ui(), self.repo, os.path.dirname(self.repo.path)) | 163 wrappers.rebase(rebase.rebase, ui.ui(), self.repo, svn=True) |
140 self.assertEqual(self.repo['tip'].branch(), 'localbranch') | 164 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
141 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) | 165 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) |
142 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) | 166 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) |
143 | 167 |
144 def test_url_is_normalized(self): | 168 def test_url_is_normalized(self): |
145 """Verify url gets normalized on initial clone. | 169 """Verify url gets normalized on initial clone. |
146 """ | 170 """ |
147 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') | 171 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') |
148 fetch_command.fetch_revisions(ui.ui(), | 172 wrappers.clone(None, ui.ui(), |
149 svn_url=test_util.fileurl(self.repo_path)+'/', | 173 source=test_util.fileurl(self.repo_path) + '/', |
150 hg_repo_path=self.wc_path, | 174 dest=self.wc_path, stupid=False) |
151 stupid=False) | 175 hg.update(self.repo, 'tip') |
152 hg.update(self.repo, 'tip') | 176 u = ui.ui() |
153 u = ui.ui() | 177 utility_commands.url(u, self.repo, self.wc_path) |
154 utility_commands.print_wc_url(u, self.repo, self.wc_path) | |
155 expected = test_util.fileurl(self.repo_path) + '\n' | 178 expected = test_util.fileurl(self.repo_path) + '\n' |
156 self.assertEqual(u.stream.getvalue(), expected) | 179 self.assertEqual(u.stream.getvalue(), expected) |
157 | 180 |
158 def test_genignore(self): | 181 def test_genignore(self): |
159 """Verify url gets normalized on initial clone. | 182 """Verify url gets normalized on initial clone. |
160 """ | 183 """ |
161 test_util.load_svndump_fixture(self.repo_path, 'ignores.svndump') | 184 test_util.load_svndump_fixture(self.repo_path, 'ignores.svndump') |
162 fetch_command.fetch_revisions(ui.ui(), | 185 wrappers.clone(None, ui.ui(), |
163 svn_url=test_util.fileurl(self.repo_path)+'/', | 186 source=test_util.fileurl(self.repo_path) + '/', |
164 hg_repo_path=self.wc_path, | 187 dest=self.wc_path, stupid=False) |
165 stupid=False) | 188 hg.update(self.repo, 'tip') |
166 hg.update(self.repo, 'tip') | 189 u = ui.ui() |
167 u = ui.ui() | 190 utility_commands.genignore(u, self.repo, self.wc_path) |
168 utility_commands.generate_ignore(u, self.repo, self.wc_path) | |
169 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 191 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
170 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 192 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |
193 | |
194 def test_list_authors(self): | |
195 test_util.load_svndump_fixture(self.repo_path, | |
196 'replace_trunk_with_branch.svndump') | |
197 u = ui.ui() | |
198 utility_commands.listauthors(u, | |
199 args=[test_util.fileurl(self.repo_path)], | |
200 authors=None) | |
201 self.assertEqual(u.stream.getvalue(), 'Augie\nevil\n') | |
202 | |
203 | |
204 def test_list_authors_map(self): | |
205 test_util.load_svndump_fixture(self.repo_path, | |
206 'replace_trunk_with_branch.svndump') | |
207 author_path = os.path.join(self.repo_path, 'authors') | |
208 utility_commands.listauthors(ui.ui(), | |
209 args=[test_util.fileurl(self.repo_path)], | |
210 authors=author_path) | |
211 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') | |
171 | 212 |
172 | 213 |
173 def suite(): | 214 def suite(): |
174 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), | 215 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), |
175 ] | 216 ] |