/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: Alexander Belchenko
  • Date: 2009-05-13 19:26:14 UTC
  • mto: This revision was merged to the branch mainline in revision 4364.
  • Revision ID: bialix@ukr.net-20090513192614-92n4xfzwshxshy79
Using unicode Windows API to obtain command-line arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
952
952
    return ignore_pipe
953
953
 
954
954
 
955
 
def main(argv):
 
955
def main(argv=None):
 
956
    """Main entry point of command-line interface.
 
957
 
 
958
    :param argv: list of unicode command-line arguments similar to sys.argv.
 
959
        argv[0] is script name usually, it will be ignored.
 
960
        Don't pass here sys.argv because this list contains plain strings
 
961
        and not unicode; pass None instead.
 
962
 
 
963
    :return: exit code of bzr command.
 
964
    """
956
965
    import bzrlib.ui
957
966
    bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal(
958
967
        sys.stdin, sys.stdout, sys.stderr)
961
970
    if bzrlib.version_info[3] == 'final':
962
971
        from bzrlib import symbol_versioning
963
972
        symbol_versioning.suppress_deprecation_warnings(override=False)
964
 
    try:
965
 
        user_encoding = osutils.get_user_encoding()
966
 
        argv = [a.decode(user_encoding) for a in argv[1:]]
967
 
    except UnicodeDecodeError:
968
 
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
969
 
                                                            "encoding." % a))
 
973
    if argv is None:
 
974
        argv = osutils.get_unicode_argv()
 
975
    else:
 
976
        argv = argv[1:]
 
977
        try:
 
978
            # check for presence of non-ascii strings
 
979
            for a in argv:
 
980
                if not isinstance(a, unicode):
 
981
                    a.decode('ascii')
 
982
        except UnicodeDecodeError:
 
983
            raise errors.BzrError("argv should be list of unicode strings.")
970
984
    ret = run_bzr_catch_errors(argv)
971
985
    trace.mutter("return code %d", ret)
972
986
    return ret