250
250
To skip the display of pending merge information altogether, use
251
251
the no-pending option or specify a file/directory.
253
If a revision argument is given, the status is calculated against
254
that revision, or between two revisions if two are provided.
253
To compare the working directory to a specific revision, pass a
254
single revision to the revision argument.
256
To see which files have changed in a specific revision, or between
257
two revisions, pass a revision range to the revision argument.
258
This will produce the same results as calling 'bzr diff --summarize'.
257
261
# TODO: --no-recurse, --recurse options
477
485
d.destroy_workingtree()
488
class cmd_repair_workingtree(Command):
489
__doc__ = """Reset the working tree state file.
491
This is not meant to be used normally, but more as a way to recover from
492
filesystem corruption, etc. This rebuilds the working inventory back to a
493
'known good' state. Any new modifications (adding a file, renaming, etc)
494
will be lost, though modified files will still be detected as such.
496
Most users will want something more like "bzr revert" or "bzr update"
497
unless the state file has become corrupted.
499
By default this attempts to recover the current state by looking at the
500
headers of the state file. If the state file is too corrupted to even do
501
that, you can supply --revision to force the state of the tree.
504
takes_options = ['revision', 'directory',
506
help='Reset the tree even if it doesn\'t appear to be'
511
def run(self, revision=None, directory='.', force=False):
512
tree, _ = WorkingTree.open_containing(directory)
513
self.add_cleanup(tree.lock_tree_write().unlock)
517
except errors.BzrError:
518
pass # There seems to be a real error here, so we'll reset
521
raise errors.BzrCommandError(
522
'The tree does not appear to be corrupt. You probably'
523
' want "bzr revert" instead. Use "--force" if you are'
524
' sure you want to reset the working tree.')
528
revision_ids = [r.as_revision_id(tree.branch) for r in revision]
530
tree.reset_state(revision_ids)
531
except errors.BzrError, e:
532
if revision_ids is None:
533
extra = (', the header appears corrupt, try passing -r -1'
534
' to set the state to the last commit')
537
raise errors.BzrCommandError('failed to reset the tree state'
480
541
class cmd_revno(Command):
481
542
__doc__ = """Show current revision number.
901
962
match the remote one, use pull --overwrite. This will work even if the two
902
963
branches have diverged.
904
If there is no default location set, the first pull will set it. After
905
that, you can omit the location to use the default. To change the
906
default, use --remember. The value will only be saved if the remote
907
location can be accessed.
965
If there is no default location set, the first pull will set it (use
966
--no-remember to avoid settting it). After that, you can omit the
967
location to use the default. To change the default, use --remember. The
968
value will only be saved if the remote location can be accessed.
909
970
Note: The location can be specified either in the form of a branch,
910
971
or in the form of a path to a file containing a merge directive generated
923
984
"branch. Local pulls are not applied to "
924
985
"the master branch."
988
help="Show base revision text in conflicts.")
927
990
takes_args = ['location?']
928
991
encoding_type = 'replace'
930
def run(self, location=None, remember=False, overwrite=False,
993
def run(self, location=None, remember=None, overwrite=False,
931
994
revision=None, verbose=False,
932
directory=None, local=False):
995
directory=None, local=False,
933
997
# FIXME: too much stuff is in the command class
934
998
revision_id = None
1026
1099
do a merge (see bzr help merge) from the other branch, and commit that.
1027
1100
After that you will be able to do a push without '--overwrite'.
1029
If there is no default push location set, the first push will set it.
1030
After that, you can omit the location to use the default. To change the
1031
default, use --remember. The value will only be saved if the remote
1032
location can be accessed.
1102
If there is no default push location set, the first push will set it (use
1103
--no-remember to avoid settting it). After that, you can omit the
1104
location to use the default. To change the default, use --remember. The
1105
value will only be saved if the remote location can be accessed.
1035
1108
_see_also = ['pull', 'update', 'working-trees']
1056
1129
Option('strict',
1057
1130
help='Refuse to push if there are uncommitted changes in'
1058
1131
' the working tree, --no-strict disables the check.'),
1133
help="Don't populate the working tree, even for protocols"
1134
" that support it."),
1060
1136
takes_args = ['location?']
1061
1137
encoding_type = 'replace'
1063
def run(self, location=None, remember=False, overwrite=False,
1139
def run(self, location=None, remember=None, overwrite=False,
1064
1140
create_prefix=False, verbose=False, revision=None,
1065
1141
use_existing_dir=False, directory=None, stacked_on=None,
1066
stacked=False, strict=None):
1142
stacked=False, strict=None, no_tree=False):
1067
1143
from bzrlib.push import _show_push_branch
1069
1145
if directory is None:
1115
1191
_show_push_branch(br_from, revision_id, location, self.outf,
1116
1192
verbose=verbose, overwrite=overwrite, remember=remember,
1117
1193
stacked_on=stacked_on, create_prefix=create_prefix,
1118
use_existing_dir=use_existing_dir)
1194
use_existing_dir=use_existing_dir, no_tree=no_tree)
1121
1197
class cmd_branch(Command):
1165
1243
files_from=None):
1166
1244
from bzrlib import switch as _mod_switch
1167
1245
from bzrlib.tag import _merge_tags_if_possible
1246
if self.invoked_as in ['get', 'clone']:
1247
ui.ui_factory.show_user_warning(
1248
'deprecated_command',
1249
deprecated_name=self.invoked_as,
1250
recommended_name='branch',
1251
deprecated_in_version='2.4')
1168
1252
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1170
1254
if not (hardlink or files_from):
1364
1448
_see_also = ['pull', 'working-trees', 'status-flags']
1365
1449
takes_args = ['dir?']
1366
takes_options = ['revision']
1450
takes_options = ['revision',
1452
help="Show base revision text in conflicts."),
1367
1454
aliases = ['up']
1369
def run(self, dir='.', revision=None):
1456
def run(self, dir='.', revision=None, show_base=None):
1370
1457
if revision is not None and len(revision) != 1:
1371
1458
raise errors.BzrCommandError(
1372
1459
"bzr update --revision takes exactly one revision")
1494
1582
title='Deletion Strategy', value_switches=True, enum_switch=False,
1495
1583
safe='Backup changed files (default).',
1496
1584
keep='Delete from bzr but leave the working copy.',
1585
no_backup='Don\'t backup changed files.',
1497
1586
force='Delete all the specified files, even if they can not be '
1498
'recovered and even if they are non-empty directories.')]
1587
'recovered and even if they are non-empty directories. '
1588
'(deprecated, use no-backup)')]
1499
1589
aliases = ['rm', 'del']
1500
1590
encoding_type = 'replace'
1502
1592
def run(self, file_list, verbose=False, new=False,
1503
1593
file_deletion_strategy='safe'):
1594
if file_deletion_strategy == 'force':
1595
note("(The --force option is deprecated, rather use --no-backup "
1597
file_deletion_strategy = 'no-backup'
1504
1599
tree, file_list = WorkingTree.open_containing_paths(file_list)
1506
1601
if file_list is not None:
1689
1784
Option('append-revisions-only',
1690
1785
help='Never change revnos or the existing log.'
1691
' Append revisions to it only.')
1786
' Append revisions to it only.'),
1788
'Create a branch without a working tree.')
1693
1790
def run(self, location=None, format=None, append_revisions_only=False,
1694
create_prefix=False):
1791
create_prefix=False, no_tree=False):
1695
1792
if format is None:
1696
1793
format = bzrdir.format_registry.make_bzrdir('default')
1697
1794
if location is None:
2987
3115
to trigger updates to external systems like bug trackers. The --fixes
2988
3116
option can be used to record the association between a revision and
2989
3117
one or more bugs. See ``bzr help bugs`` for details.
2991
A selective commit may fail in some cases where the committed
2992
tree would be invalid. Consider::
2997
bzr commit foo -m "committing foo"
2998
bzr mv foo/bar foo/baz
3001
bzr commit foo/bar -m "committing bar but not baz"
3003
In the example above, the last commit will fail by design. This gives
3004
the user the opportunity to decide whether they want to commit the
3005
rename at the same time, separately first, or not at all. (As a general
3006
rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)
3008
# TODO: Run hooks on tree to-be-committed, and after commit.
3010
# TODO: Strict commit that fails if there are deleted files.
3011
# (what does "deleted files" mean ??)
3013
# TODO: Give better message for -s, --summary, used by tla people
3015
# XXX: verbose currently does nothing
3017
3120
_see_also = ['add', 'bugs', 'hooks', 'uncommit']
3018
3121
takes_args = ['selected*']
3075
3182
def run(self, message=None, file=None, verbose=False, selected_list=None,
3076
3183
unchanged=False, strict=False, local=False, fixes=None,
3077
author=None, show_diff=False, exclude=None, commit_time=None):
3184
author=None, show_diff=False, exclude=None, commit_time=None,
3078
3186
from bzrlib.errors import (
3079
3187
PointlessCommit,
3080
3188
ConflictsInTree,
3182
3284
reporter=None, verbose=verbose, revprops=properties,
3183
3285
authors=author, timestamp=commit_stamp,
3184
3286
timezone=offset,
3185
exclude=tree.safe_relpath_files(exclude))
3287
exclude=tree.safe_relpath_files(exclude),
3186
3289
except PointlessCommit:
3187
3290
raise errors.BzrCommandError("No changes to commit."
3188
" Use --unchanged to commit anyhow.")
3291
" Please 'bzr add' the files you want to commit, or use"
3292
" --unchanged to force an empty commit.")
3189
3293
except ConflictsInTree:
3190
3294
raise errors.BzrCommandError('Conflicts detected in working '
3191
3295
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
3274
3378
class cmd_upgrade(Command):
3275
__doc__ = """Upgrade branch storage to current format.
3277
The check command or bzr developers may sometimes advise you to run
3278
this command. When the default format has changed you may also be warned
3279
during other operations to upgrade.
3379
__doc__ = """Upgrade a repository, branch or working tree to a newer format.
3381
When the default format has changed after a major new release of
3382
Bazaar, you may be informed during certain operations that you
3383
should upgrade. Upgrading to a newer format may improve performance
3384
or make new features available. It may however limit interoperability
3385
with older repositories or with older versions of Bazaar.
3387
If you wish to upgrade to a particular format rather than the
3388
current default, that can be specified using the --format option.
3389
As a consequence, you can use the upgrade command this way to
3390
"downgrade" to an earlier format, though some conversions are
3391
a one way process (e.g. changing from the 1.x default to the
3392
2.x default) so downgrading is not always possible.
3394
A backup.bzr.~#~ directory is created at the start of the conversion
3395
process (where # is a number). By default, this is left there on
3396
completion. If the conversion fails, delete the new .bzr directory
3397
and rename this one back in its place. Use the --clean option to ask
3398
for the backup.bzr directory to be removed on successful conversion.
3399
Alternatively, you can delete it by hand if everything looks good
3402
If the location given is a shared repository, dependent branches
3403
are also converted provided the repository converts successfully.
3404
If the conversion of a branch fails, remaining branches are still
3407
For more information on upgrades, see the Bazaar Upgrade Guide,
3408
http://doc.bazaar.canonical.com/latest/en/upgrade-guide/.
3282
_see_also = ['check']
3411
_see_also = ['check', 'reconcile', 'formats']
3283
3412
takes_args = ['url?']
3284
3413
takes_options = [
3285
RegistryOption('format',
3286
help='Upgrade to a specific format. See "bzr help'
3287
' formats" for details.',
3288
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3289
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
3290
value_switches=True, title='Branch format'),
3414
RegistryOption('format',
3415
help='Upgrade to a specific format. See "bzr help'
3416
' formats" for details.',
3417
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3418
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
3419
value_switches=True, title='Branch format'),
3421
help='Remove the backup.bzr directory if successful.'),
3423
help="Show what would be done, but don't actually do anything."),
3293
def run(self, url='.', format=None):
3426
def run(self, url='.', format=None, clean=False, dry_run=False):
3294
3427
from bzrlib.upgrade import upgrade
3295
upgrade(url, format)
3428
exceptions = upgrade(url, format, clean_up=clean, dry_run=dry_run)
3430
if len(exceptions) == 1:
3431
# Compatibility with historical behavior
3298
3437
class cmd_whoami(Command):
3693
3836
with bzr send. If neither is specified, the default is the upstream branch
3694
3837
or the branch most recently merged using --remember.
3696
When merging a branch, by default the tip will be merged. To pick a different
3697
revision, pass --revision. If you specify two values, the first will be used as
3698
BASE and the second one as OTHER. Merging individual revisions, or a subset of
3699
available revisions, like this is commonly referred to as "cherrypicking".
3701
Revision numbers are always relative to the branch being merged.
3703
By default, bzr will try to merge in all new work from the other
3704
branch, automatically determining an appropriate base. If this
3705
fails, you may need to give an explicit base.
3839
When merging from a branch, by default bzr will try to merge in all new
3840
work from the other branch, automatically determining an appropriate base
3841
revision. If this fails, you may need to give an explicit base.
3843
To pick a different ending revision, pass "--revision OTHER". bzr will
3844
try to merge in all new work up to and including revision OTHER.
3846
If you specify two values, "--revision BASE..OTHER", only revisions BASE
3847
through OTHER, excluding BASE but including OTHER, will be merged. If this
3848
causes some revisions to be skipped, i.e. if the destination branch does
3849
not already contain revision BASE, such a merge is commonly referred to as
3850
a "cherrypick". Unlike a normal merge, Bazaar does not currently track
3851
cherrypicks. The changes look like a normal commit, and the history of the
3852
changes from the other branch is not stored in the commit.
3854
Revision numbers are always relative to the source branch.
3707
3856
Merge will do its best to combine the changes in two branches, but there
3708
3857
are some kinds of problems only a human can fix. When it encounters those,
3712
3861
Use bzr resolve when you have fixed a problem. See also bzr conflicts.
3714
If there is no default branch set, the first merge will set it. After
3715
that, you can omit the branch to use the default. To change the
3716
default, use --remember. The value will only be saved if the remote
3717
location can be accessed.
3863
If there is no default branch set, the first merge will set it (use
3864
--no-remember to avoid settting it). After that, you can omit the branch
3865
to use the default. To change the default, use --remember. The value will
3866
only be saved if the remote location can be accessed.
3719
3868
The results of the merge are placed into the destination working
3720
3869
directory, where they can be reviewed (with bzr diff), tested, and then
3787
3936
def run(self, location=None, revision=None, force=False,
3788
merge_type=None, show_base=False, reprocess=None, remember=False,
3937
merge_type=None, show_base=False, reprocess=None, remember=None,
3789
3938
uncommitted=False, pull=False,
3790
3939
directory=None,
3968
4121
if other_revision_id is None:
3969
4122
other_revision_id = _mod_revision.ensure_null(
3970
4123
other_branch.last_revision())
3971
# Remember where we merge from
3972
if ((remember or tree.branch.get_submit_branch() is None) and
3973
user_location is not None):
4124
# Remember where we merge from. We need to remember if:
4125
# - user specify a location (and we don't merge from the parent
4127
# - user ask to remember or there is no previous location set to merge
4128
# from and user didn't ask to *not* remember
4129
if (user_location is not None
4131
or (remember is None
4132
and tree.branch.get_submit_branch() is None)))):
3974
4133
tree.branch.set_submit_branch(other_branch.base)
3975
_merge_tags_if_possible(other_branch, tree.branch)
4134
# Merge tags (but don't set them in the master branch yet, the user
4135
# might revert this merge). Commit will propagate them.
4136
_merge_tags_if_possible(other_branch, tree.branch, ignore_master=True)
3976
4137
merger = _mod_merge.Merger.from_revision_ids(pb, tree,
3977
4138
other_revision_id, base_revision_id, other_branch, base_branch)
3978
4139
if other_path != '':
4146
4307
last committed revision is used.
4148
4309
To remove only some changes, without reverting to a prior version, use
4149
merge instead. For example, "merge . --revision -2..-3" will remove the
4150
changes introduced by -2, without affecting the changes introduced by -1.
4151
Or to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
4310
merge instead. For example, "merge . -r -2..-3" (don't forget the ".")
4311
will remove the changes introduced by the second last commit (-2), without
4312
affecting the changes introduced by the last commit (-1). To remove
4313
certain changes on a hunk-by-hunk basis, see the shelve command.
4153
4315
By default, any files that have been manually changed will be backed up
4154
4316
first. (Files changed only by merge are not backed up.) Backup files have
4484
4646
@display_command
4485
4647
def run(self, verbose=False):
4486
import bzrlib.plugin
4487
from inspect import getdoc
4489
for name, plugin in bzrlib.plugin.plugins().items():
4490
version = plugin.__version__
4491
if version == 'unknown':
4493
name_ver = '%s %s' % (name, version)
4494
d = getdoc(plugin.module)
4496
doc = d.split('\n')[0]
4498
doc = '(no description)'
4499
result.append((name_ver, doc, plugin.path()))
4500
for name_ver, doc, path in sorted(result):
4501
self.outf.write("%s\n" % name_ver)
4502
self.outf.write(" %s\n" % doc)
4504
self.outf.write(" %s\n" % path)
4505
self.outf.write("\n")
4648
from bzrlib import plugin
4649
# Don't give writelines a generator as some codecs don't like that
4650
self.outf.writelines(
4651
list(plugin.describe_plugins(show_paths=verbose)))
4508
4654
class cmd_testament(Command):
4570
4718
self.add_cleanup(branch.lock_read().unlock)
4571
4719
tree = _get_one_revision_tree('annotate', revision, branch=branch)
4572
4720
self.add_cleanup(tree.lock_read().unlock)
4721
if wt is not None and revision is None:
4574
4722
file_id = wt.path2id(relpath)
4576
4724
file_id = tree.path2id(relpath)
4577
4725
if file_id is None:
4578
4726
raise errors.NotVersionedError(filename)
4579
file_version = tree.inventory[file_id].revision
4580
4727
if wt is not None and revision is None:
4581
4728
# If there is a tree and we're not annotating historical
4582
4729
# versions, annotate the working tree's content.
4583
4730
annotate_file_tree(wt, file_id, self.outf, long, all,
4584
4731
show_ids=show_ids)
4586
annotate_file(branch, file_version, file_id, long, all, self.outf,
4733
annotate_file_tree(tree, file_id, self.outf, long, all,
4734
show_ids=show_ids, branch=branch)
4590
4737
class cmd_re_sign(Command):
4841
4988
takes_options = [
4842
4989
Option('config',
4843
4990
help='LOCATION is the directory where the config lock is.'),
4992
help='Do not ask for confirmation before breaking the lock.'),
4846
def run(self, location=None, config=False):
4995
def run(self, location=None, config=False, force=False):
4847
4996
if location is None:
4848
4997
location = u'.'
4999
ui.ui_factory = ui.ConfirmationUserInterfacePolicy(ui.ui_factory,
5001
{'bzrlib.lockdir.break': True})
4850
5003
conf = _mod_config.LockableConfig(file_name=location)
4851
5004
conf.break_lock()
5141
5294
source branch defaults to that containing the working directory, but can
5142
5295
be changed using --from.
5297
Both the submit branch and the public branch follow the usual behavior with
5298
respect to --remember: If there is no default location set, the first send
5299
will set it (use --no-remember to avoid settting it). After that, you can
5300
omit the location to use the default. To change the default, use
5301
--remember. The value will only be saved if the location can be accessed.
5144
5303
In order to calculate those changes, bzr must analyse the submit branch.
5145
5304
Therefore it is most efficient for the submit branch to be a local mirror.
5146
5305
If a public location is known for the submit_branch, that location is used
5217
5376
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
5218
no_patch=False, revision=None, remember=False, output=None,
5377
no_patch=False, revision=None, remember=None, output=None,
5219
5378
format=None, mail_to=None, message=None, body=None,
5220
5379
strict=None, **kwargs):
5221
5380
from bzrlib.send import send
5378
5537
takes_options = [
5379
5538
custom_help('directory',
5380
5539
help='Branch whose tags should be displayed.'),
5381
RegistryOption.from_kwargs('sort',
5540
RegistryOption('sort',
5382
5541
'Sort tags by different criteria.', title='Sorting',
5383
alpha='Sort tags lexicographically (default).',
5384
time='Sort tags chronologically.',
5542
lazy_registry=('bzrlib.tag', 'tag_sort_methods')
5390
5548
@display_command
5549
def run(self, directory='.', sort=None, show_ids=False, revision=None):
5550
from bzrlib.tag import tag_sort_methods
5397
5551
branch, relpath = Branch.open_containing(directory)
5399
5553
tags = branch.tags.get_tag_dict().items()
5408
5562
# only show revisions between revid1 and revid2 (inclusive)
5409
5563
tags = [(tag, revid) for tag, revid in tags if
5410
5564
graph.is_between(revid, revid1, revid2)]
5413
elif sort == 'time':
5415
for tag, revid in tags:
5417
revobj = branch.repository.get_revision(revid)
5418
except errors.NoSuchRevision:
5419
timestamp = sys.maxint # place them at the end
5421
timestamp = revobj.timestamp
5422
timestamps[revid] = timestamp
5423
tags.sort(key=lambda x: timestamps[x[1]])
5566
sort = tag_sort_methods.get()
5424
5568
if not show_ids:
5425
5569
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5426
5570
for index, (tag, revid) in enumerate(tags):
5850
5994
You can put multiple items on the shelf, and by default, 'unshelve' will
5851
5995
restore the most recently shelved changes.
5997
For complicated changes, it is possible to edit the changes in a separate
5998
editor program to decide what the file remaining in the working copy
5999
should look like. To do this, add the configuration option
6001
change_editor = PROGRAM @new_path @old_path
6003
where @new_path is replaced with the path of the new version of the
6004
file and @old_path is replaced with the path of the old version of
6005
the file. The PROGRAM should save the new file with the desired
6006
contents of the file in the working tree.
5854
6010
takes_args = ['file*']
5866
6022
Option('destroy',
5867
6023
help='Destroy removed changes instead of shelving them.'),
5869
_see_also = ['unshelve']
6025
_see_also = ['unshelve', 'configuration']
5871
6027
def run(self, revision=None, all=False, file_list=None, message=None,
5872
writer=None, list=False, destroy=False, directory=u'.'):
6028
writer=None, list=False, destroy=False, directory=None):
5874
return self.run_for_list()
6030
return self.run_for_list(directory=directory)
5875
6031
from bzrlib.shelf_ui import Shelver
5876
6032
if writer is None:
5877
6033
writer = bzrlib.option.diff_writer_registry.get()
5952
6110
takes_options = ['directory',
5953
6111
Option('ignored', help='Delete all ignored files.'),
5954
Option('detritus', help='Delete conflict files, merge'
6112
Option('detritus', help='Delete conflict files, merge and revert'
5955
6113
' backups, and failed selftest dirs.'),
5956
6114
Option('unknown',
5957
6115
help='Delete files unknown to bzr (default).'),
6016
6174
self.outf.write('%s %s\n' % (path, location))
6177
class cmd_export_pot(Command):
6178
__doc__ = """Export command helps and error messages in po format."""
6183
from bzrlib.export_pot import export_pot
6184
export_pot(self.outf)
6019
6187
def _register_lazy_builtins():
6020
6188
# register lazy builtins from other modules; called at startup and should
6021
6189
# be only called once.
6022
6190
for (name, aliases, module_name) in [
6023
6191
('cmd_bundle_info', [], 'bzrlib.bundle.commands'),
6192
('cmd_config', [], 'bzrlib.config'),
6024
6193
('cmd_dpush', [], 'bzrlib.foreign'),
6025
6194
('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6026
6195
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6027
6196
('cmd_conflicts', [], 'bzrlib.conflicts'),
6028
6197
('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
6198
('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6030
6200
builtin_command_registry.register_lazy(name, aliases, module_name)