/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

Merge up with bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
590
590
 
591
591
    return argdict
592
592
 
 
593
def apply_coveraged(dirname, the_callable, *args, **kwargs):
 
594
    # Cannot use "import trace", as that would import bzrlib.trace instead of
 
595
    # the standard library's trace.
 
596
    trace = __import__('trace')
 
597
 
 
598
    tracer = trace.Trace(count=1, trace=0)
 
599
    sys.settrace(tracer.globaltrace)
 
600
 
 
601
    ret = the_callable(*args, **kwargs)
 
602
 
 
603
    sys.settrace(None)
 
604
    results = tracer.results()
 
605
    results.write_results(show_missing=1, summary=False,
 
606
                          coverdir=dirname)
593
607
 
594
608
 
595
609
def apply_profiled(the_callable, *args, **kwargs):
682
696
 
683
697
    --lsprof
684
698
        Run under the Python lsprof profiler.
 
699
 
 
700
    --coverage
 
701
        Generate line coverage report in the specified directory.
685
702
    """
686
703
    argv = list(argv)
687
704
    trace.mutter("bzr arguments: %r", argv)
688
705
 
689
706
    opt_lsprof = opt_profile = opt_no_plugins = opt_builtin =  \
690
707
                opt_no_aliases = False
691
 
    opt_lsprof_file = None
 
708
    opt_lsprof_file = opt_coverage_dir = None
692
709
 
693
710
    # --no-plugins is handled specially at a very early stage. We need
694
711
    # to load plugins before doing other command parsing so that they
712
729
            opt_no_aliases = True
713
730
        elif a == '--builtin':
714
731
            opt_builtin = True
 
732
        elif a == '--coverage':
 
733
            opt_coverage_dir = argv[i + 1]
 
734
            i += 1
715
735
        elif a.startswith('-D'):
716
736
            debug.debug_flags.add(a[2:])
717
737
        else:
755
775
 
756
776
    try:
757
777
        if opt_lsprof:
 
778
            if opt_coverage_dir:
 
779
                trace.warning(
 
780
                    '--coverage ignored, because --lsprof is in use.')
758
781
            ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv)
759
782
        elif opt_profile:
 
783
            if opt_coverage_dir:
 
784
                trace.warning(
 
785
                    '--coverage ignored, because --profile is in use.')
760
786
            ret = apply_profiled(run, *run_argv)
 
787
        elif opt_coverage_dir:
 
788
            ret = apply_coveraged(opt_coverage_dir, run, *run_argv)
761
789
        else:
762
790
            ret = run(*run_argv)
763
791
        return ret or 0