/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Martin Pool
  • Date: 2006-08-16 02:53:40 UTC
  • mto: This revision was merged to the branch mainline in revision 1928.
  • Revision ID: mbp@sourcefrog.net-20060816025340-5149ec9455c00ba3
Improved reporting of bzrlib revision_id
Use this for bzr --version and in benchmark log

Show diffs side-by-side

added added

removed removed

Lines of Context:
1993
1993
            ui.ui_factory = save_ui
1994
1994
 
1995
1995
 
1996
 
def _get_bzr_branch():
1997
 
    """If bzr is run from a branch, return Branch or None"""
1998
 
    from os.path import dirname
1999
 
    
2000
 
    try:
2001
 
        branch = Branch.open(dirname(osutils.abspath(dirname(__file__))))
2002
 
        return branch
2003
 
    except errors.BzrError:
2004
 
        return None
2005
 
    
2006
 
 
2007
 
def show_version():
2008
 
    import bzrlib
2009
 
    print "Bazaar (bzr) %s" % bzrlib.__version__
2010
 
    # is bzrlib itself in a branch?
2011
 
    branch = _get_bzr_branch()
2012
 
    if branch:
2013
 
        rh = branch.revision_history()
2014
 
        revno = len(rh)
2015
 
        print "  bzr checkout, revision %d" % (revno,)
2016
 
        print "  nick: %s" % (branch.nick,)
2017
 
        if rh:
2018
 
            print "  revid: %s" % (rh[-1],)
2019
 
    print "Using python interpreter:", sys.executable
2020
 
    import site
2021
 
    print "Using python standard library:", os.path.dirname(site.__file__)
2022
 
    print "Using bzrlib:",
2023
 
    if len(bzrlib.__path__) > 1:
2024
 
        # print repr, which is a good enough way of making it clear it's
2025
 
        # more than one element (eg ['/foo/bar', '/foo/bzr'])
2026
 
        print repr(bzrlib.__path__)
2027
 
    else:
2028
 
        print bzrlib.__path__[0]
2029
 
 
2030
 
    print
2031
 
    print bzrlib.__copyright__
2032
 
    print "http://bazaar-vcs.org/"
2033
 
    print
2034
 
    print "bzr comes with ABSOLUTELY NO WARRANTY.  bzr is free software, and"
2035
 
    print "you may use, modify and redistribute it under the terms of the GNU"
2036
 
    print "General Public License version 2 or later."
2037
 
 
2038
 
 
2039
1996
class cmd_version(Command):
2040
1997
    """Show version of bzr."""
2041
1998
 
2042
1999
    @display_command
2043
2000
    def run(self):
 
2001
        from bzrlib.version import show_version
2044
2002
        show_version()
2045
2003
 
2046
2004