# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1376113581 -7200 # Node ID 86ae03f889a44cac64a7ca42468fdd0e2e598d93 # Parent 7dc5c4368837bf58dbc8f5504579eb839a215188 test_util: allow counting converted revisions ...and while at it, use a more reliable test for filtering out obsolete revisions. diff --git a/tests/test_fetch_command.py b/tests/test_fetch_command.py --- 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( diff --git a/tests/test_util.py b/tests/test_util.py --- 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: