178
183
# TODO: --no-recurse, --recurse options
180
185
takes_args = ['file*']
181
takes_options = ['show-ids', 'revision', 'short']
186
takes_options = ['show-ids', 'revision',
187
Option('short', help='Give short SVN-style status lines'),
188
Option('versioned', help='Only show versioned files')]
182
189
aliases = ['st', 'stat']
184
191
encoding_type = 'replace'
192
_see_also = ['diff', 'revert']
187
def run(self, show_ids=False, file_list=None, revision=None, short=False):
195
def run(self, show_ids=False, file_list=None, revision=None, short=False,
188
197
from bzrlib.status import show_tree_status
190
199
tree, file_list = tree_files(file_list)
192
201
show_tree_status(tree, show_ids=show_ids,
193
202
specific_files=file_list, revision=revision,
203
to_file=self.outf, short=short, versioned=versioned)
198
206
class cmd_cat_revision(Command):
332
345
--file-ids-from will try to use the file ids from the supplied path.
333
346
It looks up ids trying to find a matching parent directory with the
334
same filename, and then by pure path.
347
same filename, and then by pure path. This option is rarely needed
348
but can be useful when adding the same logical file into two
349
branches that will be merged later (without showing the two different
350
adds as a conflict). It is also useful when merging another project
351
into a subdirectory of this one.
336
353
takes_args = ['file*']
337
354
takes_options = ['no-recurse', 'dry-run', 'verbose',
338
355
Option('file-ids-from', type=unicode,
339
356
help='Lookup file ids from here')]
340
357
encoding_type = 'replace'
358
_see_also = ['remove']
342
360
def run(self, file_list, no_recurse=False, dry_run=False, verbose=False,
343
361
file_ids_from=None):
598
620
if branch_to.get_parent() is None or remember:
599
621
branch_to.set_parent(branch_from.base)
603
if reader is not None:
604
rev_id = reader.target
605
elif len(revision) == 1:
606
rev_id = revision[0].in_history(branch_from).rev_id
608
raise errors.BzrCommandError('bzr pull --revision takes one value.')
623
if revision is not None:
624
if len(revision) == 1:
625
revision_id = revision[0].in_history(branch_from).rev_id
627
raise errors.BzrCommandError(
628
'bzr pull --revision takes one value.')
610
630
old_rh = branch_to.revision_history()
611
631
if tree_to is not None:
612
result = tree_to.pull(branch_from, overwrite, rev_id,
613
delta.ChangeReporter(unversioned_filter=tree_to.is_ignored))
632
result = tree_to.pull(branch_from, overwrite, revision_id,
633
delta._ChangeReporter(unversioned_filter=tree_to.is_ignored))
615
result = branch_to.pull(branch_from, overwrite, rev_id)
635
result = branch_to.pull(branch_from, overwrite, revision_id)
617
637
result.report(self.outf)
619
639
from bzrlib.log import show_changed_revisions
620
640
new_rh = branch_to.revision_history()
621
show_changed_revisions(branch_to, old_rh, new_rh, to_file=self.outf)
641
show_changed_revisions(branch_to, old_rh, new_rh,
624
645
class cmd_push(Command):
829
851
To retrieve the branch as of a particular revision, supply the --revision
830
852
parameter, as in "branch foo/bar -r 5".
832
--basis is to speed up branching from remote branches. When specified, it
833
copies all the file-contents, inventory and revision data from the basis
834
branch before copying anything from the remote branch.
855
_see_also = ['checkout']
836
856
takes_args = ['from_location', 'to_location?']
837
takes_options = ['revision', 'basis']
857
takes_options = ['revision']
838
858
aliases = ['get', 'clone']
840
def run(self, from_location, to_location=None, revision=None, basis=None):
860
def run(self, from_location, to_location=None, revision=None):
841
861
from bzrlib.tag import _merge_tags_if_possible
842
862
if revision is None:
843
863
revision = [None]
878
894
# preserve whatever source format we have.
879
dir = br_from.bzrdir.sprout(to_transport.base,
880
revision_id, basis_dir)
895
dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
881
896
branch = dir.open_branch()
882
897
except errors.NoSuchRevision:
883
898
to_transport.delete_tree('.')
884
899
msg = "The branch %s has no revision %s." % (from_location, revision[0])
885
900
raise errors.BzrCommandError(msg)
886
except errors.UnlistableBranch:
887
osutils.rmtree(to_location)
888
msg = "The branch %s cannot be used as a --basis" % (basis,)
889
raise errors.BzrCommandError(msg)
891
902
branch.control_files.put_utf8('branch-name', name)
892
903
_merge_tags_if_possible(br_from, branch)
910
921
parameter, as in "checkout foo/bar -r 5". Note that this will be immediately
911
922
out of date [so you cannot commit] but it may be useful (i.e. to examine old
914
--basis is to speed up checking out from remote branches. When specified, it
915
uses the inventory and file contents from the basis branch in preference to the
916
branch being checked out.
918
See "help checkouts" for more information on checkouts.
926
_see_also = ['checkouts', 'branch']
920
927
takes_args = ['branch_location?', 'to_location?']
921
takes_options = ['revision', # , 'basis']
928
takes_options = ['revision',
922
929
Option('lightweight',
923
930
help="perform a lightweight checkout. Lightweight "
924
931
"checkouts depend on access to the branch for "
1281
1301
"""Create a shared repository to hold branches.
1283
1303
New branches created under the repository directory will store their revisions
1284
in the repository, not in the branch directory, if the branch format supports
1304
in the repository, not in the branch directory.
1307
bzr init-repo --no-trees repo
1289
1308
bzr init repo/trunk
1290
1309
bzr checkout --lightweight repo/trunk trunk-checkout
1291
1310
cd trunk-checkout
1292
1311
(add files here)
1314
_see_also = ['init', 'branch', 'checkout']
1294
1315
takes_args = ["location"]
1295
1316
takes_options = [RegistryOption('format',
1296
1317
help='Specify a format for this repository. See'
1298
1319
registry=bzrdir.format_registry,
1299
1320
converter=bzrdir.format_registry.make_bzrdir,
1300
1321
value_switches=True, title='Repository format'),
1302
help='Allows branches in repository to have'
1323
help='Branches in the repository will default to'
1324
' not having a working tree'),
1304
1326
aliases = ["init-repo"]
1305
def run(self, location, format=None, trees=False):
1328
def run(self, location, format=None, no_trees=False):
1306
1329
if format is None:
1307
1330
format = bzrdir.format_registry.make_bzrdir('default')
1916
1944
given, try to find the format with the extension. If no extension
1917
1945
is found exports to a directory (equivalent to --format=dir).
1919
Root may be the top directory for tar, tgz and tbz2 formats. If none
1920
is given, the top directory will be the root name of the file.
1922
If branch is omitted then the branch containing the CWD will be used.
1924
Note: export of tree with non-ascii filenames to zip is not supported.
1947
If root is supplied, it will be used as the root directory inside
1948
container formats (tar, zip, etc). If it is not supplied it will default
1949
to the exported filename. The root option has no effect for 'dir' format.
1951
If branch is omitted then the branch containing the current working
1952
directory will be used.
1954
Note: Export of tree with non-ASCII filenames to zip is not supported.
1926
1956
Supported formats Autodetected by extension
1927
1957
----------------- -------------------------
2023
2060
within it is committed.
2025
2062
A selected-file commit may fail in some cases where the committed
2026
tree would be invalid, such as trying to commit a file in a
2027
newly-added directory that is not itself committed.
2063
tree would be invalid. Consider::
2068
bzr commit foo -m "committing foo"
2069
bzr mv foo/bar foo/baz
2072
bzr commit foo/bar -m "committing bar but not baz"
2074
In the example above, the last commit will fail by design. This gives
2075
the user the opportunity to decide whether they want to commit the
2076
rename at the same time, separately first, or not at all. (As a general
2077
rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)
2079
Note: A selected-file commit after a merge is not yet supported.
2029
2081
# TODO: Run hooks on tree to-be-committed, and after commit.
2290
2349
takes_args = ['testspecs*']
2291
2350
takes_options = ['verbose',
2292
Option('one', help='stop when one test fails'),
2293
Option('keep-output',
2352
help='stop when one test fails',
2355
Option('keep-output',
2294
2356
help='keep output directories when tests fail'),
2296
2358
help='Use a different transport by default '
2297
2359
'throughout the test suite.',
2298
2360
type=get_transport_type),
2299
Option('benchmark', help='run the bzr bencharks.'),
2361
Option('benchmark', help='run the bzr benchmarks.'),
2300
2362
Option('lsprof-timed',
2301
2363
help='generate lsprof output for benchmarked'
2302
2364
' sections of code.'),
2451
To merge the latest revision from bzr.dev
2452
bzr merge ../bzr.dev
2514
To merge the latest revision from bzr.dev:
2515
bzr merge ../bzr.dev
2454
To merge changes up to and including revision 82 from bzr.dev
2455
bzr merge -r 82 ../bzr.dev
2517
To merge changes up to and including revision 82 from bzr.dev:
2518
bzr merge -r 82 ../bzr.dev
2457
2520
To merge the changes introduced by 82, without previous changes:
2458
bzr merge -r 81..82 ../bzr.dev
2521
bzr merge -r 81..82 ../bzr.dev
2460
2523
merge refuses to run if there are any uncommitted changes, unless
2461
2524
--force is given.
2463
The following merge types are available:
2527
_see_also = ['update', 'remerge']
2465
2528
takes_args = ['branch?']
2466
2529
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2467
2530
Option('show-base', help="Show base revision text in "
2498
2562
# Either the merge helper code should be updated to take a tree,
2499
2563
# (What about tree.merge_from_branch?)
2500
2564
tree = WorkingTree.open_containing(directory)[0]
2501
change_reporter = delta.ChangeReporter(
2565
change_reporter = delta._ChangeReporter(
2502
2566
unversioned_filter=tree.is_ignored)
2504
2568
if branch is not None:
2506
reader = bundle.read_bundle_from_url(branch)
2570
mergeable = bundle.read_mergeable_from_url(
2507
2572
except errors.NotABundle:
2508
2573
pass # Continue on considering this url a Branch
2510
conflicts = merge_bundle(reader, tree, not force, merge_type,
2511
reprocess, show_base, change_reporter)
2575
if revision is not None:
2576
raise errors.BzrCommandError(
2577
'Cannot use -r with merge directives or bundles')
2578
other_revision_id = mergeable.install_revisions(
2579
tree.branch.repository)
2580
revision = [RevisionSpec.from_string(
2581
'revid:' + other_revision_id)]
2517
2583
if revision is None \
2518
2584
or len(revision) < 1 or revision[0].needs_branch():
2551
2622
base = [branch, revision[0].in_history(base_branch).revno]
2552
2623
other = [branch1, revision[1].in_history(other_branch).revno]
2554
if tree.branch.get_parent() is None or remember:
2625
if ((tree.branch.get_parent() is None or remember) and
2626
other_branch is not None):
2555
2627
tree.branch.set_parent(other_branch.base)
2557
2629
# pull tags now... it's a bit inconsistent to do it ahead of copying
2558
2630
# the history but that's done inside the merge code
2559
_merge_tags_if_possible(other_branch, tree.branch)
2631
if other_branch is not None:
2632
_merge_tags_if_possible(other_branch, tree.branch)
2562
2635
interesting_files = [path]
3214
3290
def run(self, port=None, inet=False, directory=None, allow_writes=False):
3215
from bzrlib.transport import smart
3291
from bzrlib.smart import medium, server
3216
3292
from bzrlib.transport import get_transport
3293
from bzrlib.transport.chroot import ChrootServer
3294
from bzrlib.transport.remote import BZR_DEFAULT_PORT
3217
3295
if directory is None:
3218
3296
directory = os.getcwd()
3219
3297
url = urlutils.local_path_to_url(directory)
3220
3298
if not allow_writes:
3221
3299
url = 'readonly+' + url
3222
t = get_transport(url)
3300
chroot_server = ChrootServer(get_transport(url))
3301
chroot_server.setUp()
3302
t = get_transport(chroot_server.get_url())
3224
server = smart.SmartServerPipeStreamMedium(sys.stdin, sys.stdout, t)
3304
smart_server = medium.SmartServerPipeStreamMedium(
3305
sys.stdin, sys.stdout, t)
3226
3307
if port is None:
3227
port = smart.BZR_DEFAULT_PORT
3308
port = BZR_DEFAULT_PORT
3228
3309
host = '127.0.0.1'
3230
3311
if ':' in port:
3233
3314
host = '127.0.0.1'
3234
3315
port = int(port)
3235
server = smart.SmartTCPServer(t, host=host, port=port)
3236
print 'listening on port: ', server.port
3316
smart_server = server.SmartTCPServer(t, host=host, port=port)
3317
print 'listening on port: ', smart_server.port
3237
3318
sys.stdout.flush()
3319
# for the duration of this server, no UI output is permitted.
3320
# note that this may cause problems with blackbox tests. This should
3321
# be changed with care though, as we dont want to use bandwidth sending
3322
# progress over stderr to smart server clients!
3323
old_factory = ui.ui_factory
3325
ui.ui_factory = ui.SilentUIFactory()
3326
smart_server.serve()
3328
ui.ui_factory = old_factory
3240
3331
class cmd_join(Command):
3241
3332
"""Combine a subtree into its containing tree.
3243
This is marked as a merge of the subtree into the containing tree, and all
3244
history is preserved.
3334
This command is for experimental use only. It requires the target tree
3335
to be in dirstate-with-subtree format, which cannot be converted into
3338
The TREE argument should be an independent tree, inside another tree, but
3339
not part of it. (Such trees can be produced by "bzr split", but also by
3340
running "bzr branch" with the target inside a tree.)
3342
The result is a combined tree, with the subtree no longer an independant
3343
part. This is marked as a merge of the subtree into the containing tree,
3344
and all history is preserved.
3346
If --reference is specified, the subtree retains its independence. It can
3347
be branched by itself, and can be part of multiple projects at the same
3348
time. But operations performed in the containing tree, such as commit
3349
and merge, will recurse into the subtree.
3352
_see_also = ['split']
3247
3353
takes_args = ['tree']
3248
3354
takes_options = [Option('reference', 'join by reference')]
3250
3357
def run(self, tree, reference=False):
3251
3358
sub_tree = WorkingTree.open(tree)
3276
3383
class cmd_split(Command):
3277
3384
"""Split a tree into two trees.
3386
This command is for experimental use only. It requires the target tree
3387
to be in dirstate-with-subtree format, which cannot be converted into
3390
The TREE argument should be a subdirectory of a working tree. That
3391
subdirectory will be converted into an independent tree, with its own
3392
branch. Commits in the top-level tree will not apply to the new subtree.
3393
If you want that behavior, do "bzr join --reference TREE".
3396
_see_also = ['join']
3280
3397
takes_args = ['tree']
3282
3401
def run(self, tree):
3283
3402
containing_tree, subdir = WorkingTree.open_containing(tree)
3284
3403
sub_id = containing_tree.path2id(subdir)
3413
class cmd_merge_directive(Command):
3414
"""Generate a merge directive for auto-merge tools.
3416
A directive requests a merge to be performed, and also provides all the
3417
information necessary to do so. This means it must either include a
3418
revision bundle, or the location of a branch containing the desired
3421
A submit branch (the location to merge into) must be supplied the first
3422
time the command is issued. After it has been supplied once, it will
3423
be remembered as the default.
3425
A public branch is optional if a revision bundle is supplied, but required
3426
if --diff or --plain is specified. It will be remembered as the default
3427
after the first use.
3430
takes_args = ['submit_branch?', 'public_branch?']
3433
RegistryOption.from_kwargs('patch-type',
3434
'The type of patch to include in the directive',
3435
title='Patch type', value_switches=True, enum_switch=False,
3436
bundle='Bazaar revision bundle (default)',
3437
diff='Normal unified diff',
3438
plain='No patch, just directive'),
3439
Option('sign', help='GPG-sign the directive'), 'revision',
3440
Option('mail-to', type=str,
3441
help='Instead of printing the directive, email to this address'),
3442
Option('message', type=str, short_name='m',
3443
help='Message to use when committing this merge')
3446
def run(self, submit_branch=None, public_branch=None, patch_type='bundle',
3447
sign=False, revision=None, mail_to=None, message=None):
3448
if patch_type == 'plain':
3450
branch = Branch.open('.')
3451
stored_submit_branch = branch.get_submit_branch()
3452
if submit_branch is None:
3453
submit_branch = stored_submit_branch
3455
if stored_submit_branch is None:
3456
branch.set_submit_branch(submit_branch)
3457
if submit_branch is None:
3458
submit_branch = branch.get_parent()
3459
if submit_branch is None:
3460
raise errors.BzrCommandError('No submit branch specified or known')
3462
stored_public_branch = branch.get_public_branch()
3463
if public_branch is None:
3464
public_branch = stored_public_branch
3465
elif stored_public_branch is None:
3466
branch.set_public_branch(public_branch)
3467
if patch_type != "bundle" and public_branch is None:
3468
raise errors.BzrCommandError('No public branch specified or'
3470
if revision is not None:
3471
if len(revision) != 1:
3472
raise errors.BzrCommandError('bzr merge-directive takes '
3473
'exactly one revision identifier')
3475
revision_id = revision[0].in_history(branch).rev_id
3477
revision_id = branch.last_revision()
3478
directive = merge_directive.MergeDirective.from_objects(
3479
branch.repository, revision_id, time.time(),
3480
osutils.local_time_offset(), submit_branch,
3481
public_branch=public_branch, patch_type=patch_type,
3485
self.outf.write(directive.to_signed(branch))
3487
self.outf.writelines(directive.to_lines())
3489
message = directive.to_email(mail_to, branch, sign)
3491
server = branch.get_config().get_user_option('smtp_server')
3493
server = 'localhost'
3495
s.sendmail(message['From'], message['To'], message.as_string())
3294
3498
class cmd_tag(Command):
3295
3499
"""Create a tag naming a revision.