~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Andrew Bennetts
  • Date: 2007-08-30 08:11:54 UTC
  • mfrom: (2766 +trunk)
  • mto: (2535.3.55 repo-refactor)
  • mto: This revision was merged to the branch mainline in revision 2772.
  • Revision ID: andrew.bennetts@canonical.com-20070830081154-16hebp2xwr15x2hc
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
from bzrlib.symbol_versioning import (
52
52
    deprecated_function,
53
53
    deprecated_method,
54
 
    zero_eight,
55
 
    zero_eleven,
56
54
    )
57
55
# Compatibility
58
56
from bzrlib.option import Option
511
509
            return None
512
510
 
513
511
 
514
 
# Technically, this function hasn't been use in a *really* long time
515
 
# but we are only deprecating it now.
516
 
@deprecated_function(zero_eleven)
517
 
def parse_spec(spec):
518
 
    """
519
 
    >>> parse_spec(None)
520
 
    [None, None]
521
 
    >>> parse_spec("./")
522
 
    ['./', None]
523
 
    >>> parse_spec("../@")
524
 
    ['..', -1]
525
 
    >>> parse_spec("../f/@35")
526
 
    ['../f', 35]
527
 
    >>> parse_spec('./@revid:john@arbash-meinel.com-20050711044610-3ca0327c6a222f67')
528
 
    ['.', 'revid:john@arbash-meinel.com-20050711044610-3ca0327c6a222f67']
529
 
    """
530
 
    if spec is None:
531
 
        return [None, None]
532
 
    if '/@' in spec:
533
 
        parsed = spec.split('/@')
534
 
        assert len(parsed) == 2
535
 
        if parsed[1] == "":
536
 
            parsed[1] = -1
537
 
        else:
538
 
            try:
539
 
                parsed[1] = int(parsed[1])
540
 
            except ValueError:
541
 
                pass # We can allow stuff like ./@revid:blahblahblah
542
 
            else:
543
 
                assert parsed[1] >=0
544
 
    else:
545
 
        parsed = [spec, None]
546
 
    return parsed
547
 
 
548
512
def parse_args(command, argv, alias_argv=None):
549
513
    """Parse command line.
550
514
    
806
770
    import bzrlib.ui
807
771
    from bzrlib.ui.text import TextUIFactory
808
772
    bzrlib.ui.ui_factory = TextUIFactory()
809
 
    argv = [a.decode(bzrlib.user_encoding) for a in argv[1:]]
 
773
    try:
 
774
        argv = [a.decode(bzrlib.user_encoding) for a in argv[1:]]
 
775
    except UnicodeDecodeError:
 
776
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
 
777
                                                            "encoding." % a))
810
778
    ret = run_bzr_catch_errors(argv)
811
779
    trace.mutter("return code %d", ret)
812
780
    return ret