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
189
190
aliases = ['st', 'stat']
191
192
encoding_type = 'replace'
193
_see_also = ['diff', 'revert']
194
196
def run(self, show_ids=False, file_list=None, revision=None, short=False,
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, '
666
669
location can be accessed.
672
_see_also = ['pull', 'update']
669
673
takes_options = ['remember', 'overwrite', 'verbose',
670
674
Option('create-prefix',
671
675
help='Create the path leading up to the branch '
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',
1180
1195
class cmd_ancestry(Command):
1181
1196
"""List all revisions merged into this branch."""
1198
_see_also = ['log', 'revision-history']
1182
1199
takes_args = ['location?']
1293
1312
(add files here)
1315
_see_also = ['init', 'branch', 'checkout']
1296
1316
takes_args = ["location"]
1297
1317
takes_options = [RegistryOption('format',
1298
1318
help='Specify a format for this repository. See'
1359
1379
# TODO: This probably handles non-Unix newlines poorly.
1381
_see_also = ['status']
1361
1382
takes_args = ['file*']
1362
1383
takes_options = ['revision', 'diff-options',
1363
1384
Option('prefix', type=str,
1443
1464
# directories with readdir, rather than stating each one. Same
1444
1465
# level of effort but possibly much less IO. (Or possibly not,
1445
1466
# if the directories are very large...)
1467
_see_also = ['status', 'ls']
1446
1468
takes_options = ['show-ids']
1448
1470
@display_command
1687
1708
"""List files in a tree.
1711
_see_also = ['status', 'cat']
1690
1712
takes_args = ['path?']
1691
1713
# TODO: Take a revision or remote path and list that tree instead.
1692
1714
takes_options = ['verbose', 'revision',
1821
1842
bzr ignore 'lib/**/*.o'
1822
1843
bzr ignore 'RE:lib/.*\.o'
1846
_see_also = ['status', 'ignored']
1824
1847
takes_args = ['name_pattern*']
1825
1848
takes_options = [
1826
1849
Option('old-default-rules',
2064
2089
# XXX: verbose currently does nothing
2091
_see_also = ['bugs', 'uncommit']
2066
2092
takes_args = ['selected*']
2067
2093
takes_options = ['message', 'verbose',
2068
2094
Option('unchanged',
2074
2100
Option('strict',
2075
2101
help="refuse to commit if there are unknown "
2076
2102
"files in the working tree."),
2103
ListOption('fixes', type=str,
2104
help="mark a bug as being fixed by this "
2077
2106
Option('local',
2078
2107
help="perform a local only commit in a bound "
2079
2108
"branch. Such commits are not pushed to "
2084
2113
aliases = ['ci', 'checkin']
2115
def _get_bug_fix_properties(self, fixes, branch):
2117
# Configure the properties for bug fixing attributes.
2118
for fixed_bug in fixes:
2119
tokens = fixed_bug.split(':')
2120
if len(tokens) != 2:
2121
raise errors.BzrCommandError(
2122
"Invalid bug %s. Must be in the form of 'tag:id'. "
2123
"Commit refused." % fixed_bug)
2124
tag, bug_id = tokens
2126
bug_url = bugtracker.get_bug_url(tag, branch, bug_id)
2127
except errors.UnknownBugTrackerAbbreviation:
2128
raise errors.BzrCommandError(
2129
'Unrecognized bug %s. Commit refused.' % fixed_bug)
2130
except errors.MalformedBugIdentifier:
2131
raise errors.BzrCommandError(
2132
"Invalid bug identifier for %s. Commit refused."
2134
properties.append('%s fixed' % bug_url)
2135
return '\n'.join(properties)
2086
2137
def run(self, message=None, file=None, verbose=True, selected_list=None,
2087
unchanged=False, strict=False, local=False):
2138
unchanged=False, strict=False, local=False, fixes=None):
2088
2139
from bzrlib.commit import (NullCommitReporter, ReportCommitToLog)
2089
2140
from bzrlib.errors import (PointlessCommit, ConflictsInTree,
2090
2141
StrictCommitFailed)
2097
2148
# TODO: do more checks that the commit will succeed before
2098
2149
# spending the user's valuable time typing a commit message.
2099
2153
tree, selected_list = tree_files(selected_list)
2100
2154
if selected_list == ['']:
2101
2155
# workaround - commit of root of tree should be exactly the same
2103
2157
# selected-file merge commit is not done yet
2104
2158
selected_list = []
2160
properties['bugs'] = self._get_bug_fix_properties(fixes, tree.branch)
2106
2162
if local and not tree.branch.get_bound_location():
2107
2163
raise errors.LocalRequiresBoundBranch()
2134
2190
tree.commit(message_callback=get_message,
2135
2191
specific_files=selected_list,
2136
2192
allow_pointless=unchanged, strict=strict, local=local,
2193
reporter=reporter, revprops=properties)
2138
2194
except PointlessCommit:
2139
2195
# FIXME: This should really happen before the file is read in;
2140
2196
# perhaps prepare the commit; get the message; then actually commit
2248
2308
If unset, the tree root directory name is used as the nickname
2249
2309
To print the current nickname, execute with no argument.
2312
_see_also = ['info']
2251
2313
takes_args = ['nickname?']
2252
2314
def run(self, nickname=None):
2253
2315
branch = Branch.open_containing(u'.')[0]
2264
2326
class cmd_selftest(Command):
2265
2327
"""Run internal test suite.
2267
This creates temporary test directories in the working directory, but not
2329
This creates temporary test directories in the working directory, but no
2268
2330
existing data is affected. These directories are deleted if the tests
2269
2331
pass, or left behind to help in debugging if they fail and --keep-output
2277
2339
all other tests are run. This is useful if you have been working in a
2278
2340
particular area, but want to make sure nothing else was broken.
2342
If --exclude is given, tests that match that regular expression are
2343
excluded, regardless of whether they match --first or not.
2345
To help catch accidential dependencies between tests, the --randomize
2346
option is useful. In most cases, the argument used is the word 'now'.
2347
Note that the seed used for the random number generator is displayed
2348
when this option is used. The seed can be explicitly passed as the
2349
argument to this option if required. This enables reproduction of the
2350
actual ordering used if and when an order sensitive problem is encountered.
2352
If --list-only is given, the tests that would be run are listed. This is
2353
useful when combined with --first, --exclude and/or --randomize to
2354
understand their impact. The test harness reports "Listed nn tests in ..."
2355
instead of "Ran nn tests in ..." when list mode is enabled.
2280
2357
If the global option '--no-plugins' is given, plugins are not loaded
2281
2358
before running the selftests. This has two effects: features provided or
2282
2359
modified by plugins will not be tested, and tests provided by plugins will
2295
2372
of running tests to create such subdirectories. This is default behavior
2296
2373
on Windows because of path length limitation.
2298
# TODO: --list should give a list of all available tests
2300
2375
# NB: this is used from the class without creating an instance, which is
2301
2376
# why it does not have a self parameter.
2302
2377
def get_transport_type(typestring):
2318
2393
takes_args = ['testspecs*']
2319
2394
takes_options = ['verbose',
2320
Option('one', help='stop when one test fails'),
2396
help='stop when one test fails',
2321
2399
Option('keep-output',
2322
2400
help='keep output directories when tests fail'),
2323
2401
Option('transport',
2335
2413
help='clean temporary tests directories'
2336
2414
' without running tests'),
2337
2415
Option('first',
2338
help='run all tests, but run specified tests first'
2416
help='run all tests, but run specified tests first',
2340
2419
Option('numbered-dirs',
2341
2420
help='use numbered dirs for TestCaseInTempDir'),
2422
help='list the tests instead of running them'),
2423
Option('randomize', type=str, argname="SEED",
2424
help='randomize the order of tests using the given'
2425
' seed or "now" for the current time'),
2426
Option('exclude', type=str, argname="PATTERN",
2428
help='exclude tests that match this regular'
2343
2431
encoding_type = 'replace'
2345
2433
def run(self, testspecs_list=None, verbose=None, one=False,
2346
2434
keep_output=False, transport=None, benchmark=None,
2347
2435
lsprof_timed=None, cache_dir=None, clean_output=False,
2348
first=False, numbered_dirs=None):
2436
first=False, numbered_dirs=None, list_only=False,
2437
randomize=None, exclude=None):
2349
2438
import bzrlib.ui
2350
2439
from bzrlib.tests import selftest
2351
2440
import bzrlib.benchmarks as benchmarks
2488
2580
merge refuses to run if there are any uncommitted changes, unless
2489
2581
--force is given.
2584
_see_also = ['update', 'remerge']
2491
2585
takes_args = ['branch?']
2492
2586
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2493
2587
Option('show-base', help="Show base revision text in "
2753
2847
name. If you name a directory, all the contents of that directory will be
2851
_see_also = ['cat', 'export']
2756
2852
takes_options = ['revision', 'no-backup']
2757
2853
takes_args = ['file*']
2793
2889
class cmd_help(Command):
2794
2890
"""Show help on a command or other topic.
2796
For a list of all available commands, say 'bzr help commands'.
2893
_see_also = ['topics']
2798
2894
takes_options = [Option('long', 'show help on all commands')]
2799
2895
takes_args = ['topic?']
2800
2896
aliases = ['?', '--help', '-?', '-h']
2842
2938
OTHER_BRANCH may be local or remote.
2941
_see_also = ['merge', 'pull']
2844
2942
takes_args = ['other_branch?']
2845
2943
takes_options = [Option('reverse', 'Reverse the order of revisions'),
2846
2944
Option('mine-only',
2944
3042
class cmd_testament(Command):
2945
3043
"""Show testament (signing-form) of a revision."""
2946
takes_options = ['revision',
3044
takes_options = ['revision',
2947
3045
Option('long', help='Produce long-format testament'),
2948
3046
Option('strict', help='Produce a strict-format'
3060
3158
Once converted into a checkout, commits must succeed on the master branch
3061
3159
before they will be applied to the local branch.
3063
See "help checkouts" for more information on checkouts.
3162
_see_also = ['checkouts', 'unbind']
3066
3163
takes_args = ['location?']
3067
3164
takes_options = []
3092
3189
After unbinding, the local branch is considered independent and subsequent
3093
3190
commits will be local only.
3095
See "help checkouts" for more information on checkouts.
3193
_see_also = ['checkouts', 'bind']
3098
3194
takes_args = []
3099
3195
takes_options = []
3119
3215
# unreferenced information in 'branch-as-repository' branches.
3120
3216
# TODO: jam 20060108 Add the ability for uncommit to remove unreferenced
3121
3217
# information in shared branches as well.
3218
_see_also = ['commit']
3122
3219
takes_options = ['verbose', 'revision',
3123
3220
Option('dry-run', help='Don\'t actually make changes'),
3124
3221
Option('force', help='Say yes to all questions.')]
3250
3347
def run(self, port=None, inet=False, directory=None, allow_writes=False):
3251
from bzrlib.smart import server, medium
3348
from bzrlib.smart import medium, server
3252
3349
from bzrlib.transport import get_transport
3253
from bzrlib.transport.remote import BZR_DEFAULT_PORT
3350
from bzrlib.transport.chroot import ChrootServer
3351
from bzrlib.transport.remote import BZR_DEFAULT_PORT, BZR_DEFAULT_INTERFACE
3254
3352
if directory is None:
3255
3353
directory = os.getcwd()
3256
3354
url = urlutils.local_path_to_url(directory)
3257
3355
if not allow_writes:
3258
3356
url = 'readonly+' + url
3259
t = get_transport(url)
3357
chroot_server = ChrootServer(get_transport(url))
3358
chroot_server.setUp()
3359
t = get_transport(chroot_server.get_url())
3261
3361
smart_server = medium.SmartServerPipeStreamMedium(
3262
3362
sys.stdin, sys.stdout, t)
3364
host = BZR_DEFAULT_INTERFACE
3264
3365
if port is None:
3265
3366
port = BZR_DEFAULT_PORT
3268
3368
if ':' in port:
3269
3369
host, port = port.split(':')
3272
3370
port = int(port)
3273
3371
smart_server = server.SmartTCPServer(t, host=host, port=port)
3274
3372
print 'listening on port: ', smart_server.port
3275
3373
sys.stdout.flush()
3276
smart_server.serve()
3374
# for the duration of this server, no UI output is permitted.
3375
# note that this may cause problems with blackbox tests. This should
3376
# be changed with care though, as we dont want to use bandwidth sending
3377
# progress over stderr to smart server clients!
3378
old_factory = ui.ui_factory
3380
ui.ui_factory = ui.SilentUIFactory()
3381
smart_server.serve()
3383
ui.ui_factory = old_factory
3278
3386
class cmd_join(Command):
3279
3387
"""Combine a subtree into its containing tree.
3337
3446
subdirectory will be converted into an independent tree, with its own
3338
3447
branch. Commits in the top-level tree will not apply to the new subtree.
3339
3448
If you want that behavior, do "bzr join --reference TREE".
3341
To undo this operation, do "bzr join TREE".
3451
_see_also = ['join']
3344
3452
takes_args = ['tree']