61
62
from bzrlib.commands import Command, display_command
62
from bzrlib.option import Option, RegistryOption
63
from bzrlib.option import ListOption, Option, RegistryOption
63
64
from bzrlib.progress import DummyProgress, ProgressPhase
64
65
from bzrlib.trace import mutter, note, log_error, warning, is_quiet, info
352
356
Option('file-ids-from', type=unicode,
353
357
help='Lookup file ids from here')]
354
358
encoding_type = 'replace'
359
_see_also = ['remove']
356
361
def run(self, file_list, no_recurse=False, dry_run=False, verbose=False,
357
362
file_ids_from=None):
560
562
location can be accessed.
565
_see_also = ['push', 'update']
563
566
takes_options = ['remember', 'overwrite', 'revision', 'verbose',
564
567
Option('directory',
565
568
help='branch to pull into, '
848
852
To retrieve the branch as of a particular revision, supply the --revision
849
853
parameter, as in "branch foo/bar -r 5".
856
_see_also = ['checkout']
851
857
takes_args = ['from_location', 'to_location?']
852
858
takes_options = ['revision']
853
859
aliases = ['get', 'clone']
916
922
parameter, as in "checkout foo/bar -r 5". Note that this will be immediately
917
923
out of date [so you cannot commit] but it may be useful (i.e. to examine old
920
See "help checkouts" for more information on checkouts.
927
_see_also = ['checkouts', 'branch']
922
928
takes_args = ['branch_location?', 'to_location?']
923
929
takes_options = ['revision',
924
930
Option('lightweight',
1066
1076
class cmd_remove(Command):
1067
"""Make a file unversioned.
1077
"""Remove files or directories.
1069
This makes bzr stop tracking changes to a versioned file. It does
1070
not delete the working copy.
1079
This makes bzr stop tracking changes to the specified files and
1080
delete them if they can easily be recovered using revert.
1072
1082
You can specify one or more files, and/or --new. If you specify --new,
1073
1083
only 'added' files will be removed. If you specify both, then new files
1075
1085
also new, they will also be removed.
1077
1087
takes_args = ['file*']
1078
takes_options = ['verbose', Option('new', help='remove newly-added files')]
1088
takes_options = ['verbose',
1089
Option('new', help='remove newly-added files'),
1090
RegistryOption.from_kwargs('file-deletion-strategy',
1091
'The file deletion mode to be used',
1092
title='Deletion Strategy', value_switches=True, enum_switch=False,
1093
safe='Only delete files if they can be'
1094
' safely recovered (default).',
1095
keep="Don't delete any files.",
1096
force='Delete all the specified files, even if they can not be '
1097
'recovered and even if they are non-empty directories.')]
1079
1098
aliases = ['rm']
1080
1099
encoding_type = 'replace'
1082
def run(self, file_list, verbose=False, new=False):
1101
def run(self, file_list, verbose=False, new=False,
1102
file_deletion_strategy='safe'):
1083
1103
tree, file_list = tree_files(file_list)
1085
if file_list is None:
1086
raise errors.BzrCommandError('Specify one or more files to'
1087
' remove, or use --new.')
1105
if file_list is not None:
1106
file_list = [f for f in file_list if f != '']
1108
raise errors.BzrCommandError('Specify one or more files to'
1109
' remove, or use --new.')
1089
1112
added = tree.changes_from(tree.basis_tree(),
1090
1113
specific_files=file_list).added
1091
1114
file_list = sorted([f[0] for f in added], reverse=True)
1092
1115
if len(file_list) == 0:
1093
1116
raise errors.BzrCommandError('No matching files.')
1094
tree.remove(file_list, verbose=verbose, to_file=self.outf)
1117
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1118
keep_files=file_deletion_strategy=='keep',
1119
force=file_deletion_strategy=='force')
1097
1122
class cmd_file_id(Command):
1443
1479
# directories with readdir, rather than stating each one. Same
1444
1480
# level of effort but possibly much less IO. (Or possibly not,
1445
1481
# if the directories are very large...)
1482
_see_also = ['status', 'ls']
1446
1483
takes_options = ['show-ids']
1448
1485
@display_command
2074
2115
Option('strict',
2075
2116
help="refuse to commit if there are unknown "
2076
2117
"files in the working tree."),
2118
ListOption('fixes', type=str,
2119
help="mark a bug as being fixed by this "
2077
2121
Option('local',
2078
2122
help="perform a local only commit in a bound "
2079
2123
"branch. Such commits are not pushed to "
2084
2128
aliases = ['ci', 'checkin']
2130
def _get_bug_fix_properties(self, fixes, branch):
2132
# Configure the properties for bug fixing attributes.
2133
for fixed_bug in fixes:
2134
tokens = fixed_bug.split(':')
2135
if len(tokens) != 2:
2136
raise errors.BzrCommandError(
2137
"Invalid bug %s. Must be in the form of 'tag:id'. "
2138
"Commit refused." % fixed_bug)
2139
tag, bug_id = tokens
2141
bug_url = bugtracker.get_bug_url(tag, branch, bug_id)
2142
except errors.UnknownBugTrackerAbbreviation:
2143
raise errors.BzrCommandError(
2144
'Unrecognized bug %s. Commit refused.' % fixed_bug)
2145
except errors.MalformedBugIdentifier:
2146
raise errors.BzrCommandError(
2147
"Invalid bug identifier for %s. Commit refused."
2149
properties.append('%s fixed' % bug_url)
2150
return '\n'.join(properties)
2086
2152
def run(self, message=None, file=None, verbose=True, selected_list=None,
2087
unchanged=False, strict=False, local=False):
2153
unchanged=False, strict=False, local=False, fixes=None):
2088
2154
from bzrlib.commit import (NullCommitReporter, ReportCommitToLog)
2089
2155
from bzrlib.errors import (PointlessCommit, ConflictsInTree,
2090
2156
StrictCommitFailed)
2134
2207
tree.commit(message_callback=get_message,
2135
2208
specific_files=selected_list,
2136
2209
allow_pointless=unchanged, strict=strict, local=local,
2210
reporter=reporter, revprops=properties)
2138
2211
except PointlessCommit:
2139
2212
# FIXME: This should really happen before the file is read in;
2140
2213
# perhaps prepare the commit; get the message; then actually commit
2248
2325
If unset, the tree root directory name is used as the nickname
2249
2326
To print the current nickname, execute with no argument.
2329
_see_also = ['info']
2251
2330
takes_args = ['nickname?']
2252
2331
def run(self, nickname=None):
2253
2332
branch = Branch.open_containing(u'.')[0]
2264
2343
class cmd_selftest(Command):
2265
2344
"""Run internal test suite.
2267
This creates temporary test directories in the working directory, but not
2346
This creates temporary test directories in the working directory, but no
2268
2347
existing data is affected. These directories are deleted if the tests
2269
2348
pass, or left behind to help in debugging if they fail and --keep-output
2277
2356
all other tests are run. This is useful if you have been working in a
2278
2357
particular area, but want to make sure nothing else was broken.
2359
If --exclude is given, tests that match that regular expression are
2360
excluded, regardless of whether they match --first or not.
2362
To help catch accidential dependencies between tests, the --randomize
2363
option is useful. In most cases, the argument used is the word 'now'.
2364
Note that the seed used for the random number generator is displayed
2365
when this option is used. The seed can be explicitly passed as the
2366
argument to this option if required. This enables reproduction of the
2367
actual ordering used if and when an order sensitive problem is encountered.
2369
If --list-only is given, the tests that would be run are listed. This is
2370
useful when combined with --first, --exclude and/or --randomize to
2371
understand their impact. The test harness reports "Listed nn tests in ..."
2372
instead of "Ran nn tests in ..." when list mode is enabled.
2280
2374
If the global option '--no-plugins' is given, plugins are not loaded
2281
2375
before running the selftests. This has two effects: features provided or
2282
2376
modified by plugins will not be tested, and tests provided by plugins will
2295
2389
of running tests to create such subdirectories. This is default behavior
2296
2390
on Windows because of path length limitation.
2298
# TODO: --list should give a list of all available tests
2300
2392
# NB: this is used from the class without creating an instance, which is
2301
2393
# why it does not have a self parameter.
2302
2394
def get_transport_type(typestring):
2318
2410
takes_args = ['testspecs*']
2319
2411
takes_options = ['verbose',
2320
Option('one', help='stop when one test fails'),
2413
help='stop when one test fails',
2321
2416
Option('keep-output',
2322
2417
help='keep output directories when tests fail'),
2323
2418
Option('transport',
2335
2430
help='clean temporary tests directories'
2336
2431
' without running tests'),
2337
2432
Option('first',
2338
help='run all tests, but run specified tests first'
2433
help='run all tests, but run specified tests first',
2340
2436
Option('numbered-dirs',
2341
2437
help='use numbered dirs for TestCaseInTempDir'),
2439
help='list the tests instead of running them'),
2440
Option('randomize', type=str, argname="SEED",
2441
help='randomize the order of tests using the given'
2442
' seed or "now" for the current time'),
2443
Option('exclude', type=str, argname="PATTERN",
2445
help='exclude tests that match this regular'
2343
2448
encoding_type = 'replace'
2345
2450
def run(self, testspecs_list=None, verbose=None, one=False,
2346
2451
keep_output=False, transport=None, benchmark=None,
2347
2452
lsprof_timed=None, cache_dir=None, clean_output=False,
2348
first=False, numbered_dirs=None):
2453
first=False, numbered_dirs=None, list_only=False,
2454
randomize=None, exclude=None):
2349
2455
import bzrlib.ui
2350
2456
from bzrlib.tests import selftest
2351
2457
import bzrlib.benchmarks as benchmarks
2488
2597
merge refuses to run if there are any uncommitted changes, unless
2489
2598
--force is given.
2601
_see_also = ['update', 'remerge']
2491
2602
takes_args = ['branch?']
2492
2603
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2493
2604
Option('show-base', help="Show base revision text in "
2793
2906
class cmd_help(Command):
2794
2907
"""Show help on a command or other topic.
2796
For a list of all available commands, say 'bzr help commands'.
2910
_see_also = ['topics']
2798
2911
takes_options = [Option('long', 'show help on all commands')]
2799
2912
takes_args = ['topic?']
2800
2913
aliases = ['?', '--help', '-?', '-h']
2944
3059
class cmd_testament(Command):
2945
3060
"""Show testament (signing-form) of a revision."""
2946
takes_options = ['revision',
3061
takes_options = ['revision',
2947
3062
Option('long', help='Produce long-format testament'),
2948
3063
Option('strict', help='Produce a strict-format'
3060
3175
Once converted into a checkout, commits must succeed on the master branch
3061
3176
before they will be applied to the local branch.
3063
See "help checkouts" for more information on checkouts.
3179
_see_also = ['checkouts', 'unbind']
3066
3180
takes_args = ['location?']
3067
3181
takes_options = []
3119
3232
# unreferenced information in 'branch-as-repository' branches.
3120
3233
# TODO: jam 20060108 Add the ability for uncommit to remove unreferenced
3121
3234
# information in shared branches as well.
3235
_see_also = ['commit']
3122
3236
takes_options = ['verbose', 'revision',
3123
3237
Option('dry-run', help='Don\'t actually make changes'),
3124
3238
Option('force', help='Say yes to all questions.')]
3250
3364
def run(self, port=None, inet=False, directory=None, allow_writes=False):
3251
from bzrlib.smart import server, medium
3365
from bzrlib.smart import medium, server
3252
3366
from bzrlib.transport import get_transport
3253
from bzrlib.transport.remote import BZR_DEFAULT_PORT
3367
from bzrlib.transport.chroot import ChrootServer
3368
from bzrlib.transport.remote import BZR_DEFAULT_PORT, BZR_DEFAULT_INTERFACE
3254
3369
if directory is None:
3255
3370
directory = os.getcwd()
3256
3371
url = urlutils.local_path_to_url(directory)
3257
3372
if not allow_writes:
3258
3373
url = 'readonly+' + url
3259
t = get_transport(url)
3374
chroot_server = ChrootServer(get_transport(url))
3375
chroot_server.setUp()
3376
t = get_transport(chroot_server.get_url())
3261
3378
smart_server = medium.SmartServerPipeStreamMedium(
3262
3379
sys.stdin, sys.stdout, t)
3381
host = BZR_DEFAULT_INTERFACE
3264
3382
if port is None:
3265
3383
port = BZR_DEFAULT_PORT
3268
3385
if ':' in port:
3269
3386
host, port = port.split(':')
3272
3387
port = int(port)
3273
3388
smart_server = server.SmartTCPServer(t, host=host, port=port)
3274
3389
print 'listening on port: ', smart_server.port
3275
3390
sys.stdout.flush()
3276
smart_server.serve()
3391
# for the duration of this server, no UI output is permitted.
3392
# note that this may cause problems with blackbox tests. This should
3393
# be changed with care though, as we dont want to use bandwidth sending
3394
# progress over stderr to smart server clients!
3395
old_factory = ui.ui_factory
3397
ui.ui_factory = ui.SilentUIFactory()
3398
smart_server.serve()
3400
ui.ui_factory = old_factory
3278
3403
class cmd_join(Command):
3279
3404
"""Combine a subtree into its containing tree.