comparison tests/test_utility_commands.py @ 1092:cd0d14e25757

layouts: add custom layout for those of us that need weird mappings This adds a config-driven custom layout, targeted at the case where you need to fetch a small subset of a large number of subversion branches, or where your subversion layout doesn't match the standard trunk/branches/tags layout very well.
author David Schleimer <dschleimer@fb.com>
date Mon, 26 Aug 2013 16:40:31 -0700
parents 8f3a241b790d
children e73df57b2b07
comparison
equal deleted inserted replaced
1091:384eb7e05b61 1092:cd0d14e25757
31 return util.normalize_url(test_util.fileurl(repo_path)) 31 return util.normalize_url(test_util.fileurl(repo_path))
32 32
33 class UtilityTests(test_util.TestBase): 33 class UtilityTests(test_util.TestBase):
34 stupid_mode_tests = True 34 stupid_mode_tests = True
35 35
36 def test_info_output(self): 36 def test_info_output(self, custom=False):
37 repo, repo_path = self.load_and_fetch('two_heads.svndump') 37 if custom:
38 config = {
39 'hgsubversionbranch.default': 'trunk',
40 'hgsubversionbranch.the_branch': 'branches/the_branch',
41 }
42 else:
43 config = {}
44 repo, repo_path = self.load_and_fetch('two_heads.svndump', config=config)
38 hg.update(self.repo, 'the_branch') 45 hg.update(self.repo, 'the_branch')
39 u = self.ui() 46 u = self.ui()
40 u.pushbuffer() 47 u.pushbuffer()
41 svncommands.info(u, self.repo) 48 svncommands.info(u, self.repo)
42 actual = u.popbuffer() 49 actual = u.popbuffer()
85 'branch': 'trunk', 92 'branch': 'trunk',
86 'rev': 6, 93 'rev': 6,
87 }) 94 })
88 self.assertMultiLineEqual(actual, expected) 95 self.assertMultiLineEqual(actual, expected)
89 96
90 def test_info_single(self): 97 def test_info_output_custom(self):
91 repo, repo_path = self.load_and_fetch('two_heads.svndump', subdir='trunk') 98 self.test_info_output(custom=True)
99
100 def test_info_single(self, custom=False):
101 if custom:
102 subdir=None
103 config = {
104 'hgsubversionbranch.default': 'trunk/'
105 }
106 else:
107 subdir='trunk'
108 config = {}
109 repo, repo_path = self.load_and_fetch('two_heads.svndump',
110 subdir=subdir,
111 config=config)
92 hg.update(self.repo, 'tip') 112 hg.update(self.repo, 'tip')
93 u = self.ui() 113 u = self.ui()
94 u.pushbuffer() 114 u.pushbuffer()
95 svncommands.info(u, self.repo) 115 svncommands.info(u, self.repo)
96 actual = u.popbuffer() 116 actual = u.popbuffer()
99 'repourl': repourl(repo_path), 119 'repourl': repourl(repo_path),
100 'branch': 'trunk', 120 'branch': 'trunk',
101 'rev': 6, 121 'rev': 6,
102 }) 122 })
103 self.assertMultiLineEqual(expected, actual) 123 self.assertMultiLineEqual(expected, actual)
124
125 def test_info_custom_single(self):
126 self.test_info_single(custom=True)
104 127
105 def test_missing_metadata(self): 128 def test_missing_metadata(self):
106 self._load_fixture_and_fetch('two_heads.svndump') 129 self._load_fixture_and_fetch('two_heads.svndump')
107 os.remove(self.repo.join('svn/branch_info')) 130 os.remove(self.repo.join('svn/branch_info'))
108 svncommands.updatemeta(self.ui(), self.repo, []) 131 svncommands.updatemeta(self.ui(), self.repo, [])
230 wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True) 253 wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True)
231 self.assertEqual(self.repo['tip'].branch(), 'localbranch') 254 self.assertEqual(self.repo['tip'].branch(), 'localbranch')
232 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) 255 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0])
233 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) 256 self.assertNotEqual(beforerebasehash, self.repo['tip'].node())
234 257
235 def test_genignore(self): 258 def test_genignore(self, layout='auto'):
236 """ Test generation of .hgignore file. """ 259 """ Test generation of .hgignore file. """
237 repo = self._load_fixture_and_fetch('ignores.svndump', noupdate=False) 260 if layout == 'custom':
261 config = {
262 'hgsubversionbranch.default': 'trunk',
263 }
264 else:
265 config = {}
266 repo = self._load_fixture_and_fetch('ignores.svndump',
267 layout=layout,
268 noupdate=False,
269 config=config)
238 u = self.ui() 270 u = self.ui()
239 u.pushbuffer() 271 u.pushbuffer()
240 svncommands.genignore(u, repo, self.wc_path) 272 svncommands.genignore(u, repo, self.wc_path)
241 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), 273 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(),
242 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') 274 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n')
243 275
244 def test_genignore_single(self): 276 def test_genignore_single(self):
245 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') 277 self.test_genignore(layout='single')
246 hg.update(self.repo, 'tip') 278
247 u = self.ui() 279 def test_genignore_custom(self):
248 u.pushbuffer() 280 self.test_genignore(layout='custom')
249 svncommands.genignore(u, self.repo, self.wc_path)
250 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(),
251 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n')
252 281
253 def test_list_authors(self): 282 def test_list_authors(self):
254 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') 283 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
255 u = self.ui() 284 u = self.ui()
256 u.pushbuffer() 285 u.pushbuffer()