changeset 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
files tests/test_fetch_command.py tests/test_util.py
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_fetch_command.py
+++ b/tests/test_fetch_command.py
@@ -93,7 +93,7 @@ class TestBasicRepoLayout(test_util.Test
             'test_files_copied_from_outside_btt.svndump')
         self.assertEqual(node.hex(repo['tip'].node()),
                          '3c78170e30ddd35f2c32faa0d8646ab75bba4f73')
-        self.assertEqual(test_util.repolen(repo.changelog), 2)
+        self.assertEqual(test_util.repolen(repo), 2)
 
     def test_file_renamed_in_from_outside_btt(self):
         repo = self._load_fixture_and_fetch(
--- 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: