Mercurial > hgsubversion
comparison tests/test_util.py @ 1463:86ae03f889a4
test_util: allow counting converted revisions
...and while at it, use a more reliable test for filtering out
obsolete revisions.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Sat, 10 Aug 2013 07:46:21 +0200 |
parents | 7dc5c4368837 |
children | 1a4d0f1563d0 |
comparison
equal
deleted
inserted
replaced
1462:7dc5c4368837 | 1463:86ae03f889a4 |
---|---|
206 localrepo = getattr(repo, 'local', lambda: repo)() | 206 localrepo = getattr(repo, 'local', lambda: repo)() |
207 if isinstance(localrepo, bool): | 207 if isinstance(localrepo, bool): |
208 localrepo = repo | 208 localrepo = repo |
209 return localrepo | 209 return localrepo |
210 | 210 |
211 def repolen(repo): | 211 def repolen(repo, svnonly=False): |
212 """Naively calculate the amount of available revisions in a repository. | 212 """Naively calculate the amount of available revisions in a repository. |
213 | 213 |
214 this is usually equal to len(repo) -- except in the face of | 214 this is usually equal to len(repo) -- except in the face of |
215 obsolete revisions. | 215 obsolete revisions. |
216 | |
217 if svnonly is true, only count revisions converted from Subversion. | |
216 """ | 218 """ |
217 # kind of nasty way of calculating the length, but fortunately, | 219 # kind of nasty way of calculating the length, but fortunately, |
218 # our test repositories tend to be rather small | 220 # our test repositories tend to be rather small |
219 return len([r for r in repo]) | 221 revs = set(repo) |
222 | |
223 if obsolete: | |
224 revs -= obsolete.getrevs(repo, 'obsolete') | |
225 | |
226 if svnonly: | |
227 revs = set(r for r in revs if util.getsvnrev(repo[r])) | |
228 | |
229 return len(revs) | |
220 | 230 |
221 def _makeskip(name, message): | 231 def _makeskip(name, message): |
222 if SkipTest: | 232 if SkipTest: |
223 def skip(*args, **kwargs): | 233 def skip(*args, **kwargs): |
224 raise SkipTest(message) | 234 raise SkipTest(message) |