/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: Martin Pool
  • Date: 2009-06-10 02:51:23 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4464.
  • Revision ID: mbp@sourcefrog.net-20090610025123-2u0c0ng5jcezjzqh
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
# TODO: probably should say which arguments are candidates for glob
35
35
lazy_import(globals(), """
36
36
import codecs
37
37
import errno
 
38
import threading
38
39
from warnings import warn
39
40
 
40
41
import bzrlib
686
687
 
687
688
    tracer = trace.Trace(count=1, trace=0)
688
689
    sys.settrace(tracer.globaltrace)
 
690
    threading.settrace(tracer.globaltrace)
689
691
 
690
692
    try:
691
693
        return exception_to_return_code(the_callable, *args, **kwargs)
954
956
    return ignore_pipe
955
957
 
956
958
 
957
 
def main(argv):
 
959
def main(argv=None):
 
960
    """Main entry point of command-line interface.
 
961
 
 
962
    :param argv: list of unicode command-line arguments similar to sys.argv.
 
963
        argv[0] is script name usually, it will be ignored.
 
964
        Don't pass here sys.argv because this list contains plain strings
 
965
        and not unicode; pass None instead.
 
966
 
 
967
    :return: exit code of bzr command.
 
968
    """
958
969
    import bzrlib.ui
959
970
    bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal(
960
971
        sys.stdin, sys.stdout, sys.stderr)
963
974
    if bzrlib.version_info[3] == 'final':
964
975
        from bzrlib import symbol_versioning
965
976
        symbol_versioning.suppress_deprecation_warnings(override=False)
966
 
    try:
967
 
        user_encoding = osutils.get_user_encoding()
968
 
        argv = [a.decode(user_encoding) for a in argv[1:]]
969
 
    except UnicodeDecodeError:
970
 
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
971
 
                                                            "encoding." % a))
 
977
    if argv is None:
 
978
        argv = osutils.get_unicode_argv()
 
979
    else:
 
980
        new_argv = []
 
981
        try:
 
982
            # ensure all arguments are unicode strings
 
983
            for a in argv[1:]:
 
984
                if isinstance(a, unicode):
 
985
                    new_argv.append(a)
 
986
                else:
 
987
                    new_argv.append(a.decode('ascii'))
 
988
        except UnicodeDecodeError:
 
989
            raise errors.BzrError("argv should be list of unicode strings.")
 
990
        argv = new_argv
972
991
    ret = run_bzr_catch_errors(argv)
973
992
    trace.mutter("return code %d", ret)
974
993
    return ret