27
27
# would help with validation and shell completion.
30
# TODO: Help messages for options.
32
# TODO: Define arguments by objects, rather than just using names.
33
# Those objects can specify the expected type of the argument, which
34
# would help with validation and shell completion.
59
52
if not plugin_cmds.has_key(k_unsquished):
60
53
plugin_cmds[k_unsquished] = cmd
61
mutter('registered plugin command %s', k_unsquished)
63
55
log_error('Two plugins defined the same command: %r' % k)
64
56
log_error('Not loading the one in %r' % sys.modules[cmd.__module__])
476
467
takes_options = ['verbose', 'no-recurse']
478
469
def run(self, file_list, verbose=False, no_recurse=False):
479
from bzrlib.add import smart_add, _PrintAddCallback
480
recurse = not no_recurse
481
smart_add(file_list, verbose, not no_recurse,
482
callback=_PrintAddCallback)
470
from bzrlib.add import smart_add
471
smart_add(file_list, verbose, not no_recurse)
594
582
if os.path.isdir(names_list[-1]):
595
583
# move into existing directory
596
for pair in b.move(rel_names[:-1], rel_names[-1]):
597
print "%s => %s" % pair
584
b.move(rel_names[:-1], rel_names[-1])
599
586
if len(names_list) != 2:
600
587
raise BzrCommandError('to mv multiple files the destination '
601
588
'must be a versioned directory')
602
for pair in b.move(rel_names[0], rel_names[1]):
603
print "%s => %s" % pair
589
b.move(rel_names[0], rel_names[1])
679
664
aliases = ['get', 'clone']
681
666
def run(self, from_location, to_location=None, revision=None):
682
from bzrlib.branch import copy_branch, find_cached_branch
668
from bzrlib.merge import merge
669
from bzrlib.branch import DivergedBranches, \
670
find_cached_branch, Branch
685
671
from shutil import rmtree
672
from meta_store import CachedStore
686
674
cache_root = tempfile.mkdtemp()
678
elif len(revision) > 1:
679
raise BzrCommandError('bzr branch --revision takes exactly 1 revision value')
690
elif len(revision) > 1:
691
raise BzrCommandError(
692
'bzr branch --revision takes exactly 1 revision value')
694
683
br_from = find_cached_branch(from_location, cache_root)
695
684
except OSError, e:
715
copy_branch(br_from, to_location, revision[0])
716
except bzrlib.errors.NoSuchRevision:
718
msg = "The branch %s has no revision %d." % (from_location, revision[0])
719
raise BzrCommandError(msg)
705
br_to = Branch(to_location, init=True)
707
br_to.set_root_id(br_from.get_root_id())
710
if revision[0] is None:
711
revno = br_from.revno()
713
revno, rev_id = br_from.get_revision_info(revision[0])
715
br_to.update_revisions(br_from, stop_revision=revno)
716
except bzrlib.errors.NoSuchRevision:
718
msg = "The branch %s has no revision %d." % (from_location,
720
raise BzrCommandError(msg)
722
merge((to_location, -1), (to_location, 0), this_dir=to_location,
723
check_clean=False, ignore_zero=True)
724
from_location = pull_loc(br_from)
725
br_to.controlfile("x-pull", "wb").write(from_location + "\n")
721
727
rmtree(cache_root)
730
def pull_loc(branch):
731
# TODO: Should perhaps just make attribute be 'base' in
732
# RemoteBranch and Branch?
733
if hasattr(branch, "baseurl"):
734
return branch.baseurl
724
740
class cmd_renames(Command):
725
741
"""Show list of renamed files.
1357
1373
class cmd_upgrade(Command):
1358
1374
"""Upgrade branch storage to current format.
1360
The check command or bzr developers may sometimes advise you to run
1376
This should normally be used only after the check command tells
1363
1379
takes_args = ['dir?']
1387
1403
class cmd_selftest(Command):
1388
1404
"""Run internal test suite"""
1390
takes_options = ['verbose', 'pattern']
1391
def run(self, verbose=False, pattern=".*"):
1406
takes_options = ['verbose']
1407
def run(self, verbose=False):
1392
1408
import bzrlib.ui
1393
1409
from bzrlib.selftest import selftest
1394
1411
# we don't want progress meters from the tests to go to the
1395
1412
# real output; and we don't want log messages cluttering up
1396
1413
# the real logs.
1397
1415
save_ui = bzrlib.ui.ui_factory
1398
1416
bzrlib.trace.info('running tests...')
1417
bzrlib.trace.disable_default_logging()
1400
1419
bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1401
result = selftest(verbose=verbose, pattern=pattern)
1420
result = selftest(verbose=verbose)
1403
1422
bzrlib.trace.info('tests passed')
1405
1424
bzrlib.trace.info('tests failed')
1406
1425
return int(not result)
1427
bzrlib.trace.enable_default_logging()
1408
1428
bzrlib.ui.ui_factory = save_ui
1558
1578
def run(self, revision=None, no_backup=False, file_list=None):
1559
1579
from bzrlib.merge import merge
1560
from bzrlib.branch import Branch
1561
1580
if file_list is not None:
1562
1581
if len(file_list) == 0:
1563
1582
raise BzrCommandError("No files specified")
1652
1669
from inspect import getdoc
1653
1670
from pprint import pprint
1654
1671
for plugin in bzrlib.plugin.all_plugins:
1655
if hasattr(plugin, '__path__'):
1656
print plugin.__path__[0]
1672
print plugin.__path__[0]
1659
1673
d = getdoc(plugin)
1661
1675
print '\t', d.split('\n')[0]