aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/rcs.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-23 14:19:15 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-23 14:19:15 -0400
commit45cc50d7ce0b5c32a2936d6eb87a3002670924bc (patch)
tree3d7d34e3a6eb19a76aab4b649a2b72f8cef98cb9 /libbe/rcs.py
parent988b86a70cfc493f51b71e3e0b7effa439719a13 (diff)
downloadbugseverywhere-45cc50d7ce0b5c32a2936d6eb87a3002670924bc.tar.gz
Added .revision_id() to all the VCSs.
This makes it easier to compare recent revisions without a human around to give you revision numbers.
Diffstat (limited to 'libbe/rcs.py')
-rw-r--r--libbe/rcs.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/libbe/rcs.py b/libbe/rcs.py
index 1e1cfa7..d979df0 100644
--- a/libbe/rcs.py
+++ b/libbe/rcs.py
@@ -214,6 +214,16 @@ class RCS(object):
changes to commit.
"""
return None
+ def _rcs_revision_id(self, index):
+ """
+ Return the name of the <index>th revision. Index will be an
+ integer (possibly <= 0). The choice of which branch to follow
+ when crossing branches/merges is not defined.
+
+ Return None if revision IDs are not supported, or if the
+ specified revision does not exist.
+ """
+ return None
def installed(self):
try:
self._rcs_help()
@@ -407,6 +417,18 @@ class RCS(object):
pass
def postcommit(self, directory):
pass
+ def revision_id(self, index=None):
+ """
+ Return the name of the <index>th revision. The choice of
+ which branch to follow when crossing branches/merges is not
+ defined.
+
+ Return None if index==None, revision IDs are not supported, or
+ if the specified revision does not exist.
+ """
+ if index == None:
+ return None
+ return self._rcs_revision_id(index)
def _u_any_in_string(self, list, string):
"""
Return True if any of the strings in list are in string.
@@ -814,6 +836,30 @@ class RCS_commit_TestCase(RCSTestCase):
self.failUnlessEqual(
self.test_contents['rev_1'], committed_contents)
+ def test_revision_id_as_committed(self):
+ """Check for compatibility between .commit() and .revision_id()"""
+ if not self.rcs.versioned:
+ self.failUnlessEqual(self.rcs.revision_id(5), None)
+ return
+ committed_revisions = []
+ for path in self.test_files:
+ full_path = self.full_path(path)
+ self.rcs.set_file_contents(
+ full_path, self.test_contents['rev_1'])
+ revision = self.rcs.commit("Initial %s contents." % path)
+ committed_revisions.append(revision)
+ self.rcs.set_file_contents(
+ full_path, self.test_contents['uncommitted'])
+ revision = self.rcs.commit("Altered %s contents." % path)
+ committed_revisions.append(revision)
+ for i,revision in enumerate(committed_revisions):
+ self.failUnlessEqual(self.rcs.revision_id(i), revision)
+ i += -len(committed_revisions) # check negative indices
+ self.failUnlessEqual(self.rcs.revision_id(i), revision)
+ i = len(committed_revisions)
+ self.failUnlessEqual(self.rcs.revision_id(i), None)
+ self.failUnlessEqual(self.rcs.revision_id(-i-1), None)
+
class RCS_duplicate_repo_TestCase(RCSTestCase):
"""Test cases for RCS.duplicate_repo method."""