~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: Alexander Belchenko
  • Date: 2009-05-14 12:37:52 UTC
  • mto: This revision was merged to the branch mainline in revision 4364.
  • Revision ID: bialix@ukr.net-20090514123752-prhs1hfkjzv92aig
win32utils.py: get_unicode_argv: get bzr options as tail of argv list based on the number of items in sys.argv[1:] list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
502
502
                                       ctypes.windll.shell32))
503
503
        c = INT(0)
504
504
        pargv = CommandLineToArgv(GetCommandLine(), ctypes.byref(c))
 
505
        # Skip the first argument, since we only care about parameters
505
506
        argv = [pargv[i] for i in range(1, c.value)]
506
507
        if getattr(sys, 'frozen', None) is None:
507
 
            # python.exe [PYTHON_OPTIONS] bzr [BZR_OPTIONS]
508
 
            # manually removing python, its options and 'bzr' script name
509
 
            first_item = sys.argv[0]    # should be 'bzr'
510
 
                                        # but we cannot be 100% sure
511
 
            ix = argv.index(first_item)
512
 
            if first_item == '-c':      # python -c "..."
513
 
                ix += 1                 # skip python code
514
 
            argv = argv[ix+1:]
 
508
            # Invoked via 'python.exe' which takes the form:
 
509
            #   python.exe [PYTHON_OPTIONS] C:\Path\bzr [BZR_OPTIONS]
 
510
            # we need to get only BZR_OPTIONS part,
 
511
            # so using sys.argv[1:] to get the tail of unicode argv
 
512
            tail_len = len(sys.argv[1:])
 
513
            ix = len(argv) - tail_len
 
514
            argv = argv[ix:]
515
515
        return argv
516
516
else:
517
517
    get_unicode_argv = None