/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: Aaron Bentley
  • Date: 2006-12-12 00:00:15 UTC
  • mfrom: (2155.2.4 bzr.alias_quotes)
  • mto: This revision was merged to the branch mainline in revision 2175.
  • Revision ID: aaron.bentley@utoronto.ca-20061212000015-ogni1d4lcfef673m
Merge shell-like quote handling for aliases

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
    def run_argv_aliases(self, argv, alias_argv=None):
271
271
        """Parse the command line and run with extra aliases in alias_argv."""
272
272
        if argv is None:
273
 
            warn("Passing None for [] is deprecated from bzrlib 0.10", 
 
273
            warn("Passing None for [] is deprecated from bzrlib 0.10",
274
274
                 DeprecationWarning, stacklevel=2)
275
275
            argv = []
276
276
        args, opts = parse_args(self, argv, alias_argv)
301
301
        shell error code if not.  It's OK for this method to allow
302
302
        an exception to raise up.
303
303
        """
304
 
        raise NotImplementedError('no implementation of command %r' 
 
304
        raise NotImplementedError('no implementation of command %r'
305
305
                                  % self.name())
306
306
 
307
307
    def help(self):
376
376
        args = argv
377
377
 
378
378
    options, args = parser.parse_args(args)
379
 
    opts = dict([(k, v) for k, v in options.__dict__.iteritems() if 
 
379
    opts = dict([(k, v) for k, v in options.__dict__.iteritems() if
380
380
                 v is not option.OptionParser.DEFAULT_VALUE])
381
381
    return args, opts
382
382
 
463
463
    return ret
464
464
 
465
465
 
466
 
def get_alias(cmd):
467
 
    """Return an expanded alias, or None if no alias exists"""
468
 
    import bzrlib.config
469
 
    alias = bzrlib.config.GlobalConfig().get_alias(cmd)
 
466
def get_alias(cmd, config=None):
 
467
    """Return an expanded alias, or None if no alias exists.
 
468
 
 
469
    cmd
 
470
        Command to be checked for an alias.
 
471
    config
 
472
        Used to specify an alternative config to use,
 
473
        which is especially useful for testing.
 
474
        If it is unspecified, the global config will be used.
 
475
    """
 
476
    if config is None:
 
477
        import bzrlib.config
 
478
        config = bzrlib.config.GlobalConfig()
 
479
    alias = config.get_alias(cmd)
470
480
    if (alias):
471
 
        return alias.split(' ')
 
481
        import shlex
 
482
        return [a.decode('utf-8') for a in shlex.split(alias.encode('utf-8'))]
472
483
    return None
473
484
 
474
485