~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2006-01-03 15:10:11 UTC
  • mto: (1185.50.36 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1536.
  • Revision ID: john@arbash-meinel.com-20060103151011-2ad890a2ff1475a4
Deprecating bzrlib.get_bzr_revision, in favor of bzrlib.builtins._get_bzr_branch

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
 
        revno, revision_id, branch = bzrrev
 
1481
    branch = _get_bzr_branch()
 
1482
    if branch:
 
1483
        rh = branch.revision_history()
 
1484
        revno = len(rh)
1470
1485
        print "  bzr checkout, revision %d" % (revno,)
1471
1486
        print "  nick: %s" % (branch.nick,)
1472
 
        print "  revid: %s" % (revision_id,)
 
1487
        if rh:
 
1488
            print "  revid: %s" % (rh[-1],)
1473
1489
    print bzrlib.__copyright__
1474
1490
    print "http://bazaar-ng.org/"
1475
1491
    print