~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Martin Pool
  • Date: 2006-01-06 01:13:05 UTC
  • mfrom: (1534.1.4 integration)
  • Revision ID: mbp@sourcefrog.net-20060106011305-3772285d84b5cbb4
[merge] robertc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1461
1461
            bzrlib.ui.ui_factory = save_ui
1462
1462
 
1463
1463
 
 
1464
def _get_bzr_branch():
 
1465
    """If bzr is run from a branch, return Branch or None"""
 
1466
    import bzrlib.errors
 
1467
    from bzrlib.branch import Branch
 
1468
    from bzrlib.osutils import abspath
 
1469
    from os.path import dirname
 
1470
    
 
1471
    try:
 
1472
        branch = Branch.open(dirname(abspath(dirname(__file__))))
 
1473
        return branch
 
1474
    except bzrlib.errors.BzrError:
 
1475
        return None
 
1476
    
 
1477
 
1464
1478
def show_version():
1465
1479
    print "bzr (bazaar-ng) %s" % bzrlib.__version__
1466
1480
    # is bzrlib itself in a branch?
1467
 
    bzrrev = bzrlib.get_bzr_revision()
1468
 
    if bzrrev:
1469
 
        print "  (bzr checkout, revision %d {%s})" % bzrrev
 
1481
    branch = _get_bzr_branch()
 
1482
    if branch:
 
1483
        rh = branch.revision_history()
 
1484
        revno = len(rh)
 
1485
        print "  bzr checkout, revision %d" % (revno,)
 
1486
        print "  nick: %s" % (branch.nick,)
 
1487
        if rh:
 
1488
            print "  revid: %s" % (rh[-1],)
1470
1489
    print bzrlib.__copyright__
1471
1490
    print "http://bazaar-ng.org/"
1472
1491
    print