~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

MergeĀ fromĀ martin

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
    add them.
223
223
    """
224
224
    takes_args = ['file*']
225
 
    takes_options = ['no-recurse', 'dry-run']
 
225
    takes_options = ['no-recurse', 'dry-run', 'verbose']
226
226
 
227
 
    def run(self, file_list, no_recurse=False, dry_run=False):
 
227
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False):
228
228
        import bzrlib.add
229
229
 
230
230
        if dry_run:
238
238
        else:
239
239
            action = bzrlib.add.add_action_add_and_print
240
240
 
241
 
        bzrlib.add.smart_add(file_list, not no_recurse, action)
 
241
        added, ignored = bzrlib.add.smart_add(file_list, not no_recurse, 
 
242
                                              action)
 
243
        if len(ignored) > 0:
 
244
            for glob in sorted(ignored.keys()):
 
245
                match_len = len(ignored[glob])
 
246
                if verbose:
 
247
                    for path in ignored[glob]:
 
248
                        print "ignored %s matching \"%s\"" % (path, glob)
 
249
                else:
 
250
                    print "ignored %d file(s) matching \"%s\"" % (match_len,
 
251
                                                              glob)
 
252
            print "If you wish to add some of these files, please add them"\
 
253
                " by name."
242
254
 
243
255
 
244
256
class cmd_mkdir(Command):
399
411
            else:
400
412
                print "Using saved location: %s" % stored_loc
401
413
                location = stored_loc
 
414
 
402
415
        br_from = Branch.open(location)
403
416
        br_to = tree_to.branch
404
 
        try:
405
 
            old_rh = br_to.revision_history()
406
 
            count = tree_to.pull(br_from, overwrite)
407
 
        except DivergedBranches:
408
 
            # FIXME: Just make DivergedBranches display the right message
409
 
            # itself.
410
 
            raise BzrCommandError("These branches have diverged."
411
 
                                  "  Try merge.")
 
417
 
 
418
        old_rh = br_to.revision_history()
 
419
        count = tree_to.pull(br_from, overwrite)
 
420
 
412
421
        if br_to.get_parent() is None or remember:
413
422
            br_to.set_parent(location)
414
423
        note('%d revision(s) pulled.' % (count,))
1452
1461
            bzrlib.ui.ui_factory = save_ui
1453
1462
 
1454
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
 
1455
1478
def show_version():
1456
1479
    print "bzr (bazaar-ng) %s" % bzrlib.__version__
1457
1480
    # is bzrlib itself in a branch?
1458
 
    bzrrev = bzrlib.get_bzr_revision()
1459
 
    if bzrrev:
1460
 
        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],)
1461
1489
    print bzrlib.__copyright__
1462
1490
    print "http://bazaar-ng.org/"
1463
1491
    print
1775
1803
            show_ids=False, verbose=False):
1776
1804
        from bzrlib.missing import find_unmerged, iter_log_data
1777
1805
        from bzrlib.log import log_formatter
1778
 
        local_branch = bzrlib.branch.Branch.open_containing(".")[0]
 
1806
        local_branch = bzrlib.branch.Branch.open_containing(u".")[0]
1779
1807
        parent = local_branch.get_parent()
1780
1808
        if other_branch is None:
1781
1809
            other_branch = parent