diff 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
line wrap: on
line diff
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -208,15 +208,25 @@ def getlocalpeer(repo):
         localrepo = repo
     return localrepo
 
-def repolen(repo):
+def repolen(repo, svnonly=False):
     """Naively calculate the amount of available revisions in a repository.
 
     this is usually equal to len(repo) -- except in the face of
     obsolete revisions.
+
+    if svnonly is true, only count revisions converted from Subversion.
     """
     # kind of nasty way of calculating the length, but fortunately,
     # our test repositories tend to be rather small
-    return len([r for r in repo])
+    revs = set(repo)
+
+    if obsolete:
+        revs -= obsolete.getrevs(repo, 'obsolete')
+
+    if svnonly:
+        revs = set(r for r in revs if util.getsvnrev(repo[r]))
+
+    return len(revs)
 
 def _makeskip(name, message):
     if SkipTest: