Mercurial > hgsubversion
comparison tests/test_util.py @ 689:35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
| author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
|---|---|
| date | Wed, 08 Sep 2010 09:57:06 +0200 |
| parents | c3900ad3bf69 |
| children | c11bf0dd38d3 |
comparison
equal
deleted
inserted
replaced
| 688:073132fc27f1 | 689:35a1e93b6f78 |
|---|---|
| 182 for l in '[extensions]', 'hgsubversion=': | 182 for l in '[extensions]', 'hgsubversion=': |
| 183 print >> rc, l | 183 print >> rc, l |
| 184 | 184 |
| 185 self.repo_path = '%s/testrepo' % self.tmpdir | 185 self.repo_path = '%s/testrepo' % self.tmpdir |
| 186 self.wc_path = '%s/testrepo_wc' % self.tmpdir | 186 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
| 187 self.svn_wc = None | |
| 187 | 188 |
| 188 # Previously, we had a MockUI class that wrapped ui, and giving access | 189 # Previously, we had a MockUI class that wrapped ui, and giving access |
| 189 # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used | 190 # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used |
| 190 # instead. Using the regular UI class, with all stderr redirected to | 191 # instead. Using the regular UI class, with all stderr redirected to |
| 191 # stdout ensures that the test setup is much more similar to usage | 192 # stdout ensures that the test setup is much more similar to usage |
| 229 subdir = '' | 230 subdir = '' |
| 230 return load_fixture_and_fetch(fixture_name, self.repo_path, | 231 return load_fixture_and_fetch(fixture_name, self.repo_path, |
| 231 self.wc_path, subdir=subdir, | 232 self.wc_path, subdir=subdir, |
| 232 stupid=stupid, layout=layout, | 233 stupid=stupid, layout=layout, |
| 233 startrev=startrev) | 234 startrev=startrev) |
| 235 | |
| 236 def _add_svn_rev(self, changes): | |
| 237 '''changes is a dict of filename -> contents''' | |
| 238 if self.svn_wc is None: | |
| 239 self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc') | |
| 240 subprocess.call([ | |
| 241 'svn', 'co', '-q', fileurl(self.repo_path), | |
| 242 self.svn_wc | |
| 243 ], | |
| 244 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
| 245 | |
| 246 for filename, contents in changes.iteritems(): | |
| 247 # filenames are / separated | |
| 248 filename = filename.replace('/', os.path.sep) | |
| 249 filename = os.path.join(self.svn_wc, filename) | |
| 250 open(filename, 'w').write(contents) | |
| 251 # may be redundant | |
| 252 subprocess.call(['svn', 'add', '-q', filename], | |
| 253 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
| 254 subprocess.call([ | |
| 255 'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes'], | |
| 256 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
| 234 | 257 |
| 235 # define this as a property so that it reloads anytime we need it | 258 # define this as a property so that it reloads anytime we need it |
| 236 @property | 259 @property |
| 237 def repo(self): | 260 def repo(self): |
| 238 return hg.repository(testui(), self.wc_path) | 261 return hg.repository(testui(), self.wc_path) |
