Skip to content

Commit

Permalink
Removing useless methods
Browse files Browse the repository at this point in the history
At first, I saw that the changes list was being sorted by the revisions, and thought that because of that
it will be necessary to allow sorting by time for the other VCSs. But, then I realized that the sorting
was being done simply so that duplicate changes with same revision will be grouped for removing. This works
no matter if the revision is a number or not.
  • Loading branch information
abyx committed Dec 22, 2009
1 parent 98f39c1 commit 4824989
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
9 changes: 0 additions & 9 deletions buildbot/status/web/console.py
Expand Up @@ -786,20 +786,11 @@ class RevisionComparator(object):

def isRevisionEarlier(self, first, second):
raise NotImplementedError

def getSortingKey(self):
raise NotImplementedError

class TimeRevisionComparator(RevisionComparator):
def isRevisionEarlier(self, first, second):
return first.when < second.when

def getSortingKey(self):
return operator.attrgetter('when')

class IntegerRevisionComparator(RevisionComparator):
def isRevisionEarlier(self, first, second):
return int(first.revision) < int(second.revision)

def getSortingKey(self):
return operator.attrgetter('revision')
17 changes: 0 additions & 17 deletions buildbot/test/test_console.py
Expand Up @@ -68,16 +68,6 @@ def testOrdersDifferentRevisions(self):
self.assertTrue(self.comparator.isRevisionEarlier(first, second))
self.assertFalse(self.comparator.isRevisionEarlier(second, first))

def testReturnedKeySortsRevisionsCorrectly(self):
my_changes = [_createDummyChange('rev' + str(i))
for i in range(1, 6)]
for i in range(1, len(my_changes)):
my_changes[i].when = my_changes[i-1].when + 1

reversed_changes = list(reversed(my_changes))
reversed_changes.sort(key=self.comparator.getSortingKey())
self.assertEqual(my_changes, reversed_changes)

class IntegerRevisionComparatorTest(unittest.TestCase):
def setUp(self):
self.comparator = console.IntegerRevisionComparator()
Expand All @@ -93,13 +83,6 @@ def testOrdersDifferentRevisions(self):
self.assertTrue(self.comparator.isRevisionEarlier(first, second))
self.assertFalse(self.comparator.isRevisionEarlier(second, first))

def testReturnedKeySortsRevisionsCorrectly(self):
my_changes = [_createDummyChange(str(i)) for i in range(1, 6)]

reversed_changes = list(reversed(my_changes))
reversed_changes.sort(key=self.comparator.getSortingKey())
self.assertEqual(my_changes, reversed_changes)

# Helper class to mock a request. We define only what we really need.
class MockRequest(object):
def childLink(self, link):
Expand Down

0 comments on commit 4824989

Please sign in to comment.