Mercurial > hgsubversion
comparison tests/test_util.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 | 2148eb4b4da4 |
| children | 3e18cdcb6e00 |
comparison
equal
deleted
inserted
replaced
| 575:c278a225b750 | 576:d96aa92d9ad9 |
|---|---|
| 95 if drive: | 95 if drive: |
| 96 drive = '/' + drive | 96 drive = '/' + drive |
| 97 url = 'file://%s%s' % (drive, path) | 97 url = 'file://%s%s' % (drive, path) |
| 98 return url | 98 return url |
| 99 | 99 |
| 100 def testui(stupid=False, layout='auto'): | |
| 101 u = ui.ui() | |
| 102 bools = {True: 'true', False: 'false'} | |
| 103 u.setconfig('ui', 'quiet', bools[True]) | |
| 104 u.setconfig('hgsubversion', 'stupid', bools[stupid]) | |
| 105 u.setconfig('hgsubversion', 'layout', layout) | |
| 106 return u | |
| 107 | |
| 100 def load_svndump_fixture(path, fixture_name): | 108 def load_svndump_fixture(path, fixture_name): |
| 101 '''Loads an svnadmin dump into a fresh repo at path, which should not | 109 '''Loads an svnadmin dump into a fresh repo at path, which should not |
| 102 already exist. | 110 already exist. |
| 103 ''' | 111 ''' |
| 104 if os.path.exists(path): rmtree(path) | 112 if os.path.exists(path): rmtree(path) |
| 112 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', | 120 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', |
| 113 noupdate=True, layout='auto'): | 121 noupdate=True, layout='auto'): |
| 114 load_svndump_fixture(repo_path, fixture_name) | 122 load_svndump_fixture(repo_path, fixture_name) |
| 115 if subdir: | 123 if subdir: |
| 116 repo_path += '/' + subdir | 124 repo_path += '/' + subdir |
| 117 | 125 _ui = testui(stupid=stupid, layout=layout) |
| 118 confvars = locals() | |
| 119 def conf(): | |
| 120 _ui = ui.ui() | |
| 121 for var in ('stupid', 'layout'): | |
| 122 _ui.setconfig('hgsubversion', var, str(confvars[var])) | |
| 123 return _ui | |
| 124 _ui = conf() | |
| 125 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate) | 126 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate) |
| 126 _ui = conf() | 127 return hg.repository(testui(), wc_path) |
| 127 return hg.repository(_ui, wc_path) | |
| 128 | 128 |
| 129 def rmtree(path): | 129 def rmtree(path): |
| 130 # Read-only files cannot be removed under Windows | 130 # Read-only files cannot be removed under Windows |
| 131 for root, dirs, files in os.walk(path): | 131 for root, dirs, files in os.walk(path): |
| 132 for f in files: | 132 for f in files: |
| 190 print ''.join(difflib.unified_diff( | 190 print ''.join(difflib.unified_diff( |
| 191 add_nl(l.splitlines()), add_nl(r.splitlines()), | 191 add_nl(l.splitlines()), add_nl(r.splitlines()), |
| 192 fromfile='expected', tofile='got')) | 192 fromfile='expected', tofile='got')) |
| 193 raise | 193 raise |
| 194 | 194 |
| 195 def ui(self, stupid=False, layout='auto'): | |
| 196 return testui(stupid, layout) | |
| 197 | |
| 195 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'): | 198 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'): |
| 196 if layout == 'single': | 199 if layout == 'single': |
| 197 if subdir is None: | 200 if subdir is None: |
| 198 subdir = 'trunk' | 201 subdir = 'trunk' |
| 199 elif subdir is None: | 202 elif subdir is None: |
| 203 stupid=stupid, layout=layout) | 206 stupid=stupid, layout=layout) |
| 204 | 207 |
| 205 # define this as a property so that it reloads anytime we need it | 208 # define this as a property so that it reloads anytime we need it |
| 206 @property | 209 @property |
| 207 def repo(self): | 210 def repo(self): |
| 208 return hg.repository(ui.ui(), self.wc_path) | 211 return hg.repository(testui(), self.wc_path) |
| 209 | 212 |
| 210 def pushrevisions(self, stupid=False, expected_extra_back=0): | 213 def pushrevisions(self, stupid=False, expected_extra_back=0): |
| 211 before = len(self.repo) | 214 before = len(self.repo) |
| 212 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid)) | 215 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
| 213 commands.push(self.repo.ui, self.repo) | 216 commands.push(self.repo.ui, self.repo) |
