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.
469
476
takes_options = ['verbose', 'no-recurse']
471
478
def run(self, file_list, verbose=False, no_recurse=False):
472
from bzrlib.add import smart_add
479
from bzrlib.add import smart_add, _PrintAddCallback
474
480
recurse = not no_recurse
475
for path, kind, file_id in smart_add(file_list, verbose, recurse):
481
smart_add(file_list, verbose, not no_recurse,
482
callback=_PrintAddCallback)
672
679
aliases = ['get', 'clone']
674
681
def run(self, from_location, to_location=None, revision=None):
682
from bzrlib.branch import copy_branch, find_cached_branch
676
from bzrlib.merge import merge
677
from bzrlib.branch import DivergedBranches, \
678
find_cached_branch, Branch
679
685
from shutil import rmtree
680
from meta_store import CachedStore
682
686
cache_root = tempfile.mkdtemp()
686
elif len(revision) > 1:
687
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')
691
694
br_from = find_cached_branch(from_location, cache_root)
692
695
except OSError, e:
713
br_to = Branch(to_location, init=True)
715
br_to.set_root_id(br_from.get_root_id())
718
if revision[0] is None:
719
revno = br_from.revno()
721
revno, rev_id = br_from.get_revision_info(revision[0])
723
br_to.update_revisions(br_from, stop_revision=revno)
724
except bzrlib.errors.NoSuchRevision:
726
msg = "The branch %s has no revision %d." % (from_location,
728
raise BzrCommandError(msg)
730
merge((to_location, -1), (to_location, 0), this_dir=to_location,
731
check_clean=False, ignore_zero=True)
732
from_location = pull_loc(br_from)
733
br_to.controlfile("x-pull", "wb").write(from_location + "\n")
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)
735
721
rmtree(cache_root)
738
def pull_loc(branch):
739
# TODO: Should perhaps just make attribute be 'base' in
740
# RemoteBranch and Branch?
741
if hasattr(branch, "baseurl"):
742
return branch.baseurl
748
724
class cmd_renames(Command):
749
725
"""Show list of renamed files.
1411
1387
class cmd_selftest(Command):
1412
1388
"""Run internal test suite"""
1414
takes_options = ['verbose']
1415
def run(self, verbose=False):
1390
takes_options = ['verbose', 'pattern']
1391
def run(self, verbose=False, pattern=".*"):
1416
1392
import bzrlib.ui
1417
1393
from bzrlib.selftest import selftest
1419
1394
# we don't want progress meters from the tests to go to the
1420
1395
# real output; and we don't want log messages cluttering up
1421
1396
# the real logs.
1423
1397
save_ui = bzrlib.ui.ui_factory
1424
1398
bzrlib.trace.info('running tests...')
1426
1400
bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1427
result = selftest(verbose=verbose)
1401
result = selftest(verbose=verbose, pattern=pattern)
1429
1403
bzrlib.trace.info('tests passed')
1584
1558
def run(self, revision=None, no_backup=False, file_list=None):
1585
1559
from bzrlib.merge import merge
1560
from bzrlib.branch import Branch
1586
1561
if file_list is not None:
1587
1562
if len(file_list) == 0:
1588
1563
raise BzrCommandError("No files specified")