comparison tests/test_utility_commands.py @ 1570:d55c9d0ba350

tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
author Paul Morelle <paul.morelle@octobus.net>
date Fri, 25 May 2018 11:52:03 +0200
parents cff81f35b31e
children e2d38f6b8afe
comparison
equal deleted inserted replaced
1569:4afe8d7e4602 1570:d55c9d0ba350
16 from hgsubversion import util 16 from hgsubversion import util
17 from hgsubversion import svncommands 17 from hgsubversion import svncommands
18 from hgsubversion import verify 18 from hgsubversion import verify
19 from hgsubversion import wrappers 19 from hgsubversion import wrappers
20 from hgsubversion import compathacks 20 from hgsubversion import compathacks
21
22 revsymbol = test_util.revsymbol
21 23
22 expected_info_output = '''URL: %(repourl)s/%(branch)s 24 expected_info_output = '''URL: %(repourl)s/%(branch)s
23 Repository Root: %(repourl)s 25 Repository Root: %(repourl)s
24 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf 26 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf
25 Revision: %(rev)s 27 Revision: %(rev)s
42 'hgsubversionbranch.the_branch': 'branches/the_branch', 44 'hgsubversionbranch.the_branch': 'branches/the_branch',
43 } 45 }
44 else: 46 else:
45 config = {} 47 config = {}
46 repo, repo_path = self.load_and_fetch('two_heads.svndump', config=config) 48 repo, repo_path = self.load_and_fetch('two_heads.svndump', config=config)
47 hg.update(self.repo, 'the_branch') 49 hg.update(self.repo, revsymbol(self.repo, 'the_branch'))
48 u = self.ui() 50 u = self.ui()
49 u.pushbuffer() 51 u.pushbuffer()
50 svncommands.info(u, self.repo) 52 svncommands.info(u, self.repo)
51 actual = u.popbuffer() 53 actual = u.popbuffer()
52 expected = (expected_info_output % 54 expected = (expected_info_output %
54 'repourl': repourl(repo_path), 56 'repourl': repourl(repo_path),
55 'branch': 'branches/the_branch', 57 'branch': 'branches/the_branch',
56 'rev': 5, 58 'rev': 5,
57 }) 59 })
58 self.assertMultiLineEqual(actual, expected) 60 self.assertMultiLineEqual(actual, expected)
59 hg.update(self.repo, 'default') 61 hg.update(self.repo, revsymbol(self.repo, 'default'))
60 u.pushbuffer() 62 u.pushbuffer()
61 svncommands.info(u, self.repo) 63 svncommands.info(u, self.repo)
62 actual = u.popbuffer() 64 actual = u.popbuffer()
63 expected = (expected_info_output % 65 expected = (expected_info_output %
64 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', 66 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
65 'repourl': repourl(repo_path), 67 'repourl': repourl(repo_path),
66 'branch': 'trunk', 68 'branch': 'trunk',
67 'rev': 6, 69 'rev': 6,
68 }) 70 })
69 self.assertMultiLineEqual(actual, expected) 71 self.assertMultiLineEqual(actual, expected)
70 hg.update(self.repo, 'default') 72 hg.update(self.repo, revsymbol(self.repo, 'default'))
71 u.pushbuffer() 73 u.pushbuffer()
72 svncommands.info(u, self.repo, rev=3) 74 svncommands.info(u, self.repo, rev=3)
73 actual = u.popbuffer() 75 actual = u.popbuffer()
74 expected = (expected_info_output % 76 expected = (expected_info_output %
75 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', 77 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
81 destpath = self.wc_path + '_clone' 83 destpath = self.wc_path + '_clone'
82 test_util.hgclone(u, self.repo, destpath) 84 test_util.hgclone(u, self.repo, destpath)
83 repo2 = hg.repository(u, destpath) 85 repo2 = hg.repository(u, destpath)
84 repo2.ui.setconfig('paths', 'default-push', 86 repo2.ui.setconfig('paths', 'default-push',
85 self.repo.ui.config('paths', 'default')) 87 self.repo.ui.config('paths', 'default'))
86 hg.update(repo2, 'default') 88 hg.update(repo2, revsymbol(self.repo, 'default'))
87 svncommands.rebuildmeta(u, repo2, []) 89 svncommands.rebuildmeta(u, repo2, [])
88 u.pushbuffer() 90 u.pushbuffer()
89 svncommands.info(u, repo2) 91 svncommands.info(u, repo2)
90 actual = u.popbuffer() 92 actual = u.popbuffer()
91 expected = (expected_info_output % 93 expected = (expected_info_output %
158 160
159 def test_parent_output(self): 161 def test_parent_output(self):
160 self._load_fixture_and_fetch('two_heads.svndump') 162 self._load_fixture_and_fetch('two_heads.svndump')
161 u = self.ui() 163 u = self.ui()
162 u.pushbuffer() 164 u.pushbuffer()
163 parents = (self.repo['the_branch'].node(), revlog.nullid,) 165 parents = (revsymbol(self.repo, 'the_branch').node(), revlog.nullid,)
164 def filectxfn(repo, memctx, path): 166 def filectxfn(repo, memctx, path):
165 return compathacks.makememfilectx(repo, 167 return compathacks.makememfilectx(repo,
166 memctx=memctx, 168 memctx=memctx,
167 path=path, 169 path=path,
168 data='added', 170 data='added',
182 hg.update(self.repo, new) 184 hg.update(self.repo, new)
183 wrappers.parents(lambda x, y: None, u, self.repo, svn=True) 185 wrappers.parents(lambda x, y: None, u, self.repo, svn=True)
184 actual = u.popbuffer() 186 actual = u.popbuffer()
185 self.assertEqual(actual, '3:4e256962fc5d\n') 187 self.assertEqual(actual, '3:4e256962fc5d\n')
186 188
187 hg.update(self.repo, 'default') 189 hg.update(self.repo, revsymbol(self.repo, 'default'))
188 190
189 # Make sure styles work 191 # Make sure styles work
190 u.pushbuffer() 192 u.pushbuffer()
191 wrappers.parents(lambda x, y: None, u, self.repo, svn=True, style='compact') 193 wrappers.parents(lambda x, y: None, u, self.repo, svn=True, style='compact')
192 actual = u.popbuffer() 194 actual = u.popbuffer()
204 self.assertEqual(actual, '4:1083037b18d8\n') 206 self.assertEqual(actual, '4:1083037b18d8\n')
205 207
206 def test_outgoing_output(self): 208 def test_outgoing_output(self):
207 repo, repo_path = self.load_and_fetch('two_heads.svndump') 209 repo, repo_path = self.load_and_fetch('two_heads.svndump')
208 u = self.ui() 210 u = self.ui()
209 parents = (self.repo['the_branch'].node(), revlog.nullid,) 211 parents = (revsymbol(self.repo, 'the_branch').node(), revlog.nullid,)
210 def filectxfn(repo, memctx, path): 212 def filectxfn(repo, memctx, path):
211 return compathacks.makememfilectx(repo, 213 return compathacks.makememfilectx(repo,
212 memctx=memctx, 214 memctx=memctx,
213 path=path, 215 path=path,
214 data='added', 216 data='added',
227 new = lr.commitctx(ctx) 229 new = lr.commitctx(ctx)
228 hg.update(self.repo, new) 230 hg.update(self.repo, new)
229 u.pushbuffer() 231 u.pushbuffer()
230 commands.outgoing(u, self.repo, repourl(repo_path)) 232 commands.outgoing(u, self.repo, repourl(repo_path))
231 actual = u.popbuffer() 233 actual = u.popbuffer()
232 self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual) 234 self.assertTrue(node.hex(revsymbol(self.repo, 'localbranch').node())[:8] in actual)
233 self.assertEqual(actual.strip(), '5:6de15430fa20') 235 self.assertEqual(actual.strip(), '5:6de15430fa20')
234 hg.update(self.repo, 'default') 236 hg.update(self.repo, revsymbol(self.repo, 'default'))
235 u.pushbuffer() 237 u.pushbuffer()
236 commands.outgoing(u, self.repo, repourl(repo_path)) 238 commands.outgoing(u, self.repo, repourl(repo_path))
237 actual = u.popbuffer() 239 actual = u.popbuffer()
238 self.assertEqual(actual, '') 240 self.assertEqual(actual, '')
239 241