Mercurial > hgsubversion
comparison tests/test_util.py @ 652:c3900ad3bf69
test_util: support specifying a start revision
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 20 Jul 2010 11:55:07 +0200 |
parents | 3cb5042531fb |
children | 35a1e93b6f78 |
comparison
equal
deleted
inserted
replaced
651:827547493112 | 652:c3900ad3bf69 |
---|---|
96 if drive: | 96 if drive: |
97 drive = '/' + drive | 97 drive = '/' + drive |
98 url = 'file://%s%s' % (drive, path) | 98 url = 'file://%s%s' % (drive, path) |
99 return url | 99 return url |
100 | 100 |
101 def testui(stupid=False, layout='auto'): | 101 def testui(stupid=False, layout='auto', startrev=0): |
102 u = ui.ui() | 102 u = ui.ui() |
103 bools = {True: 'true', False: 'false'} | 103 bools = {True: 'true', False: 'false'} |
104 u.setconfig('ui', 'quiet', bools[True]) | 104 u.setconfig('ui', 'quiet', bools[True]) |
105 u.setconfig('hgsubversion', 'stupid', bools[stupid]) | 105 u.setconfig('hgsubversion', 'stupid', bools[stupid]) |
106 u.setconfig('hgsubversion', 'layout', layout) | 106 u.setconfig('hgsubversion', 'layout', layout) |
107 u.setconfig('hgsubversion', 'startrev', startrev) | |
107 return u | 108 return u |
108 | 109 |
109 def load_svndump_fixture(path, fixture_name): | 110 def load_svndump_fixture(path, fixture_name): |
110 '''Loads an svnadmin dump into a fresh repo at path, which should not | 111 '''Loads an svnadmin dump into a fresh repo at path, which should not |
111 already exist. | 112 already exist. |
116 inp = open(os.path.join(FIXTURES, fixture_name)) | 117 inp = open(os.path.join(FIXTURES, fixture_name)) |
117 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, | 118 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, |
118 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 119 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
119 proc.communicate() | 120 proc.communicate() |
120 | 121 |
121 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', | 122 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, |
122 noupdate=True, layout='auto'): | 123 subdir='', noupdate=True, layout='auto', |
124 startrev=0): | |
123 load_svndump_fixture(repo_path, fixture_name) | 125 load_svndump_fixture(repo_path, fixture_name) |
124 if subdir: | 126 if subdir: |
125 repo_path += '/' + subdir | 127 repo_path += '/' + subdir |
126 _ui = testui(stupid=stupid, layout=layout) | 128 _ui = testui(stupid=stupid, layout=layout, startrev=startrev) |
127 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate) | 129 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate) |
128 return hg.repository(testui(), wc_path) | 130 return hg.repository(testui(), wc_path) |
129 | 131 |
130 def rmtree(path): | 132 def rmtree(path): |
131 # Read-only files cannot be removed under Windows | 133 # Read-only files cannot be removed under Windows |
216 raise | 218 raise |
217 | 219 |
218 def ui(self, stupid=False, layout='auto'): | 220 def ui(self, stupid=False, layout='auto'): |
219 return testui(stupid, layout) | 221 return testui(stupid, layout) |
220 | 222 |
221 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'): | 223 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, |
224 layout='auto', startrev=0): | |
222 if layout == 'single': | 225 if layout == 'single': |
223 if subdir is None: | 226 if subdir is None: |
224 subdir = 'trunk' | 227 subdir = 'trunk' |
225 elif subdir is None: | 228 elif subdir is None: |
226 subdir = '' | 229 subdir = '' |
227 return load_fixture_and_fetch(fixture_name, self.repo_path, | 230 return load_fixture_and_fetch(fixture_name, self.repo_path, |
228 self.wc_path, subdir=subdir, | 231 self.wc_path, subdir=subdir, |
229 stupid=stupid, layout=layout) | 232 stupid=stupid, layout=layout, |
233 startrev=startrev) | |
230 | 234 |
231 # define this as a property so that it reloads anytime we need it | 235 # define this as a property so that it reloads anytime we need it |
232 @property | 236 @property |
233 def repo(self): | 237 def repo(self): |
234 return hg.repository(testui(), self.wc_path) | 238 return hg.repository(testui(), self.wc_path) |