[Pkg-bazaar-commits] ./bzr/unstable r606: - new bzrlib.get_bzr_revision() tells about the history of

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:18:51 UTC 2009


------------------------------------------------------------
revno: 606
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-05-31 13:02:45 +1000
message:
  - new bzrlib.get_bzr_revision() tells about the history of 
    bzr itself
  - also display revision-id in --version output
modified:
  bzrlib/__init__.py
  bzrlib/commands.py
-------------- next part --------------
=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2005-05-19 09:59:49 +0000
+++ b/bzrlib/__init__.py	2005-05-31 03:02:45 +0000
@@ -47,3 +47,18 @@
 __copyright__ = "Copyright 2005 Canonical Development Ltd."
 __author__ = "Martin Pool <mbp at canonical.com>"
 __version__ = '0.0.5pre'
+
+
+def get_bzr_revision():
+    """If bzr is run from a branch, return (revno,revid) or None"""
+    from errors import BzrError
+    try:
+        branch = Branch(__path__[0])
+        rh = branch.revision_history()
+        if rh:
+            return len(rh), rh[-1]
+        else:
+            return None
+    except BzrError:
+        return None
+    

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-05-31 02:56:12 +0000
+++ b/bzrlib/commands.py	2005-05-31 03:02:45 +0000
@@ -964,12 +964,9 @@
 def show_version():
     print "bzr (bazaar-ng) %s" % bzrlib.__version__
     # is bzrlib itself in a branch?
-    try:
-        branch = Branch(bzrlib.__path__[0])
-    except BzrError:
-        pass
-    else:
-        print "  (bzr checkout, revision %s)" % branch.revno()
+    bzrrev = bzrlib.get_bzr_revision()
+    if bzrrev:
+        print "  (bzr checkout, revision %d {%s})" % bzrrev
     print bzrlib.__copyright__
     print "http://bazaar-ng.org/"
     print



More information about the Pkg-bazaar-commits mailing list