/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/win32utils.py

  • Committer: Jason Spashett
  • Date: 2010-06-18 10:57:20 UTC
  • mto: This revision was merged to the branch mainline in revision 5315.
  • Revision ID: jason@spashett.com-20100618105720-xijod9h4riss3k11
Reverse merge -r 5280..5279

Show diffs side-by-side

added added

removed removed

Lines of Context:
535
535
                                  default.
536
536
    :return: A list of unicode strings.
537
537
    """
 
538
    # First, spit the command line
538
539
    s = cmdline.Splitter(command_line, single_quotes_allowed=single_quotes_allowed)
539
 
    # Now that we've split the content, expand globs if necessary
 
540
    
 
541
    # Bug #587868 Now make sure that the length of s agrees with sys.argv 
 
542
    # we do this by simply counting the number of arguments in each. The counts should 
 
543
    # agree no matter what encoding sys.argv is in (AFAIK) 
 
544
    # len(arguments) < len(sys.argv) should be an impossibility since python gets 
 
545
    # args from the very same PEB as does GetCommandLineW
 
546
    arguments = list(s)
 
547
    
 
548
    # Bug #588277 remove the --profile-imports from the command line arguments
 
549
    # as is also done in the main bzr module
 
550
    if '--profile-imports' not in sys.argv:
 
551
        if (False, '--profile-imports') in arguments:
 
552
            arguments.remove((False, '--profile-imports'))
 
553
        elif (True, '--profile-imports') in arguments:
 
554
            arguments.remove((True, '--profile-imports'))
 
555
    
 
556
    # Now shorten the command line we get from GetCommandLineW to match sys.argv
 
557
    if len(arguments) < len(sys.argv):
 
558
        from bzrlib.errors import InternalBzrError
 
559
        raise InternalBzrError("len(GetCommandLineW(...)) < len(sys.argv) should not be possible")
 
560
    arguments = arguments[len(arguments) - len(sys.argv):]
 
561
    
 
562
    # Carry on to process globs (metachars) in the command line
 
563
    # expand globs if necessary
540
564
    # TODO: Use 'globbing' instead of 'glob.glob', this gives us stuff like
541
565
    #       '**/' style globs
542
 
    args = []
543
 
    for is_quoted, arg in s:
 
566
    argv = []
 
567
    for is_quoted, arg in arguments:
544
568
        if is_quoted or not glob.has_magic(arg):
545
 
            args.append(arg)
 
569
            argv.append(arg)
546
570
        else:
547
 
            args.extend(glob_one(arg))
548
 
    return args
 
571
            argv.extend(glob_one(arg))
 
572
    return argv
549
573
 
550
574
 
551
575
if has_ctypes and winver != 'Windows 98':
558
582
            raise ctypes.WinError()
559
583
        # Skip the first argument, since we only care about parameters
560
584
        argv = _command_line_to_argv(command_line)[1:]
561
 
        if getattr(sys, 'frozen', None) is None:
562
 
            # Invoked via 'python.exe' which takes the form:
563
 
            #   python.exe [PYTHON_OPTIONS] C:\Path\bzr [BZR_OPTIONS]
564
 
            # we need to get only BZR_OPTIONS part,
565
 
            # We already removed 'python.exe' so we remove everything up to and
566
 
            # including the first non-option ('-') argument.
567
 
            for idx in xrange(len(argv)):
568
 
                if argv[idx][:1] != '-':
569
 
                    break
570
 
            argv = argv[idx+1:]
571
585
        return argv
572
586
else:
573
587
    get_unicode_argv = None