~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-11-28 08:03:42 UTC
  • mto: (1185.33.61 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: mbp@sourcefrog.net-20051128080342-b7db3190dca90484
[broken] start converting basic_io to more rfc822-like format

Suggestions from mailing list:
 
  no double quotes
  no cute right-alignment
  no escaping
  just indent continuation lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
447
447
        os.remove(pfname)
448
448
 
449
449
 
450
 
def apply_lsprofiled(the_callable, *args, **kwargs):
451
 
    from bzrlib.lsprof import profile
452
 
    ret,stats = profile(the_callable,*args,**kwargs)
453
 
    stats.sort()
454
 
    stats.pprint()
455
 
    return ret
456
 
 
457
450
def run_bzr(argv):
458
451
    """Execute a command.
459
452
 
476
469
        other behaviour.)
477
470
 
478
471
    --profile
479
 
        Run under the Python hotshot profiler.
480
 
 
481
 
    --lsprof
482
 
        Run under the Python lsprof profiler.
 
472
        Run under the Python profiler.
483
473
    """
484
474
    argv = [a.decode(bzrlib.user_encoding) for a in argv]
485
475
 
486
 
    opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = False
 
476
    opt_profile = opt_no_plugins = opt_builtin = False
487
477
 
488
478
    # --no-plugins is handled specially at a very early stage. We need
489
479
    # to load plugins before doing other command parsing so that they
492
482
    for a in argv:
493
483
        if a == '--profile':
494
484
            opt_profile = True
495
 
        elif a == '--lsprof':
496
 
            opt_lsprof = True
497
485
        elif a == '--no-plugins':
498
486
            opt_no_plugins = True
499
487
        elif a == '--builtin':
526
514
    cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
527
515
 
528
516
    try:
529
 
        if opt_lsprof:
530
 
            ret = apply_lsprofiled(cmd_obj.run_argv, argv)
531
 
        elif opt_profile:
 
517
        if opt_profile:
532
518
            ret = apply_profiled(cmd_obj.run_argv, argv)
533
519
        else:
534
520
            ret = cmd_obj.run_argv(argv)
557
543
 
558
544
def main(argv):
559
545
    import bzrlib.ui
560
 
    from bzrlib.ui.text import TextUIFactory
561
546
    ## bzrlib.trace.enable_default_logging()
562
547
    bzrlib.trace.log_startup(argv)
563
 
    bzrlib.ui.ui_factory = TextUIFactory()
 
548
    bzrlib.ui.ui_factory = bzrlib.ui.TextUIFactory()
564
549
    ret = run_bzr_catch_errors(argv[1:])
565
550
    mutter("return code %d", ret)
566
551
    return ret