200
200
assert isinstance(arguments, dict)
201
201
cmdargs = options.copy()
202
202
cmdargs.update(arguments)
203
if self.__doc__ == Command.__doc__:
204
from warnings import warn
205
warn("No help message set for %r" % self)
203
assert self.__doc__ != Command.__doc__, \
204
("No help message set for %r" % self)
206
205
self.status = self.run(**cmdargs)
207
if self.status is None:
412
409
whether already versioned or not, are searched for files or
413
410
subdirectories that are neither versioned or ignored, and these
414
411
are added. This search proceeds recursively into versioned
415
directories. If no names are given '.' is assumed.
417
Therefore simply saying 'bzr add' will version all files that
414
Therefore simply saying 'bzr add .' will version all files that
418
415
are currently unknown.
420
417
TODO: Perhaps adding a file whose directly is not versioned should
421
418
recursively add that parent, rather than giving an error?
423
takes_args = ['file*']
420
takes_args = ['file+']
424
421
takes_options = ['verbose', 'no-recurse']
426
423
def run(self, file_list, verbose=False, no_recurse=False):
598
595
cache_root = tempfile.mkdtemp()
597
if revision is not None:
598
if len(revision) > 1:
599
raise BzrCommandError('bzr branch --revision takes exactly 1 revision value')
601
601
revision = [None]
602
elif len(revision) > 1:
603
raise BzrCommandError('bzr branch --revision takes exactly 1 revision value')
607
604
br_from = find_cached_branch(from_location, cache_root)
631
628
br_to.set_root_id(br_from.get_root_id())
634
if revision[0] is None:
635
revno = br_from.revno()
637
revno, rev_id = br_from.get_revision_info(revision[0])
631
revno = br_to.lookup_revision(revision[0])
639
633
br_to.update_revisions(br_from, stop_revision=revno)
640
634
except NoSuchRevision:
1260
class cmd_scan_cache(Command):
1263
from bzrlib.hashcache import HashCache
1270
print '%6d stats' % c.stat_count
1271
print '%6d in hashcache' % len(c._cache)
1272
print '%6d files removed from cache' % c.removed_count
1273
print '%6d hashes updated' % c.update_count
1274
print '%6d files changed too recently to cache' % c.danger_count
1281
1254
class cmd_upgrade(Command):
1282
1255
"""Upgrade branch storage to current format.
1306
1279
class cmd_selftest(Command):
1307
1280
"""Run internal test suite"""
1309
takes_options = ['verbose']
1310
def run(self, verbose=False):
1311
1283
from bzrlib.selftest import selftest
1312
return int(not selftest(verbose=verbose))
1284
return int(not selftest())
1315
1287
class cmd_version(Command):
1430
1402
def run(self, revision=None):
1431
1403
from bzrlib.merge import merge
1432
1404
if revision is None:
1434
1406
elif len(revision) != 1:
1435
1407
raise BzrCommandError('bzr merge-revert --revision takes exactly 1 argument')
1436
1408
merge(('.', revision[0]), parse_spec('.'),
1675
1647
This is also a non-master option.
1676
1648
--help Run help and exit, also a non-master option (I think that should stay, though)
1678
>>> argv, opts = _parse_master_args(['--test'])
1650
>>> argv, opts = _parse_master_args(['bzr', '--test'])
1679
1651
Traceback (most recent call last):
1681
1653
BzrCommandError: Invalid master option: 'test'
1682
>>> argv, opts = _parse_master_args(['--version', 'command'])
1654
>>> argv, opts = _parse_master_args(['bzr', '--version', 'command'])
1685
1657
>>> print opts['version']
1687
>>> argv, opts = _parse_master_args(['--profile', 'command', '--more-options'])
1659
>>> argv, opts = _parse_master_args(['bzr', '--profile', 'command', '--more-options'])
1689
1661
['command', '--more-options']
1690
1662
>>> print opts['profile']
1692
>>> argv, opts = _parse_master_args(['--no-plugins', 'command'])
1664
>>> argv, opts = _parse_master_args(['bzr', '--no-plugins', 'command'])
1695
1667
>>> print opts['no-plugins']
1697
1669
>>> print opts['profile']
1699
>>> argv, opts = _parse_master_args(['command', '--profile'])
1671
>>> argv, opts = _parse_master_args(['bzr', 'command', '--profile'])
1701
1673
['command', '--profile']
1702
1674
>>> print opts['profile']
1684
# This is the point where we could hook into argv[0] to determine
1685
# what front-end is supposed to be run
1686
# For now, we are just ignoring it.
1687
cmd_name = argv.pop(0)
1712
1688
for arg in argv[:]:
1713
1689
if arg[:2] != '--': # at the first non-option, we return the rest
1729
1705
This is similar to main(), but without all the trappings for
1730
1706
logging and error handling.
1733
The command-line arguments, without the program name.
1735
Returns a command status or raises an exception.
1737
1708
argv = [a.decode(bzrlib.user_encoding) for a in argv]
1739
# some options like --builtin and --no-plugins have special effects
1740
argv, master_opts = _parse_master_args(argv)
1741
if not master_opts['no-plugins']:
1742
from bzrlib.plugin import load_plugins
1745
args, opts = parse_args(argv)
1747
if master_opts.get('help') or 'help' in opts:
1748
from bzrlib.help import help
1755
if 'version' in opts:
1759
if args and args[0] == 'builtin':
1760
include_plugins=False
1711
# some options like --builtin and --no-plugins have special effects
1712
argv, master_opts = _parse_master_args(argv)
1713
if not master_opts['no-plugins']:
1714
from bzrlib.plugin import load_plugins
1717
args, opts = parse_args(argv)
1719
if master_opts['help']:
1720
from bzrlib.help import help
1728
from bzrlib.help import help
1734
elif 'version' in opts:
1737
elif args and args[0] == 'builtin':
1738
include_plugins=False
1764
1740
cmd = str(args.pop(0))
1765
1741
except IndexError:
1766
print >>sys.stderr, "please try 'bzr help' for help"
1769
1747
plugins_override = not (master_opts['builtin'])
1770
1748
canonical_cmd, cmd_class = get_cmd_class(cmd, plugins_override=plugins_override)