Mercurial > hgsubversion
comparison tests/test_utility_commands.py @ 257:ffccf0080e54
Move wrappers for hg commands to their own module.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 10 Apr 2009 22:38:29 -0500 |
parents | 7932d098cb5f |
children | 112d57bb736e |
comparison
equal
deleted
inserted
replaced
256:7932d098cb5f | 257:ffccf0080e54 |
---|---|
6 from mercurial import revlog | 6 from mercurial import revlog |
7 from mercurial import context | 7 from mercurial import context |
8 from mercurial import node | 8 from mercurial import node |
9 | 9 |
10 import utility_commands | 10 import utility_commands |
11 import svncommands | |
12 import test_util | 11 import test_util |
12 import wrappers | |
13 | 13 |
14 expected_info_output = '''URL: %(repourl)s/%(branch)s | 14 expected_info_output = '''URL: %(repourl)s/%(branch)s |
15 Repository Root: %(repourl)s | 15 Repository Root: %(repourl)s |
16 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf | 16 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf |
17 Revision: %(rev)s | 17 Revision: %(rev)s |
63 'testy', | 63 'testy', |
64 '2008-12-21 16:32:00 -0500', | 64 '2008-12-21 16:32:00 -0500', |
65 {'branch': 'localbranch', }) | 65 {'branch': 'localbranch', }) |
66 new = self.repo.commitctx(ctx) | 66 new = self.repo.commitctx(ctx) |
67 hg.update(self.repo, new) | 67 hg.update(self.repo, new) |
68 utility_commands.parent(lambda x, y: None, u, self.repo, svn=True) | 68 wrappers.parent(lambda x, y: None, u, self.repo, svn=True) |
69 self.assertEqual(u.stream.getvalue(), | 69 self.assertEqual(u.stream.getvalue(), |
70 'changeset: 3:4e256962fc5d\n' | 70 'changeset: 3:4e256962fc5d\n' |
71 'branch: the_branch\n' | 71 'branch: the_branch\n' |
72 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' | 72 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' |
73 'date: Wed Oct 08 01:39:05 2008 +0000\n' | 73 'date: Wed Oct 08 01:39:05 2008 +0000\n' |
74 'summary: add delta on the branch\n\n') | 74 'summary: add delta on the branch\n\n') |
75 | 75 |
76 hg.update(self.repo, 'default') | 76 hg.update(self.repo, 'default') |
77 # Make sure styles work | 77 # Make sure styles work |
78 u = ui.ui() | 78 u = ui.ui() |
79 utility_commands.parent(lambda x, y: None, u, self.repo, svn=True, style='compact') | 79 wrappers.parent(lambda x, y: None, u, self.repo, svn=True, style='compact') |
80 self.assertEqual(u.stream.getvalue(), | 80 self.assertEqual(u.stream.getvalue(), |
81 '4:1 1083037b18d8 2008-10-08 01:39 +0000 durin\n' | 81 '4:1 1083037b18d8 2008-10-08 01:39 +0000 durin\n' |
82 ' Add gamma on trunk.\n\n') | 82 ' Add gamma on trunk.\n\n') |
83 # custom templates too | 83 # custom templates too |
84 u = ui.ui() | 84 u = ui.ui() |
85 utility_commands.parent(lambda x, y: None, u, self.repo, svn=True, template='{node}\n') | 85 wrappers.parent(lambda x, y: None, u, self.repo, svn=True, template='{node}\n') |
86 self.assertEqual(u.stream.getvalue(), '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') | 86 self.assertEqual(u.stream.getvalue(), '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') |
87 | 87 |
88 u = ui.ui() | 88 u = ui.ui() |
89 utility_commands.parent(lambda x, y: None, u, self.repo, svn=True) | 89 wrappers.parent(lambda x, y: None, u, self.repo, svn=True) |
90 self.assertEqual(u.stream.getvalue(), | 90 self.assertEqual(u.stream.getvalue(), |
91 'changeset: 4:1083037b18d8\n' | 91 'changeset: 4:1083037b18d8\n' |
92 'parent: 1:c95251e0dd04\n' | 92 'parent: 1:c95251e0dd04\n' |
93 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' | 93 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' |
94 'date: Wed Oct 08 01:39:29 2008 +0000\n' | 94 'date: Wed Oct 08 01:39:29 2008 +0000\n' |
112 'testy', | 112 'testy', |
113 '2008-12-21 16:32:00 -0500', | 113 '2008-12-21 16:32:00 -0500', |
114 {'branch': 'localbranch', }) | 114 {'branch': 'localbranch', }) |
115 new = self.repo.commitctx(ctx) | 115 new = self.repo.commitctx(ctx) |
116 hg.update(self.repo, new) | 116 hg.update(self.repo, new) |
117 utility_commands.outgoing(lambda x,y,z: None, u, self.repo, svn=True) | 117 wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True) |
118 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in | 118 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in |
119 u.stream.getvalue()) | 119 u.stream.getvalue()) |
120 self.assertEqual(u.stream.getvalue(), ('changeset: 5:6de15430fa20\n' | 120 self.assertEqual(u.stream.getvalue(), ('changeset: 5:6de15430fa20\n' |
121 'branch: localbranch\n' | 121 'branch: localbranch\n' |
122 'tag: tip\n' | 122 'tag: tip\n' |
125 'date: Sun Dec 21 16:32:00 2008 -0500\n' | 125 'date: Sun Dec 21 16:32:00 2008 -0500\n' |
126 'summary: automated test\n' | 126 'summary: automated test\n' |
127 '\n')) | 127 '\n')) |
128 hg.update(self.repo, 'default') | 128 hg.update(self.repo, 'default') |
129 u = ui.ui() | 129 u = ui.ui() |
130 utility_commands.outgoing(lambda x,y,z: None, u, self.repo, svn=True) | 130 wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True) |
131 self.assertEqual(u.stream.getvalue(), 'no changes found\n') | 131 self.assertEqual(u.stream.getvalue(), 'no changes found\n') |
132 | 132 |
133 def test_url_output(self): | 133 def test_url_output(self): |
134 self._load_fixture_and_fetch('two_revs.svndump') | 134 self._load_fixture_and_fetch('two_revs.svndump') |
135 hg.update(self.repo, 'tip') | 135 hg.update(self.repo, 'tip') |
166 | 166 |
167 def test_url_is_normalized(self): | 167 def test_url_is_normalized(self): |
168 """Verify url gets normalized on initial clone. | 168 """Verify url gets normalized on initial clone. |
169 """ | 169 """ |
170 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') | 170 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') |
171 svncommands.pull(ui.ui(), | 171 wrappers.clone(None, ui.ui(), |
172 svn_url=test_util.fileurl(self.repo_path) + '/', | 172 source=test_util.fileurl(self.repo_path) + '/', |
173 hg_repo_path=self.wc_path, stupid=False) | 173 dest=self.wc_path, stupid=False) |
174 hg.update(self.repo, 'tip') | 174 hg.update(self.repo, 'tip') |
175 u = ui.ui() | 175 u = ui.ui() |
176 utility_commands.url(u, self.repo, self.wc_path) | 176 utility_commands.url(u, self.repo, self.wc_path) |
177 expected = test_util.fileurl(self.repo_path) + '\n' | 177 expected = test_util.fileurl(self.repo_path) + '\n' |
178 self.assertEqual(u.stream.getvalue(), expected) | 178 self.assertEqual(u.stream.getvalue(), expected) |
179 | 179 |
180 def test_genignore(self): | 180 def test_genignore(self): |
181 """Verify url gets normalized on initial clone. | 181 """Verify url gets normalized on initial clone. |
182 """ | 182 """ |
183 test_util.load_svndump_fixture(self.repo_path, 'ignores.svndump') | 183 test_util.load_svndump_fixture(self.repo_path, 'ignores.svndump') |
184 svncommands.pull(ui.ui(), | 184 wrappers.clone(None, ui.ui(), |
185 svn_url=test_util.fileurl(self.repo_path) + '/', | 185 source=test_util.fileurl(self.repo_path) + '/', |
186 hg_repo_path=self.wc_path, stupid=False) | 186 dest=self.wc_path, stupid=False) |
187 hg.update(self.repo, 'tip') | 187 hg.update(self.repo, 'tip') |
188 u = ui.ui() | 188 u = ui.ui() |
189 utility_commands.genignore(u, self.repo, self.wc_path) | 189 utility_commands.genignore(u, self.repo, self.wc_path) |
190 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 190 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
191 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 191 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |