aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
Diffstat (limited to 'libbe')
-rw-r--r--libbe/git.py7
-rw-r--r--libbe/hg.py5
-rw-r--r--libbe/rcs.py9
3 files changed, 19 insertions, 2 deletions
diff --git a/libbe/git.py b/libbe/git.py
index 2b45679..f7e9646 100644
--- a/libbe/git.py
+++ b/libbe/git.py
@@ -117,7 +117,12 @@ class Git(RCS):
return full_revision
def _rcs_revision_id(self, index):
args = ["rev-list", "--first-parent", "--reverse", "HEAD"]
- status,output,error = self._u_invoke_client(*args)
+ kwargs = {"expect":(0,128)}
+ status,output,error = self._u_invoke_client(*args, **kwargs)
+ if status == 128:
+ if error.startswith("fatal: ambiguous argument 'HEAD': unknown "):
+ return None
+ raise rcs.CommandError(args, status, error)
commits = output.splitlines()
try:
return commits[index]
diff --git a/libbe/hg.py b/libbe/hg.py
index fcda829..31df1d0 100644
--- a/libbe/hg.py
+++ b/libbe/hg.py
@@ -86,7 +86,10 @@ class Hg(RCS):
kwargs = {"expect": (0,255)}
status,output,error = self._u_invoke_client(*args, **kwargs)
if status == 0:
- return output.strip()
+ id = output.strip()
+ if id == '000000000000':
+ return None # before initial commit.
+ return id
return None
diff --git a/libbe/rcs.py b/libbe/rcs.py
index d979df0..fdbb01a 100644
--- a/libbe/rcs.py
+++ b/libbe/rcs.py
@@ -860,6 +860,15 @@ class RCS_commit_TestCase(RCSTestCase):
self.failUnlessEqual(self.rcs.revision_id(i), None)
self.failUnlessEqual(self.rcs.revision_id(-i-1), None)
+ def test_revision_id_as_committed(self):
+ """Check revision id before first commit"""
+ if not self.rcs.versioned:
+ self.failUnlessEqual(self.rcs.revision_id(5), None)
+ return
+ committed_revisions = []
+ for path in self.test_files:
+ self.failUnlessEqual(self.rcs.revision_id(0), None)
+
class RCS_duplicate_repo_TestCase(RCSTestCase):
"""Test cases for RCS.duplicate_repo method."""