Mercurial > hgsubversion
comparison tests/test_util.py @ 1048:903c9c9dfe6a
tests: count revisions explicitly
The assumption that len(repo) corresponds to the count of actual,
usable revision in the repository fails in presence of hidden
revisions. Instead, we use a dedicated method in test_util, and change
all tests to use this for obtaining repository length -- just to be
safe...
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Fri, 09 Aug 2013 11:22:50 -0400 |
| parents | 70090e2ee262 |
| children | 608e7c8740af |
comparison
equal
deleted
inserted
replaced
| 1047:3092b3c109a8 | 1048:903c9c9dfe6a |
|---|---|
| 108 def getlocalpeer(repo): | 108 def getlocalpeer(repo): |
| 109 localrepo = getattr(repo, 'local', lambda: repo)() | 109 localrepo = getattr(repo, 'local', lambda: repo)() |
| 110 if isinstance(localrepo, bool): | 110 if isinstance(localrepo, bool): |
| 111 localrepo = repo | 111 localrepo = repo |
| 112 return localrepo | 112 return localrepo |
| 113 | |
| 114 def repolen(repo): | |
| 115 """Naively calculate the amount of available revisions in a repository. | |
| 116 | |
| 117 this is usually equal to len(repo) -- except in the face of | |
| 118 obsolete revisions. | |
| 119 """ | |
| 120 # kind of nasty way of calculating the length, but fortunately, | |
| 121 # our test repositories tend to be rather small | |
| 122 return len([r for r in repo]) | |
| 113 | 123 |
| 114 def _makeskip(name, message): | 124 def _makeskip(name, message): |
| 115 if SkipTest: | 125 if SkipTest: |
| 116 def skip(*args, **kwargs): | 126 def skip(*args, **kwargs): |
| 117 raise SkipTest(message) | 127 raise SkipTest(message) |
| 415 @property | 425 @property |
| 416 def repo(self): | 426 def repo(self): |
| 417 return hg.repository(testui(), self.wc_path) | 427 return hg.repository(testui(), self.wc_path) |
| 418 | 428 |
| 419 def pushrevisions(self, stupid=False, expected_extra_back=0): | 429 def pushrevisions(self, stupid=False, expected_extra_back=0): |
| 420 before = len(self.repo) | 430 before = repolen(self.repo) |
| 421 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid)) | 431 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
| 422 res = commands.push(self.repo.ui, self.repo) | 432 res = commands.push(self.repo.ui, self.repo) |
| 423 after = len(self.repo) | 433 after = repolen(self.repo) |
| 424 self.assertEqual(expected_extra_back, after - before) | 434 self.assertEqual(expected_extra_back, after - before) |
| 425 return res | 435 return res |
| 426 | 436 |
| 427 def svnco(self, repo_path, svnpath, rev, path): | 437 def svnco(self, repo_path, svnpath, rev, path): |
| 428 path = os.path.join(self.wc_path, path) | 438 path = os.path.join(self.wc_path, path) |
