comparison tests/test_utility_commands.py @ 578:de384e4e0423

merge commands from utility_commands into svncommands
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 26 Feb 2010 15:00:15 +0100
parents d96aa92d9ad9
children d2ef7220a079
comparison
equal deleted inserted replaced
577:930bb6df19a0 578:de384e4e0423
7 from mercurial import context 7 from mercurial import context
8 from mercurial import node 8 from mercurial import node
9 from mercurial import commands 9 from mercurial import commands
10 10
11 from hgsubversion import util 11 from hgsubversion import util
12 from hgsubversion import utility_commands 12 from hgsubversion import svncommands
13 import test_util 13 import test_util
14 from hgsubversion import wrappers 14 from hgsubversion import wrappers
15 15
16 expected_info_output = '''URL: %(repourl)s/%(branch)s 16 expected_info_output = '''URL: %(repourl)s/%(branch)s
17 Repository Root: %(repourl)s 17 Repository Root: %(repourl)s
31 def test_info_output(self): 31 def test_info_output(self):
32 self._load_fixture_and_fetch('two_heads.svndump') 32 self._load_fixture_and_fetch('two_heads.svndump')
33 hg.update(self.repo, 'the_branch') 33 hg.update(self.repo, 'the_branch')
34 u = self.ui() 34 u = self.ui()
35 u.pushbuffer() 35 u.pushbuffer()
36 utility_commands.info(u, self.repo) 36 svncommands.info(u, self.repo)
37 actual = u.popbuffer() 37 actual = u.popbuffer()
38 expected = (expected_info_output % 38 expected = (expected_info_output %
39 {'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)',
40 'repourl': self.repourl, 40 'repourl': self.repourl,
41 'branch': 'branches/the_branch', 41 'branch': 'branches/the_branch',
42 'rev': 5, 42 'rev': 5,
43 }) 43 })
44 self.assertEqual(actual, expected) 44 self.assertEqual(actual, expected)
45 hg.update(self.repo, 'default') 45 hg.update(self.repo, 'default')
46 u.pushbuffer() 46 u.pushbuffer()
47 utility_commands.info(u, self.repo) 47 svncommands.info(u, self.repo)
48 actual = u.popbuffer() 48 actual = u.popbuffer()
49 expected = (expected_info_output % 49 expected = (expected_info_output %
50 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', 50 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
51 'repourl': self.repourl, 51 'repourl': self.repourl,
52 'branch': 'trunk', 52 'branch': 'trunk',
53 'rev': 6, 53 'rev': 6,
54 }) 54 })
55 self.assertEqual(actual, expected) 55 self.assertEqual(actual, expected)
56 hg.update(self.repo, 'default') 56 hg.update(self.repo, 'default')
57 u.pushbuffer() 57 u.pushbuffer()
58 utility_commands.info(u, self.repo, rev=3) 58 svncommands.info(u, self.repo, rev=3)
59 actual = u.popbuffer() 59 actual = u.popbuffer()
60 expected = (expected_info_output % 60 expected = (expected_info_output %
61 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', 61 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
62 'repourl': self.repourl, 62 'repourl': self.repourl,
63 'branch': 'branches/the_branch', 63 'branch': 'branches/the_branch',
68 def test_info_single(self): 68 def test_info_single(self):
69 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') 69 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk')
70 hg.update(self.repo, 'tip') 70 hg.update(self.repo, 'tip')
71 u = self.ui() 71 u = self.ui()
72 u.pushbuffer() 72 u.pushbuffer()
73 utility_commands.info(u, self.repo) 73 svncommands.info(u, self.repo)
74 actual = u.popbuffer() 74 actual = u.popbuffer()
75 expected = (expected_info_output % 75 expected = (expected_info_output %
76 {'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)',
77 'repourl': self.repourl, 77 'repourl': self.repourl,
78 'branch': 'trunk', 78 'branch': 'trunk',
185 """ Test generation of .hgignore file. """ 185 """ Test generation of .hgignore file. """
186 test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, 186 test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path,
187 self.wc_path, noupdate=False) 187 self.wc_path, noupdate=False)
188 u = self.ui() 188 u = self.ui()
189 u.pushbuffer() 189 u.pushbuffer()
190 utility_commands.genignore(u, self.repo, self.wc_path) 190 svncommands.genignore(u, self.repo, self.wc_path)
191 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), 191 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(),
192 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') 192 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n')
193 193
194 def test_genignore_single(self): 194 def test_genignore_single(self):
195 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') 195 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk')
196 hg.update(self.repo, 'tip') 196 hg.update(self.repo, 'tip')
197 u = self.ui() 197 u = self.ui()
198 u.pushbuffer() 198 u.pushbuffer()
199 utility_commands.genignore(u, self.repo, self.wc_path) 199 svncommands.genignore(u, self.repo, self.wc_path)
200 self.assertStringEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), 200 self.assertStringEqual(open(os.path.join(self.wc_path, '.hgignore')).read(),
201 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') 201 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n')
202 202
203 def test_list_authors(self): 203 def test_list_authors(self):
204 test_util.load_svndump_fixture(self.repo_path, 204 test_util.load_svndump_fixture(self.repo_path,
205 'replace_trunk_with_branch.svndump') 205 'replace_trunk_with_branch.svndump')
206 u = self.ui() 206 u = self.ui()
207 u.pushbuffer() 207 u.pushbuffer()
208 utility_commands.listauthors(u, 208 svncommands.listauthors(u,
209 args=[test_util.fileurl(self.repo_path)], 209 args=[test_util.fileurl(self.repo_path)],
210 authors=None) 210 authors=None)
211 actual = u.popbuffer() 211 actual = u.popbuffer()
212 self.assertEqual(actual, 'Augie\nevil\n') 212 self.assertEqual(actual, 'Augie\nevil\n')
213 213
214 214
215 def test_list_authors_map(self): 215 def test_list_authors_map(self):
216 test_util.load_svndump_fixture(self.repo_path, 216 test_util.load_svndump_fixture(self.repo_path,
217 'replace_trunk_with_branch.svndump') 217 'replace_trunk_with_branch.svndump')
218 author_path = os.path.join(self.repo_path, 'authors') 218 author_path = os.path.join(self.repo_path, 'authors')
219 utility_commands.listauthors(self.ui(), 219 svncommands.listauthors(self.ui(),
220 args=[test_util.fileurl(self.repo_path)], 220 args=[test_util.fileurl(self.repo_path)],
221 authors=author_path) 221 authors=author_path)
222 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') 222 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n')
223 223
224 224