Mercurial > hgsubversion
comparison tests/test_utility_commands.py @ 576:d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
| author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
|---|---|
| date | Fri, 26 Feb 2010 14:50:22 +0100 |
| parents | 00393e9abff8 |
| children | de384e4e0423 |
comparison
equal
deleted
inserted
replaced
| 575:c278a225b750 | 576:d96aa92d9ad9 |
|---|---|
| 1 import os | 1 import os |
| 2 import unittest | 2 import unittest |
| 3 | 3 |
| 4 from hgext import rebase | 4 from hgext import rebase |
| 5 from mercurial import ui | |
| 6 from mercurial import hg | 5 from mercurial import hg |
| 7 from mercurial import revlog | 6 from mercurial import revlog |
| 8 from mercurial import context | 7 from mercurial import context |
| 9 from mercurial import node | 8 from mercurial import node |
| 10 from mercurial import commands | 9 from mercurial import commands |
| 30 return util.normalize_url(test_util.fileurl(self.repo_path)) | 29 return util.normalize_url(test_util.fileurl(self.repo_path)) |
| 31 | 30 |
| 32 def test_info_output(self): | 31 def test_info_output(self): |
| 33 self._load_fixture_and_fetch('two_heads.svndump') | 32 self._load_fixture_and_fetch('two_heads.svndump') |
| 34 hg.update(self.repo, 'the_branch') | 33 hg.update(self.repo, 'the_branch') |
| 35 u = ui.ui() | 34 u = self.ui() |
| 36 u.pushbuffer() | 35 u.pushbuffer() |
| 37 utility_commands.info(u, self.repo) | 36 utility_commands.info(u, self.repo) |
| 38 actual = u.popbuffer() | 37 actual = u.popbuffer() |
| 39 expected = (expected_info_output % | 38 expected = (expected_info_output % |
| 40 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', | 39 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', |
| 67 self.assertEqual(actual, expected) | 66 self.assertEqual(actual, expected) |
| 68 | 67 |
| 69 def test_info_single(self): | 68 def test_info_single(self): |
| 70 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') | 69 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') |
| 71 hg.update(self.repo, 'tip') | 70 hg.update(self.repo, 'tip') |
| 72 u = ui.ui() | 71 u = self.ui() |
| 73 u.pushbuffer() | 72 u.pushbuffer() |
| 74 utility_commands.info(u, self.repo) | 73 utility_commands.info(u, self.repo) |
| 75 actual = u.popbuffer() | 74 actual = u.popbuffer() |
| 76 expected = (expected_info_output % | 75 expected = (expected_info_output % |
| 77 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', | 76 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', |
| 81 }) | 80 }) |
| 82 self.assertStringEqual(expected, actual) | 81 self.assertStringEqual(expected, actual) |
| 83 | 82 |
| 84 def test_parent_output(self): | 83 def test_parent_output(self): |
| 85 self._load_fixture_and_fetch('two_heads.svndump') | 84 self._load_fixture_and_fetch('two_heads.svndump') |
| 86 u = ui.ui() | 85 u = self.ui() |
| 87 u.pushbuffer() | 86 u.pushbuffer() |
| 88 parents = (self.repo['the_branch'].node(), revlog.nullid, ) | 87 parents = (self.repo['the_branch'].node(), revlog.nullid, ) |
| 89 def filectxfn(repo, memctx, path): | 88 def filectxfn(repo, memctx, path): |
| 90 return context.memfilectx(path=path, | 89 return context.memfilectx(path=path, |
| 91 data='added', | 90 data='added', |
| 102 {'branch': 'localbranch', }) | 101 {'branch': 'localbranch', }) |
| 103 new = self.repo.commitctx(ctx) | 102 new = self.repo.commitctx(ctx) |
| 104 hg.update(self.repo, new) | 103 hg.update(self.repo, new) |
| 105 wrappers.parents(lambda x, y: None, u, self.repo, svn=True) | 104 wrappers.parents(lambda x, y: None, u, self.repo, svn=True) |
| 106 actual = u.popbuffer() | 105 actual = u.popbuffer() |
| 107 self.assertEqual(actual, | 106 self.assertEqual(actual, '3:4e256962fc5d\n') |
| 108 'changeset: 3:4e256962fc5d\n' | 107 |
| 109 'branch: the_branch\n' | 108 hg.update(self.repo, 'default') |
| 110 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' | 109 |
| 111 'date: Wed Oct 08 01:39:05 2008 +0000\n' | |
| 112 'summary: add delta on the branch\n\n') | |
| 113 | |
| 114 hg.update(self.repo, 'default') | |
| 115 # Make sure styles work | 110 # Make sure styles work |
| 116 u.pushbuffer() | 111 u.pushbuffer() |
| 117 wrappers.parents(lambda x, y: None, u, self.repo, svn=True, style='compact') | 112 wrappers.parents(lambda x, y: None, u, self.repo, svn=True, style='compact') |
| 118 actual = u.popbuffer() | 113 actual = u.popbuffer() |
| 119 self.assertEqual(actual, | 114 self.assertEqual(actual, '4:1083037b18d8\n') |
| 120 '4:1 1083037b18d8 2008-10-08 01:39 +0000 durin\n' | 115 |
| 121 ' Add gamma on trunk.\n\n') | |
| 122 # custom templates too | 116 # custom templates too |
| 123 u.pushbuffer() | 117 u.pushbuffer() |
| 124 wrappers.parents(lambda x, y: None, u, self.repo, svn=True, template='{node}\n') | 118 wrappers.parents(lambda x, y: None, u, self.repo, svn=True, template='{node}\n') |
| 125 actual = u.popbuffer() | 119 actual = u.popbuffer() |
| 126 self.assertEqual(actual, '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') | 120 self.assertEqual(actual, '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') |
| 127 | 121 |
| 128 u.pushbuffer() | 122 u.pushbuffer() |
| 129 wrappers.parents(lambda x, y: None, u, self.repo, svn=True) | 123 wrappers.parents(lambda x, y: None, u, self.repo, svn=True) |
| 130 actual = u.popbuffer() | 124 actual = u.popbuffer() |
| 131 self.assertEqual(actual, | 125 self.assertEqual(actual, '4:1083037b18d8\n') |
| 132 'changeset: 4:1083037b18d8\n' | |
| 133 'parent: 1:c95251e0dd04\n' | |
| 134 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' | |
| 135 'date: Wed Oct 08 01:39:29 2008 +0000\n' | |
| 136 'summary: Add gamma on trunk.\n\n') | |
| 137 | 126 |
| 138 def test_outgoing_output(self): | 127 def test_outgoing_output(self): |
| 139 self._load_fixture_and_fetch('two_heads.svndump') | 128 self._load_fixture_and_fetch('two_heads.svndump') |
| 140 u = ui.ui() | 129 u = self.ui() |
| 141 parents = (self.repo['the_branch'].node(), revlog.nullid, ) | 130 parents = (self.repo['the_branch'].node(), revlog.nullid, ) |
| 142 def filectxfn(repo, memctx, path): | 131 def filectxfn(repo, memctx, path): |
| 143 return context.memfilectx(path=path, | 132 return context.memfilectx(path=path, |
| 144 data='added', | 133 data='added', |
| 145 islink=False, | 134 islink=False, |
| 156 new = self.repo.commitctx(ctx) | 145 new = self.repo.commitctx(ctx) |
| 157 hg.update(self.repo, new) | 146 hg.update(self.repo, new) |
| 158 u.pushbuffer() | 147 u.pushbuffer() |
| 159 commands.outgoing(u, self.repo, self.repourl) | 148 commands.outgoing(u, self.repo, self.repourl) |
| 160 actual = u.popbuffer() | 149 actual = u.popbuffer() |
| 161 u.write(actual) | |
| 162 self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual) | 150 self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual) |
| 163 actual = actual.splitlines() | 151 self.assertEqual(actual.strip(), '5:6de15430fa20') |
| 164 self.assertEqual(actual[0], 'comparing with ' + self.repourl) | |
| 165 self.assertEqual(actual[1], 'changeset: 5:6de15430fa20') | |
| 166 self.assertEqual(actual[2], 'branch: localbranch') | |
| 167 self.assertEqual(actual[3], 'tag: tip') | |
| 168 self.assertEqual(actual[4], 'parent: 3:4e256962fc5d') | |
| 169 self.assertEqual(actual[5], 'user: testy') | |
| 170 self.assertEqual(actual[6], 'date: Sun Dec 21 16:32:00 2008 -0500') | |
| 171 self.assertEqual(actual[7], 'summary: automated test') | |
| 172 hg.update(self.repo, 'default') | 152 hg.update(self.repo, 'default') |
| 173 u.pushbuffer() | 153 u.pushbuffer() |
| 174 commands.outgoing(u, self.repo, self.repourl) | 154 commands.outgoing(u, self.repo, self.repourl) |
| 175 actual = u.popbuffer() | 155 actual = u.popbuffer() |
| 176 u.write(actual) | 156 self.assertEqual(actual, '') |
| 177 self.assertEqual(actual.splitlines()[1], 'no changes found') | |
| 178 | 157 |
| 179 def test_rebase(self): | 158 def test_rebase(self): |
| 180 self._load_fixture_and_fetch('two_revs.svndump') | 159 self._load_fixture_and_fetch('two_revs.svndump') |
| 181 parents = (self.repo[0].node(), revlog.nullid, ) | 160 parents = (self.repo[0].node(), revlog.nullid, ) |
| 182 def filectxfn(repo, memctx, path): | 161 def filectxfn(repo, memctx, path): |
| 195 {'branch': 'localbranch', }) | 174 {'branch': 'localbranch', }) |
| 196 self.repo.commitctx(ctx) | 175 self.repo.commitctx(ctx) |
| 197 self.assertEqual(self.repo['tip'].branch(), 'localbranch') | 176 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
| 198 beforerebasehash = self.repo['tip'].node() | 177 beforerebasehash = self.repo['tip'].node() |
| 199 hg.update(self.repo, 'tip') | 178 hg.update(self.repo, 'tip') |
| 200 wrappers.rebase(rebase.rebase, ui.ui(), self.repo, svn=True) | 179 wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True) |
| 201 self.assertEqual(self.repo['tip'].branch(), 'localbranch') | 180 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
| 202 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) | 181 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) |
| 203 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) | 182 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) |
| 204 | 183 |
| 205 def test_genignore(self): | 184 def test_genignore(self): |
| 206 """ Test generation of .hgignore file. """ | 185 """ Test generation of .hgignore file. """ |
| 207 test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, | 186 test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, |
| 208 self.wc_path, noupdate=False) | 187 self.wc_path, noupdate=False) |
| 209 u = ui.ui() | 188 u = self.ui() |
| 210 u.pushbuffer() | 189 u.pushbuffer() |
| 211 utility_commands.genignore(u, self.repo, self.wc_path) | 190 utility_commands.genignore(u, self.repo, self.wc_path) |
| 212 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 191 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
| 213 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 192 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |
| 214 | 193 |
| 215 def test_genignore_single(self): | 194 def test_genignore_single(self): |
| 216 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') | 195 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') |
| 217 hg.update(self.repo, 'tip') | 196 hg.update(self.repo, 'tip') |
| 218 u = ui.ui() | 197 u = self.ui() |
| 219 u.pushbuffer() | 198 u.pushbuffer() |
| 220 utility_commands.genignore(u, self.repo, self.wc_path) | 199 utility_commands.genignore(u, self.repo, self.wc_path) |
| 221 self.assertStringEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 200 self.assertStringEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
| 222 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 201 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |
| 223 | 202 |
| 224 def test_list_authors(self): | 203 def test_list_authors(self): |
| 225 test_util.load_svndump_fixture(self.repo_path, | 204 test_util.load_svndump_fixture(self.repo_path, |
| 226 'replace_trunk_with_branch.svndump') | 205 'replace_trunk_with_branch.svndump') |
| 227 u = ui.ui() | 206 u = self.ui() |
| 228 u.pushbuffer() | 207 u.pushbuffer() |
| 229 utility_commands.listauthors(u, | 208 utility_commands.listauthors(u, |
| 230 args=[test_util.fileurl(self.repo_path)], | 209 args=[test_util.fileurl(self.repo_path)], |
| 231 authors=None) | 210 authors=None) |
| 232 actual = u.popbuffer() | 211 actual = u.popbuffer() |
| 235 | 214 |
| 236 def test_list_authors_map(self): | 215 def test_list_authors_map(self): |
| 237 test_util.load_svndump_fixture(self.repo_path, | 216 test_util.load_svndump_fixture(self.repo_path, |
| 238 'replace_trunk_with_branch.svndump') | 217 'replace_trunk_with_branch.svndump') |
| 239 author_path = os.path.join(self.repo_path, 'authors') | 218 author_path = os.path.join(self.repo_path, 'authors') |
| 240 utility_commands.listauthors(ui.ui(), | 219 utility_commands.listauthors(self.ui(), |
| 241 args=[test_util.fileurl(self.repo_path)], | 220 args=[test_util.fileurl(self.repo_path)], |
| 242 authors=author_path) | 221 authors=author_path) |
| 243 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') | 222 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') |
| 244 | 223 |
| 245 | 224 |
