~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merged mailine

Show diffs side-by-side

added added

removed removed

Lines of Context:
792
792
        if revision is not None:
793
793
            if b2 is not None:
794
794
                raise BzrCommandError("Can't specify -r with two branches")
795
 
            if len(revision) == 1:
 
795
            if (len(revision) == 1) or (revision[1].spec is None):
796
796
                return show_diff(tree.branch, revision[0], specific_files=file_list,
797
797
                                 external_diff_options=diff_options)
798
798
            elif len(revision) == 2:
858
858
            if file_id in basis_inv:
859
859
                continue
860
860
            path = inv.id2path(file_id)
861
 
            if not os.access(b.abspath(path), os.F_OK):
 
861
            if not os.access(bzrlib.osutils.abspath(path), os.F_OK):
862
862
                continue
863
863
            print path
864
864
                
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
1952
1971
    
1953
1972
    In the future, uncommit will create a changeset, which can then
1954
1973
    be re-applied.
 
1974
 
 
1975
    TODO: jam 20060108 Add an option to allow uncommit to remove unreferenced
 
1976
              information in 'branch-as-repostory' branches.
 
1977
    TODO: jam 20060108 Add the ability for uncommit to remove unreferenced
 
1978
              information in shared branches as well.
1955
1979
    """
1956
 
    takes_options = ['all', 'verbose', 'revision',
 
1980
    takes_options = ['verbose', 'revision',
1957
1981
                    Option('dry-run', help='Don\'t actually make changes'),
1958
1982
                    Option('force', help='Say yes to all questions.')]
1959
1983
    takes_args = ['location?']
1960
1984
    aliases = []
1961
1985
 
1962
 
    def run(self, location=None, all=False,
 
1986
    def run(self, location=None, 
1963
1987
            dry_run=False, verbose=False,
1964
1988
            revision=None, force=False):
1965
1989
        from bzrlib.branch import Branch
1996
2020
                    print 'Canceled'
1997
2021
                    return 0
1998
2022
 
1999
 
        uncommit(b, remove_files=all,
2000
 
                dry_run=dry_run, verbose=verbose,
 
2023
        uncommit(b, dry_run=dry_run, verbose=verbose,
2001
2024
                revno=revno)
2002
2025
 
2003
2026