/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

  • Committer: Aaron Bentley
  • Date: 2008-10-12 16:11:17 UTC
  • mfrom: (3774 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3775.
  • Revision ID: aaron@aaronbentley.com-20081012161117-et0n1u2221zzwc8z
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    errors,
44
44
    option,
45
45
    osutils,
46
 
    registry,
47
46
    trace,
48
47
    win32utils,
49
48
    )
50
49
""")
51
50
 
52
 
from bzrlib.symbol_versioning import (
53
 
    deprecated_function,
54
 
    deprecated_method,
55
 
    )
 
51
from bzrlib import registry
56
52
# Compatibility
57
53
from bzrlib.option import Option
58
54
 
675
671
def run_bzr(argv):
676
672
    """Execute a command.
677
673
 
678
 
    This is similar to main(), but without all the trappings for
679
 
    logging and error handling.  
680
 
    
681
674
    argv
682
675
       The command-line arguments, without the program name from argv[0]
683
676
       These should already be decoded. All library/test code calling
755
748
        from bzrlib.builtins import cmd_version
756
749
        cmd_version().run_argv_aliases([])
757
750
        return 0
758
 
        
 
751
 
759
752
    if not opt_no_plugins:
760
753
        from bzrlib.plugin import load_plugins
761
754
        load_plugins()
768
761
    if not opt_no_aliases:
769
762
        alias_argv = get_alias(argv[0])
770
763
        if alias_argv:
771
 
            alias_argv = [a.decode(bzrlib.user_encoding) for a in alias_argv]
 
764
            user_encoding = osutils.get_user_encoding()
 
765
            alias_argv = [a.decode(user_encoding) for a in alias_argv]
772
766
            argv[0] = alias_argv.pop(0)
773
767
 
774
768
    cmd = argv.pop(0)
781
775
    run_argv = [argv, alias_argv]
782
776
 
783
777
    try:
 
778
        # We can be called recursively (tests for example), but we don't want
 
779
        # the verbosity level to propagate.
 
780
        saved_verbosity_level = option._verbosity_level
 
781
        option._verbosity_level = 0
784
782
        if opt_lsprof:
785
783
            if opt_coverage_dir:
786
784
                trace.warning(
796
794
        else:
797
795
            ret = run(*run_argv)
798
796
        if 'memory' in debug.debug_flags:
799
 
            try:
800
 
                status_file = file('/proc/%s/status' % os.getpid(), 'rb')
801
 
            except IOError:
802
 
                pass
803
 
            else:
804
 
                status = status_file.read()
805
 
                status_file.close()
806
 
                trace.note("Process status after command:")
807
 
                for line in status.splitlines():
808
 
                    trace.note(line)
 
797
            trace.debug_memory('Process status after command:', short=False)
809
798
        return ret or 0
810
799
    finally:
811
 
        # reset, in case we may do other commands later within the same process
812
 
        option._verbosity_level = 0
 
800
        # reset, in case we may do other commands later within the same
 
801
        # process. Commands that want to execute sub-commands must propagate
 
802
        # --verbose in their own way.
 
803
        option._verbosity_level = saved_verbosity_level
813
804
 
814
805
def display_command(func):
815
806
    """Decorator that suppresses pipe/interrupt errors."""
835
826
    import bzrlib.ui
836
827
    from bzrlib.ui.text import TextUIFactory
837
828
    bzrlib.ui.ui_factory = TextUIFactory()
838
 
     
 
829
 
839
830
    # Is this a final release version? If so, we should suppress warnings
840
831
    if bzrlib.version_info[3] == 'final':
841
832
        from bzrlib import symbol_versioning
842
833
        symbol_versioning.suppress_deprecation_warnings(override=False)
843
834
    try:
844
 
        argv = [a.decode(bzrlib.user_encoding) for a in argv[1:]]
 
835
        user_encoding = osutils.get_user_encoding()
 
836
        argv = [a.decode(user_encoding) for a in argv[1:]]
845
837
    except UnicodeDecodeError:
846
838
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
847
839
                                                            "encoding." % a))