Mercurial > hgsubversion
diff tests/test_utility_commands.py @ 331:75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
The 'hg svn url' command has been killed; the replacement is
'.hg/hgrc'. More stuff related to its disappearance has been stripped,
including two tests.
HgChangeReceiver now takes a UUID argument, which it uses to ensure
that remote repositories remain unchanged. This is a temporary
solution, and I'm not entirely satisfied with how it's done either.
Access to the UUID file has been isolated in a HgChangeReceiver
property.
Some more tests have been updated to use ui.pushbuffer()/popbuffer(),
and to pass through the Mercurial API.
Moved the arguments to wrappers.pull() to the UI configuration.
Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames'
instance & configuration variable. The name is taken from the
ConvertExtension.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 15 May 2009 19:18:43 +0200 |
parents | 112d57bb736e |
children | 46e69be8e2c8 |
line wrap: on
line diff
--- a/tests/test_utility_commands.py +++ b/tests/test_utility_commands.py @@ -8,6 +8,7 @@ from mercurial import revlog from mercurial import context from mercurial import node +import util import utility_commands import test_util import wrappers @@ -23,32 +24,40 @@ Last Changed Date: %(date)s ''' class UtilityTests(test_util.TestBase): + @property + def repourl(self): + return util.normalize_url(test_util.fileurl(self.repo_path)) + def test_info_output(self): self._load_fixture_and_fetch('two_heads.svndump') hg.update(self.repo, 'the_branch') u = ui.ui() + u.pushbuffer() utility_commands.info(u, self.repo, self.wc_path) + actual = u.popbuffer() expected = (expected_info_output % {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', - 'repourl': test_util.fileurl(self.repo_path), + 'repourl': self.repourl, 'branch': 'branches/the_branch', 'rev': 5, }) - self.assertEqual(u.stream.getvalue(), expected) + self.assertEqual(actual, expected) hg.update(self.repo, 'default') - u = ui.ui() + u.pushbuffer() utility_commands.info(u, self.repo, self.wc_path) + actual = u.popbuffer() expected = (expected_info_output % {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', - 'repourl': test_util.fileurl(self.repo_path), + 'repourl': self.repourl, 'branch': 'trunk', 'rev': 6, }) - self.assertEqual(u.stream.getvalue(), expected) + self.assertEqual(actual, expected) def test_parent_output(self): self._load_fixture_and_fetch('two_heads.svndump') u = ui.ui() + u.pushbuffer() parents = (self.repo['the_branch'].node(), revlog.nullid, ) def filectxfn(repo, memctx, path): return context.memfilectx(path=path, @@ -67,7 +76,8 @@ class UtilityTests(test_util.TestBase): new = self.repo.commitctx(ctx) hg.update(self.repo, new) wrappers.parent(lambda x, y: None, u, self.repo, svn=True) - self.assertEqual(u.stream.getvalue(), + actual = u.popbuffer() + self.assertEqual(actual, 'changeset: 3:4e256962fc5d\n' 'branch: the_branch\n' 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' @@ -76,19 +86,22 @@ class UtilityTests(test_util.TestBase): hg.update(self.repo, 'default') # Make sure styles work - u = ui.ui() + u.pushbuffer() wrappers.parent(lambda x, y: None, u, self.repo, svn=True, style='compact') - self.assertEqual(u.stream.getvalue(), + actual = u.popbuffer() + self.assertEqual(actual, '4:1 1083037b18d8 2008-10-08 01:39 +0000 durin\n' ' Add gamma on trunk.\n\n') # custom templates too - u = ui.ui() + u.pushbuffer() wrappers.parent(lambda x, y: None, u, self.repo, svn=True, template='{node}\n') - self.assertEqual(u.stream.getvalue(), '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') + actual = u.popbuffer() + self.assertEqual(actual, '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n') - u = ui.ui() + u.pushbuffer() wrappers.parent(lambda x, y: None, u, self.repo, svn=True) - self.assertEqual(u.stream.getvalue(), + actual = u.popbuffer() + self.assertEqual(actual, 'changeset: 4:1083037b18d8\n' 'parent: 1:c95251e0dd04\n' 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n' @@ -98,6 +111,7 @@ class UtilityTests(test_util.TestBase): def test_outgoing_output(self): self._load_fixture_and_fetch('two_heads.svndump') u = ui.ui() + u.pushbuffer() parents = (self.repo['the_branch'].node(), revlog.nullid, ) def filectxfn(repo, memctx, path): return context.memfilectx(path=path, @@ -116,9 +130,9 @@ class UtilityTests(test_util.TestBase): new = self.repo.commitctx(ctx) hg.update(self.repo, new) wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True) - self.assert_(node.hex(self.repo['localbranch'].node())[:8] in - u.stream.getvalue()) - self.assertEqual(u.stream.getvalue(), ('changeset: 5:6de15430fa20\n' + actual = u.popbuffer() + self.assert_(node.hex(self.repo['localbranch'].node())[:8] in actual) + self.assertEqual(actual, ('changeset: 5:6de15430fa20\n' 'branch: localbranch\n' 'tag: tip\n' 'parent: 3:4e256962fc5d\n' @@ -127,17 +141,10 @@ class UtilityTests(test_util.TestBase): 'summary: automated test\n' '\n')) hg.update(self.repo, 'default') - u = ui.ui() + u.pushbuffer() wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True) - self.assertEqual(u.stream.getvalue(), 'no changes found\n') - - def test_url_output(self): - self._load_fixture_and_fetch('two_revs.svndump') - hg.update(self.repo, 'tip') - u = ui.ui() - utility_commands.url(u, self.repo, self.wc_path) - expected = test_util.fileurl(self.repo_path) + '\n' - self.assertEqual(u.stream.getvalue(), expected) + actual = u.popbuffer() + self.assertEqual(actual, 'no changes found\n') def test_rebase(self): self._load_fixture_and_fetch('two_revs.svndump') @@ -165,28 +172,12 @@ class UtilityTests(test_util.TestBase): self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) - def test_url_is_normalized(self): - """Verify url gets normalized on initial clone. - """ - test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') - wrappers.clone(None, ui.ui(), - source=test_util.fileurl(self.repo_path) + '/', - dest=self.wc_path, stupid=False) - hg.update(self.repo, 'tip') - u = ui.ui() - utility_commands.url(u, self.repo, self.wc_path) - expected = test_util.fileurl(self.repo_path) + '\n' - self.assertEqual(u.stream.getvalue(), expected) - def test_genignore(self): - """Verify url gets normalized on initial clone. - """ - test_util.load_svndump_fixture(self.repo_path, 'ignores.svndump') - wrappers.clone(None, ui.ui(), - source=test_util.fileurl(self.repo_path) + '/', - dest=self.wc_path, stupid=False) - hg.update(self.repo, 'tip') + """ Test generation of .hgignore file. """ + test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, + self.wc_path, noupdate=False) u = ui.ui() + u.pushbuffer() utility_commands.genignore(u, self.repo, self.wc_path) self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') @@ -195,10 +186,12 @@ class UtilityTests(test_util.TestBase): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') u = ui.ui() + u.pushbuffer() utility_commands.listauthors(u, args=[test_util.fileurl(self.repo_path)], authors=None) - self.assertEqual(u.stream.getvalue(), 'Augie\nevil\n') + actual = u.popbuffer() + self.assertEqual(actual, 'Augie\nevil\n') def test_list_authors_map(self):