~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge from integration.

Show diffs side-by-side

added added

removed removed

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