53
53
from bzrlib.commands import Command, display_command
54
from bzrlib.option import Option
54
from bzrlib.option import Option, RegistryOption
55
55
from bzrlib.progress import DummyProgress, ProgressPhase
56
56
from bzrlib.trace import mutter, note, log_error, warning, is_quiet, info
451
451
If the last argument is a versioned directory, all the other names
452
452
are moved into it. Otherwise, there must be exactly two arguments
453
and the file is changed to a new name, which must not already exist.
453
and the file is changed to a new name.
455
If OLDNAME does not exist on the filesystem but is versioned and
456
NEWNAME does exist on the filesystem but is not versioned, mv
457
assumes that the file has been manually moved and only updates
458
its internal inventory to reflect that change.
459
The same is valid when moving many SOURCE files to a DESTINATION.
455
461
Files cannot be moved between branches.
458
464
takes_args = ['names*']
465
takes_options = [Option("after", help="move only the bzr identifier"
466
" of the file (file has already been moved). Use this flag if"
467
" bzr is not able to detect this itself.")]
459
468
aliases = ['move', 'rename']
460
469
encoding_type = 'replace'
462
def run(self, names_list):
471
def run(self, names_list, after=False):
463
472
if names_list is None:
470
479
if os.path.isdir(names_list[-1]):
471
480
# move into existing directory
472
for pair in tree.move(rel_names[:-1], rel_names[-1]):
481
for pair in tree.move(rel_names[:-1], rel_names[-1], after=after):
473
482
self.outf.write("%s => %s\n" % pair)
475
484
if len(names_list) != 2:
476
raise errors.BzrCommandError('to mv multiple files the destination '
477
'must be a versioned directory')
478
tree.rename_one(rel_names[0], rel_names[1])
485
raise errors.BzrCommandError('to mv multiple files the'
486
' destination must be a versioned'
488
tree.rename_one(rel_names[0], rel_names[1], after=after)
479
489
self.outf.write("%s => %s\n" % (rel_names[0], rel_names[1]))
1080
1090
takes_args = ['location?']
1081
1091
takes_options = [
1092
RegistryOption('format',
1083
1093
help='Specify a format for this branch. Current'
1084
1094
' formats are: default, knit, metaweave and'
1085
1095
' weave. Default is knit; metaweave and'
1086
1096
' weave are deprecated',
1087
type=get_format_type),
1097
registry=bzrdir.format_registry,
1098
converter=get_format_type,
1099
value_switches=True),
1089
1101
def run(self, location=None, format=None):
1090
1102
if format is None:
1137
1149
(add files here)
1139
1151
takes_args = ["location"]
1140
takes_options = [Option('format',
1152
takes_options = [RegistryOption('format',
1141
1153
help='Specify a format for this repository.'
1142
1154
' Current formats are: default, knit,'
1143
1155
' metaweave and weave. Default is knit;'
1144
1156
' metaweave and weave are deprecated',
1145
type=get_format_type),
1157
registry=bzrdir.format_registry,
1158
converter=get_format_type,
1159
value_switches=True),
1146
1160
Option('trees',
1147
1161
help='Allows branches in repository to have'
1148
1162
' a working tree')]
1548
tree, relpath = WorkingTree.open_containing(fs_path)
1562
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
1553
1568
if revision is not None:
1554
tree = tree.branch.repository.revision_tree(
1555
revision[0].in_history(tree.branch).rev_id)
1569
tree = branch.repository.revision_tree(
1570
revision[0].in_history(branch).rev_id)
1572
tree = branch.basis_tree()
1557
1574
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
1558
1575
if fp.startswith(relpath):
1965
1982
takes_args = ['url?']
1966
1983
takes_options = [
1968
help='Upgrade to a specific format. Current formats'
1969
' are: default, knit, metaweave and weave.'
1970
' Default is knit; metaweave and weave are'
1972
type=get_format_type),
1984
RegistryOption('format',
1985
help='Upgrade to a specific format. Current formats'
1986
' are: default, knit, metaweave and weave.'
1987
' Default is knit; metaweave and weave are'
1989
registry=bzrdir.format_registry,
1990
converter=get_format_type,
1991
value_switches=True),
2047
2066
class cmd_selftest(Command):
2048
2067
"""Run internal test suite.
2050
This creates temporary test directories in the working directory,
2051
but not existing data is affected. These directories are deleted
2052
if the tests pass, or left behind to help in debugging if they
2053
fail and --keep-output is specified.
2069
This creates temporary test directories in the working directory, but not
2070
existing data is affected. These directories are deleted if the tests
2071
pass, or left behind to help in debugging if they fail and --keep-output
2055
If arguments are given, they are regular expressions that say
2056
which tests should run.
2074
If arguments are given, they are regular expressions that say which tests
2075
should run. Tests matching any expression are run, and other tests are
2078
Alternatively if --first is given, matching tests are run first and then
2079
all other tests are run. This is useful if you have been working in a
2080
particular area, but want to make sure nothing else was broken.
2058
2082
If the global option '--no-plugins' is given, plugins are not loaded
2059
2083
before running the selftests. This has two effects: features provided or
2060
2084
modified by plugins will not be tested, and tests provided by plugins will
2064
2088
bzr selftest ignore
2089
run only tests relating to 'ignore'
2065
2090
bzr --no-plugins selftest -v
2091
disable plugins and list tests as they're run
2067
2093
# TODO: --list should give a list of all available tests
2103
2129
Option('clean-output',
2104
2130
help='clean temporary tests directories'
2105
2131
' without running tests'),
2133
help='run all tests, but run specified tests first',
2107
2136
encoding_type = 'replace'
2109
2138
def run(self, testspecs_list=None, verbose=None, one=False,
2110
2139
keep_output=False, transport=None, benchmark=None,
2111
lsprof_timed=None, cache_dir=None, clean_output=False):
2140
lsprof_timed=None, cache_dir=None, clean_output=False,
2112
2142
import bzrlib.ui
2113
2143
from bzrlib.tests import selftest
2114
2144
import bzrlib.benchmarks as benchmarks
2147
2177
transport=transport,
2148
2178
test_suite_factory=test_suite_factory,
2149
2179
lsprof_timed=lsprof_timed,
2150
bench_history=benchfile)
2180
bench_history=benchfile,
2181
matching_tests_first=first,
2152
2184
if benchfile is not None:
2153
2185
benchfile.close()
2599
2631
other_branch = parent
2600
2632
if other_branch is None:
2601
2633
raise errors.BzrCommandError("No peer location known or specified.")
2602
print "Using last location: " + local_branch.get_parent()
2634
display_url = urlutils.unescape_for_display(parent,
2636
print "Using last location: " + display_url
2603
2638
remote_branch = Branch.open(other_branch)
2604
2639
if remote_branch.base == local_branch.base:
2605
2640
remote_branch = local_branch