164
173
:return: workingtree, [relative_paths]
166
if file_list is None or len(file_list) == 0:
167
tree = WorkingTree.open_containing(default_branch)[0]
168
if tree.supports_views() and apply_view:
169
view_files = tree.views.lookup_view()
171
file_list = view_files
172
view_str = views.view_display_str(view_files)
173
note("Ignoring files outside view. View is %s" % view_str)
174
return tree, file_list
175
tree = WorkingTree.open_containing(osutils.realpath(file_list[0]))[0]
176
return tree, safe_relpath_files(tree, file_list, canonicalize,
177
apply_view=apply_view)
180
def safe_relpath_files(tree, file_list, canonicalize=True, apply_view=True):
181
"""Convert file_list into a list of relpaths in tree.
183
:param tree: A tree to operate on.
184
:param file_list: A list of user provided paths or None.
185
:param apply_view: if True and a view is set, apply it or check that
186
specified files are within it
187
:return: A list of relative paths.
188
:raises errors.PathNotChild: When a provided path is in a different tree
191
if file_list is None:
193
if tree.supports_views() and apply_view:
194
view_files = tree.views.lookup_view()
198
# tree.relpath exists as a "thunk" to osutils, but canonical_relpath
199
# doesn't - fix that up here before we enter the loop.
201
fixer = lambda p: osutils.canonical_relpath(tree.basedir, p)
204
for filename in file_list:
206
relpath = fixer(osutils.dereference_path(filename))
207
if view_files and not osutils.is_inside_any(view_files, relpath):
208
raise errors.FileOutsideView(filename, view_files)
209
new_list.append(relpath)
210
except errors.PathNotChild:
211
raise errors.FileInWrongBranch(tree.branch, filename)
175
return WorkingTree.open_containing_paths(
176
file_list, default_directory='.',
215
181
def _get_view_info_for_change_reporter(tree):
330
312
takes_args = ['revision_id?']
331
takes_options = ['revision']
313
takes_options = ['directory', 'revision']
332
314
# cat-revision is more for frontends so should be exact
333
315
encoding = 'strict'
317
def print_revision(self, revisions, revid):
318
stream = revisions.get_record_stream([(revid,)], 'unordered', True)
319
record = stream.next()
320
if record.storage_kind == 'absent':
321
raise errors.NoSuchRevision(revisions, revid)
322
revtext = record.get_bytes_as('fulltext')
323
self.outf.write(revtext.decode('utf-8'))
336
def run(self, revision_id=None, revision=None):
326
def run(self, revision_id=None, revision=None, directory=u'.'):
337
327
if revision_id is not None and revision is not None:
338
328
raise errors.BzrCommandError('You can only supply one of'
339
329
' revision_id or --revision')
340
330
if revision_id is None and revision is None:
341
331
raise errors.BzrCommandError('You must supply either'
342
332
' --revision or a revision_id')
343
b = WorkingTree.open_containing(u'.')[0].branch
345
# TODO: jam 20060112 should cat-revision always output utf-8?
346
if revision_id is not None:
347
revision_id = osutils.safe_revision_id(revision_id, warn=False)
349
self.outf.write(b.repository.get_revision_xml(revision_id).decode('utf-8'))
350
except errors.NoSuchRevision:
351
msg = "The repository %s contains no revision %s." % (b.repository.base,
353
raise errors.BzrCommandError(msg)
354
elif revision is not None:
357
raise errors.BzrCommandError('You cannot specify a NULL'
359
rev_id = rev.as_revision_id(b)
360
self.outf.write(b.repository.get_revision_xml(rev_id).decode('utf-8'))
333
b = WorkingTree.open_containing(directory)[0].branch
335
revisions = b.repository.revisions
336
if revisions is None:
337
raise errors.BzrCommandError('Repository %r does not support '
338
'access to raw revision texts')
340
b.repository.lock_read()
342
# TODO: jam 20060112 should cat-revision always output utf-8?
343
if revision_id is not None:
344
revision_id = osutils.safe_revision_id(revision_id, warn=False)
346
self.print_revision(revisions, revision_id)
347
except errors.NoSuchRevision:
348
msg = "The repository %s contains no revision %s." % (
349
b.repository.base, revision_id)
350
raise errors.BzrCommandError(msg)
351
elif revision is not None:
354
raise errors.BzrCommandError(
355
'You cannot specify a NULL revision.')
356
rev_id = rev.as_revision_id(b)
357
self.print_revision(revisions, rev_id)
359
b.repository.unlock()
363
362
class cmd_dump_btree(Command):
364
"""Dump the contents of a btree index file to stdout.
363
__doc__ = """Dump the contents of a btree index file to stdout.
366
365
PATH is a btree index file, it can be any URL. This includes things like
367
366
.bzr/repository/pack-names, or .bzr/repository/indices/a34b3a...ca4a4.iix
443
449
To re-create the working tree, use "bzr checkout".
445
451
_see_also = ['checkout', 'working-trees']
446
takes_args = ['location?']
452
takes_args = ['location*']
447
453
takes_options = [
449
455
help='Remove the working tree even if it has '
450
'uncommitted changes.'),
456
'uncommitted or shelved changes.'),
453
def run(self, location='.', force=False):
454
d = bzrdir.BzrDir.open(location)
457
working = d.open_workingtree()
458
except errors.NoWorkingTree:
459
raise errors.BzrCommandError("No working tree to remove")
460
except errors.NotLocalUrl:
461
raise errors.BzrCommandError("You cannot remove the working tree"
464
# XXX: What about pending merges ? -- vila 20090629
465
if working.has_changes(working.basis_tree()):
466
raise errors.UncommittedChanges(working)
468
working_path = working.bzrdir.root_transport.base
469
branch_path = working.branch.bzrdir.root_transport.base
470
if working_path != branch_path:
471
raise errors.BzrCommandError("You cannot remove the working tree"
472
" from a lightweight checkout")
474
d.destroy_workingtree()
459
def run(self, location_list, force=False):
460
if not location_list:
463
for location in location_list:
464
d = bzrdir.BzrDir.open(location)
467
working = d.open_workingtree()
468
except errors.NoWorkingTree:
469
raise errors.BzrCommandError("No working tree to remove")
470
except errors.NotLocalUrl:
471
raise errors.BzrCommandError("You cannot remove the working tree"
474
if (working.has_changes()):
475
raise errors.UncommittedChanges(working)
476
if working.get_shelf_manager().last_shelf() is not None:
477
raise errors.ShelvedChanges(working)
479
if working.user_url != working.branch.user_url:
480
raise errors.BzrCommandError("You cannot remove the working tree"
481
" from a lightweight checkout")
483
d.destroy_workingtree()
477
486
class cmd_revno(Command):
478
"""Show current revision number.
487
__doc__ = """Show current revision number.
480
489
This is equal to the number of revisions on this branch.
493
502
wt = WorkingTree.open_containing(location)[0]
503
self.add_cleanup(wt.lock_read().unlock)
495
504
except (errors.NoWorkingTree, errors.NotLocalUrl):
496
505
raise errors.NoWorkingTree(location)
506
revid = wt.last_revision()
498
revid = wt.last_revision()
500
revno_t = wt.branch.revision_id_to_dotted_revno(revid)
501
except errors.NoSuchRevision:
503
revno = ".".join(str(n) for n in revno_t)
508
revno_t = wt.branch.revision_id_to_dotted_revno(revid)
509
except errors.NoSuchRevision:
511
revno = ".".join(str(n) for n in revno_t)
507
513
b = Branch.open_containing(location)[0]
514
self.add_cleanup(b.lock_read().unlock)
514
517
self.outf.write(str(revno) + '\n')
517
520
class cmd_revision_info(Command):
518
"""Show revision number and revision id for a given revision identifier.
521
__doc__ = """Show revision number and revision id for a given revision identifier.
521
524
takes_args = ['revision_info*']
522
525
takes_options = [
527
custom_help('directory',
525
528
help='Branch to examine, '
526
'rather than the one containing the working directory.',
529
'rather than the one containing the working directory.'),
530
530
Option('tree', help='Show revno of working tree'),
538
538
wt = WorkingTree.open_containing(directory)[0]
540
self.add_cleanup(wt.lock_read().unlock)
541
541
except (errors.NoWorkingTree, errors.NotLocalUrl):
543
543
b = Branch.open_containing(directory)[0]
547
if revision is not None:
548
revision_ids.extend(rev.as_revision_id(b) for rev in revision)
549
if revision_info_list is not None:
550
for rev_str in revision_info_list:
551
rev_spec = RevisionSpec.from_string(rev_str)
552
revision_ids.append(rev_spec.as_revision_id(b))
553
# No arguments supplied, default to the last revision
554
if len(revision_ids) == 0:
557
raise errors.NoWorkingTree(directory)
558
revision_ids.append(wt.last_revision())
560
revision_ids.append(b.last_revision())
564
for revision_id in revision_ids:
566
dotted_revno = b.revision_id_to_dotted_revno(revision_id)
567
revno = '.'.join(str(i) for i in dotted_revno)
568
except errors.NoSuchRevision:
570
maxlen = max(maxlen, len(revno))
571
revinfos.append([revno, revision_id])
544
self.add_cleanup(b.lock_read().unlock)
546
if revision is not None:
547
revision_ids.extend(rev.as_revision_id(b) for rev in revision)
548
if revision_info_list is not None:
549
for rev_str in revision_info_list:
550
rev_spec = RevisionSpec.from_string(rev_str)
551
revision_ids.append(rev_spec.as_revision_id(b))
552
# No arguments supplied, default to the last revision
553
if len(revision_ids) == 0:
556
raise errors.NoWorkingTree(directory)
557
revision_ids.append(wt.last_revision())
559
revision_ids.append(b.last_revision())
563
for revision_id in revision_ids:
565
dotted_revno = b.revision_id_to_dotted_revno(revision_id)
566
revno = '.'.join(str(i) for i in dotted_revno)
567
except errors.NoSuchRevision:
569
maxlen = max(maxlen, len(revno))
570
revinfos.append([revno, revision_id])
578
573
for ri in revinfos:
579
574
self.outf.write('%*s %s\n' % (maxlen, ri[0], ri[1]))
582
577
class cmd_add(Command):
583
"""Add specified files or directories.
578
__doc__ = """Add specified files or directories.
585
580
In non-recursive mode, all the named items are added, regardless
586
581
of whether they were previously ignored. A warning is given if
727
723
raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
729
725
revision = _get_one_revision('inventory', revision)
730
work_tree, file_list = tree_files(file_list)
731
work_tree.lock_read()
733
if revision is not None:
734
tree = revision.as_tree(work_tree.branch)
736
extra_trees = [work_tree]
742
if file_list is not None:
743
file_ids = tree.paths2ids(file_list, trees=extra_trees,
744
require_versioned=True)
745
# find_ids_across_trees may include some paths that don't
747
entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
748
for file_id in file_ids if file_id in tree)
750
entries = tree.inventory.entries()
753
if tree is not work_tree:
726
work_tree, file_list = WorkingTree.open_containing_paths(file_list)
727
self.add_cleanup(work_tree.lock_read().unlock)
728
if revision is not None:
729
tree = revision.as_tree(work_tree.branch)
731
extra_trees = [work_tree]
732
self.add_cleanup(tree.lock_read().unlock)
737
if file_list is not None:
738
file_ids = tree.paths2ids(file_list, trees=extra_trees,
739
require_versioned=True)
740
# find_ids_across_trees may include some paths that don't
742
entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
743
for file_id in file_ids if file_id in tree)
745
entries = tree.inventory.entries()
756
748
for path, entry in entries:
757
749
if kind and kind != entry.kind:
899
887
dest = osutils.pathjoin(dest_parent, dest_tail)
900
888
mutter("attempting to move %s => %s", src, dest)
901
889
tree.rename_one(src, dest, after=after)
902
self.outf.write("%s => %s\n" % (src, dest))
891
self.outf.write("%s => %s\n" % (src, dest))
905
894
class cmd_pull(Command):
906
"""Turn this branch into a mirror of another branch.
895
__doc__ = """Turn this branch into a mirror of another branch.
908
This command only works on branches that have not diverged. Branches are
909
considered diverged if the destination branch's most recent commit is one
910
that has not been merged (directly or indirectly) into the parent.
897
By default, this command only works on branches that have not diverged.
898
Branches are considered diverged if the destination branch's most recent
899
commit is one that has not been merged (directly or indirectly) into the
912
902
If branches have diverged, you can use 'bzr merge' to integrate the changes
913
903
from one into the other. Once one branch has merged, the other should
914
904
be able to pull it again.
916
If you want to forget your local changes and just update your branch to
917
match the remote one, use pull --overwrite.
906
If you want to replace your local changes and just want your branch to
907
match the remote one, use pull --overwrite. This will work even if the two
908
branches have diverged.
919
910
If there is no default location set, the first pull will set it. After
920
911
that, you can omit the location to use the default. To change the
996
992
branch_from = Branch.open(location,
997
993
possible_transports=possible_transports)
994
self.add_cleanup(branch_from.lock_read().unlock)
999
996
if branch_to.get_parent() is None or remember:
1000
997
branch_to.set_parent(branch_from.base)
1002
if branch_from is not branch_to:
1003
branch_from.lock_read()
1005
if revision is not None:
1006
revision_id = revision.as_revision_id(branch_from)
1008
branch_to.lock_write()
1010
if tree_to is not None:
1011
view_info = _get_view_info_for_change_reporter(tree_to)
1012
change_reporter = delta._ChangeReporter(
1013
unversioned_filter=tree_to.is_ignored,
1014
view_info=view_info)
1015
result = tree_to.pull(
1016
branch_from, overwrite, revision_id, change_reporter,
1017
possible_transports=possible_transports, local=local)
1019
result = branch_to.pull(
1020
branch_from, overwrite, revision_id, local=local)
1022
result.report(self.outf)
1023
if verbose and result.old_revid != result.new_revid:
1024
log.show_branch_change(
1025
branch_to, self.outf, result.old_revno,
1030
if branch_from is not branch_to:
1031
branch_from.unlock()
999
if revision is not None:
1000
revision_id = revision.as_revision_id(branch_from)
1002
if tree_to is not None:
1003
view_info = _get_view_info_for_change_reporter(tree_to)
1004
change_reporter = delta._ChangeReporter(
1005
unversioned_filter=tree_to.is_ignored,
1006
view_info=view_info)
1007
result = tree_to.pull(
1008
branch_from, overwrite, revision_id, change_reporter,
1009
possible_transports=possible_transports, local=local,
1010
show_base=show_base)
1012
result = branch_to.pull(
1013
branch_from, overwrite, revision_id, local=local)
1015
result.report(self.outf)
1016
if verbose and result.old_revid != result.new_revid:
1017
log.show_branch_change(
1018
branch_to, self.outf, result.old_revno,
1034
1022
class cmd_push(Command):
1035
"""Update a mirror of this branch.
1023
__doc__ = """Update a mirror of this branch.
1037
1025
The target branch will not have its working tree populated because this
1038
1026
is both expensive, and is not supported on remote file systems.
1099
1087
# Get the source branch
1100
1088
(tree, br_from,
1101
1089
_unused) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
1103
strict = br_from.get_config().get_user_option_as_bool('push_strict')
1104
if strict is None: strict = True # default value
1105
1090
# Get the tip's revision_id
1106
1091
revision = _get_one_revision('push', revision)
1107
1092
if revision is not None:
1108
1093
revision_id = revision.in_history(br_from).rev_id
1110
1095
revision_id = None
1111
if strict and tree is not None and revision_id is None:
1112
if (tree.has_changes(tree.basis_tree())
1113
or len(tree.get_parent_ids()) > 1):
1114
raise errors.UncommittedChanges(
1115
tree, more='Use --no-strict to force the push.')
1116
if tree.last_revision() != tree.branch.last_revision():
1117
# The tree has lost sync with its branch, there is little
1118
# chance that the user is aware of it but he can still force
1119
# the push with --no-strict
1120
raise errors.OutOfDateTree(
1121
tree, more='Use --no-strict to force the push.')
1096
if tree is not None and revision_id is None:
1097
tree.check_changed_or_out_of_date(
1098
strict, 'push_strict',
1099
more_error='Use --no-strict to force the push.',
1100
more_warning='Uncommitted changes will not be pushed.')
1123
1101
# Get the stacked_on branch, if any
1124
1102
if stacked_on is not None:
1125
1103
stacked_on = urlutils.normalize_url(stacked_on)
1190
1170
' directory exists, but does not already'
1191
1171
' have a control directory. This flag will'
1192
1172
' allow branch to proceed.'),
1174
help="Bind new branch to from location."),
1194
1176
aliases = ['get', 'clone']
1196
1178
def run(self, from_location, to_location=None, revision=None,
1197
1179
hardlink=False, stacked=False, standalone=False, no_tree=False,
1198
use_existing_dir=False, switch=False):
1180
use_existing_dir=False, switch=False, bind=False,
1199
1182
from bzrlib import switch as _mod_switch
1200
1183
from bzrlib.tag import _merge_tags_if_possible
1201
1184
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1203
if (accelerator_tree is not None and
1204
accelerator_tree.supports_content_filtering()):
1186
if not (hardlink or files_from):
1187
# accelerator_tree is usually slower because you have to read N
1188
# files (no readahead, lots of seeks, etc), but allow the user to
1189
# explicitly request it
1205
1190
accelerator_tree = None
1191
if files_from is not None and files_from != from_location:
1192
accelerator_tree = WorkingTree.open(files_from)
1206
1193
revision = _get_one_revision('branch', revision)
1194
self.add_cleanup(br_from.lock_read().unlock)
1195
if revision is not None:
1196
revision_id = revision.as_revision_id(br_from)
1198
# FIXME - wt.last_revision, fallback to branch, fall back to
1199
# None or perhaps NULL_REVISION to mean copy nothing
1201
revision_id = br_from.last_revision()
1202
if to_location is None:
1203
to_location = urlutils.derive_to_location(from_location)
1204
to_transport = transport.get_transport(to_location)
1209
if revision is not None:
1210
revision_id = revision.as_revision_id(br_from)
1206
to_transport.mkdir('.')
1207
except errors.FileExists:
1208
if not use_existing_dir:
1209
raise errors.BzrCommandError('Target directory "%s" '
1210
'already exists.' % to_location)
1212
# FIXME - wt.last_revision, fallback to branch, fall back to
1213
# None or perhaps NULL_REVISION to mean copy nothing
1215
revision_id = br_from.last_revision()
1216
if to_location is None:
1217
to_location = urlutils.derive_to_location(from_location)
1218
to_transport = transport.get_transport(to_location)
1220
to_transport.mkdir('.')
1221
except errors.FileExists:
1222
if not use_existing_dir:
1223
raise errors.BzrCommandError('Target directory "%s" '
1224
'already exists.' % to_location)
1213
bzrdir.BzrDir.open_from_transport(to_transport)
1214
except errors.NotBranchError:
1227
bzrdir.BzrDir.open_from_transport(to_transport)
1228
except errors.NotBranchError:
1231
raise errors.AlreadyBranchError(to_location)
1232
except errors.NoSuchFile:
1233
raise errors.BzrCommandError('Parent of "%s" does not exist.'
1236
# preserve whatever source format we have.
1237
dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1238
possible_transports=[to_transport],
1239
accelerator_tree=accelerator_tree,
1240
hardlink=hardlink, stacked=stacked,
1241
force_new_repo=standalone,
1242
create_tree_if_local=not no_tree,
1243
source_branch=br_from)
1244
branch = dir.open_branch()
1245
except errors.NoSuchRevision:
1246
to_transport.delete_tree('.')
1247
msg = "The branch %s has no revision %s." % (from_location,
1249
raise errors.BzrCommandError(msg)
1250
_merge_tags_if_possible(br_from, branch)
1251
# If the source branch is stacked, the new branch may
1252
# be stacked whether we asked for that explicitly or not.
1253
# We therefore need a try/except here and not just 'if stacked:'
1255
note('Created new stacked branch referring to %s.' %
1256
branch.get_stacked_on_url())
1257
except (errors.NotStacked, errors.UnstackableBranchFormat,
1258
errors.UnstackableRepositoryFormat), e:
1259
note('Branched %d revision(s).' % branch.revno())
1261
# Switch to the new branch
1262
wt, _ = WorkingTree.open_containing('.')
1263
_mod_switch.switch(wt.bzrdir, branch)
1264
note('Switched to branch: %s',
1265
urlutils.unescape_for_display(branch.base, 'utf-8'))
1217
raise errors.AlreadyBranchError(to_location)
1218
except errors.NoSuchFile:
1219
raise errors.BzrCommandError('Parent of "%s" does not exist.'
1222
# preserve whatever source format we have.
1223
dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1224
possible_transports=[to_transport],
1225
accelerator_tree=accelerator_tree,
1226
hardlink=hardlink, stacked=stacked,
1227
force_new_repo=standalone,
1228
create_tree_if_local=not no_tree,
1229
source_branch=br_from)
1230
branch = dir.open_branch()
1231
except errors.NoSuchRevision:
1232
to_transport.delete_tree('.')
1233
msg = "The branch %s has no revision %s." % (from_location,
1235
raise errors.BzrCommandError(msg)
1236
_merge_tags_if_possible(br_from, branch)
1237
# If the source branch is stacked, the new branch may
1238
# be stacked whether we asked for that explicitly or not.
1239
# We therefore need a try/except here and not just 'if stacked:'
1241
note('Created new stacked branch referring to %s.' %
1242
branch.get_stacked_on_url())
1243
except (errors.NotStacked, errors.UnstackableBranchFormat,
1244
errors.UnstackableRepositoryFormat), e:
1245
note('Branched %d revision(s).' % branch.revno())
1247
# Bind to the parent
1248
parent_branch = Branch.open(from_location)
1249
branch.bind(parent_branch)
1250
note('New branch bound to %s' % from_location)
1252
# Switch to the new branch
1253
wt, _ = WorkingTree.open_containing('.')
1254
_mod_switch.switch(wt.bzrdir, branch)
1255
note('Switched to branch: %s',
1256
urlutils.unescape_for_display(branch.base, 'utf-8'))
1270
1259
class cmd_checkout(Command):
1271
"""Create a new checkout of an existing branch.
1260
__doc__ = """Create a new checkout of an existing branch.
1273
1262
If BRANCH_LOCATION is omitted, checkout will reconstitute a working tree for
1274
1263
the branch found in '.'. This is useful if you have removed the working tree
1348
1342
@display_command
1349
1343
def run(self, dir=u'.'):
1350
1344
tree = WorkingTree.open_containing(dir)[0]
1353
new_inv = tree.inventory
1354
old_tree = tree.basis_tree()
1355
old_tree.lock_read()
1357
old_inv = old_tree.inventory
1359
iterator = tree.iter_changes(old_tree, include_unchanged=True)
1360
for f, paths, c, v, p, n, k, e in iterator:
1361
if paths[0] == paths[1]:
1365
renames.append(paths)
1367
for old_name, new_name in renames:
1368
self.outf.write("%s => %s\n" % (old_name, new_name))
1345
self.add_cleanup(tree.lock_read().unlock)
1346
new_inv = tree.inventory
1347
old_tree = tree.basis_tree()
1348
self.add_cleanup(old_tree.lock_read().unlock)
1349
old_inv = old_tree.inventory
1351
iterator = tree.iter_changes(old_tree, include_unchanged=True)
1352
for f, paths, c, v, p, n, k, e in iterator:
1353
if paths[0] == paths[1]:
1357
renames.append(paths)
1359
for old_name, new_name in renames:
1360
self.outf.write("%s => %s\n" % (old_name, new_name))
1375
1363
class cmd_update(Command):
1376
"""Update a tree to have the latest code committed to its branch.
1364
__doc__ = """Update a tree to have the latest code committed to its branch.
1378
1366
This will perform a merge into the working tree, and may generate
1379
1367
conflicts. If you have any local changes, you will still
1382
1370
If you want to discard your local changes, you can just do a
1383
1371
'bzr revert' instead of 'bzr commit' after the update.
1373
If you want to restore a file that has been removed locally, use
1374
'bzr revert' instead of 'bzr update'.
1376
If the tree's branch is bound to a master branch, it will also update
1377
the branch from the master.
1386
1380
_see_also = ['pull', 'working-trees', 'status-flags']
1387
1381
takes_args = ['dir?']
1382
takes_options = ['revision',
1384
help="Show base revision text in conflicts."),
1388
1386
aliases = ['up']
1390
def run(self, dir='.'):
1388
def run(self, dir='.', revision=None, show_base=None):
1389
if revision is not None and len(revision) != 1:
1390
raise errors.BzrCommandError(
1391
"bzr update --revision takes exactly one revision")
1391
1392
tree = WorkingTree.open_containing(dir)[0]
1393
branch = tree.branch
1392
1394
possible_transports = []
1393
master = tree.branch.get_master_branch(
1395
master = branch.get_master_branch(
1394
1396
possible_transports=possible_transports)
1395
1397
if master is not None:
1398
branch_location = master.base
1396
1399
tree.lock_write()
1401
branch_location = tree.branch.base
1398
1402
tree.lock_tree_write()
1403
self.add_cleanup(tree.unlock)
1404
# get rid of the final '/' and be ready for display
1405
branch_location = urlutils.unescape_for_display(
1406
branch_location.rstrip('/'),
1408
existing_pending_merges = tree.get_parent_ids()[1:]
1412
# may need to fetch data into a heavyweight checkout
1413
# XXX: this may take some time, maybe we should display a
1415
old_tip = branch.update(possible_transports)
1416
if revision is not None:
1417
revision_id = revision[0].as_revision_id(branch)
1419
revision_id = branch.last_revision()
1420
if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1421
revno = branch.revision_id_to_dotted_revno(revision_id)
1422
note("Tree is up to date at revision %s of branch %s" %
1423
('.'.join(map(str, revno)), branch_location))
1425
view_info = _get_view_info_for_change_reporter(tree)
1426
change_reporter = delta._ChangeReporter(
1427
unversioned_filter=tree.is_ignored,
1428
view_info=view_info)
1400
existing_pending_merges = tree.get_parent_ids()[1:]
1401
last_rev = _mod_revision.ensure_null(tree.last_revision())
1402
if last_rev == _mod_revision.ensure_null(
1403
tree.branch.last_revision()):
1404
# may be up to date, check master too.
1405
if master is None or last_rev == _mod_revision.ensure_null(
1406
master.last_revision()):
1407
revno = tree.branch.revision_id_to_revno(last_rev)
1408
note("Tree is up to date at revision %d." % (revno,))
1410
view_info = _get_view_info_for_change_reporter(tree)
1411
1430
conflicts = tree.update(
1412
delta._ChangeReporter(unversioned_filter=tree.is_ignored,
1413
view_info=view_info), possible_transports=possible_transports)
1414
revno = tree.branch.revision_id_to_revno(
1415
_mod_revision.ensure_null(tree.last_revision()))
1416
note('Updated to revision %d.' % (revno,))
1417
if tree.get_parent_ids()[1:] != existing_pending_merges:
1418
note('Your local commits will now show as pending merges with '
1419
"'bzr status', and can be committed with 'bzr commit'.")
1432
possible_transports=possible_transports,
1433
revision=revision_id,
1435
show_base=show_base)
1436
except errors.NoSuchRevision, e:
1437
raise errors.BzrCommandError(
1438
"branch has no revision %s\n"
1439
"bzr update --revision only works"
1440
" for a revision in the branch history"
1442
revno = tree.branch.revision_id_to_dotted_revno(
1443
_mod_revision.ensure_null(tree.last_revision()))
1444
note('Updated to revision %s of branch %s' %
1445
('.'.join(map(str, revno)), branch_location))
1446
parent_ids = tree.get_parent_ids()
1447
if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1448
note('Your local commits will now show as pending merges with '
1449
"'bzr status', and can be committed with 'bzr commit'.")
1428
1456
class cmd_info(Command):
1429
"""Show information about a working tree, branch or repository.
1457
__doc__ = """Show information about a working tree, branch or repository.
1431
1459
This command will show all known locations and formats associated to the
1432
1460
tree, branch or repository.
1483
1512
RegistryOption.from_kwargs('file-deletion-strategy',
1484
1513
'The file deletion mode to be used.',
1485
1514
title='Deletion Strategy', value_switches=True, enum_switch=False,
1486
safe='Only delete files if they can be'
1487
' safely recovered (default).',
1515
safe='Backup changed files (default).',
1488
1516
keep='Delete from bzr but leave the working copy.',
1517
no_backup='Don\'t backup changed files.',
1489
1518
force='Delete all the specified files, even if they can not be '
1490
'recovered and even if they are non-empty directories.')]
1519
'recovered and even if they are non-empty directories. '
1520
'(deprecated, use no-backup)')]
1491
1521
aliases = ['rm', 'del']
1492
1522
encoding_type = 'replace'
1494
1524
def run(self, file_list, verbose=False, new=False,
1495
1525
file_deletion_strategy='safe'):
1496
tree, file_list = tree_files(file_list)
1526
if file_deletion_strategy == 'force':
1527
note("(The --force option is deprecated, rather use --no-backup "
1529
file_deletion_strategy = 'no-backup'
1531
tree, file_list = WorkingTree.open_containing_paths(file_list)
1498
1533
if file_list is not None:
1499
1534
file_list = [f for f in file_list]
1503
# Heuristics should probably all move into tree.remove_smart or
1506
added = tree.changes_from(tree.basis_tree(),
1507
specific_files=file_list).added
1508
file_list = sorted([f[0] for f in added], reverse=True)
1509
if len(file_list) == 0:
1510
raise errors.BzrCommandError('No matching files.')
1511
elif file_list is None:
1512
# missing files show up in iter_changes(basis) as
1513
# versioned-with-no-kind.
1515
for change in tree.iter_changes(tree.basis_tree()):
1516
# Find paths in the working tree that have no kind:
1517
if change[1][1] is not None and change[6][1] is None:
1518
missing.append(change[1][1])
1519
file_list = sorted(missing, reverse=True)
1520
file_deletion_strategy = 'keep'
1521
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1522
keep_files=file_deletion_strategy=='keep',
1523
force=file_deletion_strategy=='force')
1536
self.add_cleanup(tree.lock_write().unlock)
1537
# Heuristics should probably all move into tree.remove_smart or
1540
added = tree.changes_from(tree.basis_tree(),
1541
specific_files=file_list).added
1542
file_list = sorted([f[0] for f in added], reverse=True)
1543
if len(file_list) == 0:
1544
raise errors.BzrCommandError('No matching files.')
1545
elif file_list is None:
1546
# missing files show up in iter_changes(basis) as
1547
# versioned-with-no-kind.
1549
for change in tree.iter_changes(tree.basis_tree()):
1550
# Find paths in the working tree that have no kind:
1551
if change[1][1] is not None and change[6][1] is None:
1552
missing.append(change[1][1])
1553
file_list = sorted(missing, reverse=True)
1554
file_deletion_strategy = 'keep'
1555
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1556
keep_files=file_deletion_strategy=='keep',
1557
force=(file_deletion_strategy=='no-backup'))
1528
1560
class cmd_file_id(Command):
1529
"""Print file_id of a particular file or directory.
1561
__doc__ = """Print file_id of a particular file or directory.
1531
1563
The file_id is assigned when the file is first added and remains the
1532
1564
same through all revisions where the file exists, even when it is
1907
1994
raise errors.BzrCommandError('bzr diff --revision takes exactly'
1908
1995
' one or two revision specifiers')
1910
old_tree, new_tree, specific_files, extra_trees = \
1911
_get_trees_to_diff(file_list, revision, old, new,
1997
if using is not None and format is not None:
1998
raise errors.BzrCommandError('--using and --format are mutually '
2001
(old_tree, new_tree,
2002
old_branch, new_branch,
2003
specific_files, extra_trees) = get_trees_and_branches_to_diff_locked(
2004
file_list, revision, old, new, self.add_cleanup, apply_view=True)
2005
# GNU diff on Windows uses ANSI encoding for filenames
2006
path_encoding = osutils.get_diff_header_encoding()
1913
2007
return show_diff_trees(old_tree, new_tree, sys.stdout,
1914
2008
specific_files=specific_files,
1915
2009
external_diff_options=diff_options,
1916
2010
old_label=old_label, new_label=new_label,
1917
extra_trees=extra_trees, using=using)
2011
extra_trees=extra_trees,
2012
path_encoding=path_encoding,
1920
2017
class cmd_deleted(Command):
1921
"""List files deleted in the working tree.
2018
__doc__ = """List files deleted in the working tree.
1923
2020
# TODO: Show files deleted since a previous revision, or
1924
2021
# between two revisions.
1927
2024
# level of effort but possibly much less IO. (Or possibly not,
1928
2025
# if the directories are very large...)
1929
2026
_see_also = ['status', 'ls']
1930
takes_options = ['show-ids']
2027
takes_options = ['directory', 'show-ids']
1932
2029
@display_command
1933
def run(self, show_ids=False):
1934
tree = WorkingTree.open_containing(u'.')[0]
1937
old = tree.basis_tree()
1940
for path, ie in old.inventory.iter_entries():
1941
if not tree.has_id(ie.file_id):
1942
self.outf.write(path)
1944
self.outf.write(' ')
1945
self.outf.write(ie.file_id)
1946
self.outf.write('\n')
2030
def run(self, show_ids=False, directory=u'.'):
2031
tree = WorkingTree.open_containing(directory)[0]
2032
self.add_cleanup(tree.lock_read().unlock)
2033
old = tree.basis_tree()
2034
self.add_cleanup(old.lock_read().unlock)
2035
for path, ie in old.inventory.iter_entries():
2036
if not tree.has_id(ie.file_id):
2037
self.outf.write(path)
2039
self.outf.write(' ')
2040
self.outf.write(ie.file_id)
2041
self.outf.write('\n')
1953
2044
class cmd_modified(Command):
1954
"""List files modified in working tree.
2045
__doc__ = """List files modified in working tree.
1958
2049
_see_also = ['status', 'ls']
1961
help='Write an ascii NUL (\\0) separator '
1962
'between files rather than a newline.')
2050
takes_options = ['directory', 'null']
1965
2052
@display_command
1966
def run(self, null=False):
1967
tree = WorkingTree.open_containing(u'.')[0]
2053
def run(self, null=False, directory=u'.'):
2054
tree = WorkingTree.open_containing(directory)[0]
1968
2055
td = tree.changes_from(tree.basis_tree())
1969
2056
for path, id, kind, text_modified, meta_modified in td.modified:
1976
2063
class cmd_added(Command):
1977
"""List files added in working tree.
2064
__doc__ = """List files added in working tree.
1981
2068
_see_also = ['status', 'ls']
1984
help='Write an ascii NUL (\\0) separator '
1985
'between files rather than a newline.')
2069
takes_options = ['directory', 'null']
1988
2071
@display_command
1989
def run(self, null=False):
1990
wt = WorkingTree.open_containing(u'.')[0]
1993
basis = wt.basis_tree()
1996
basis_inv = basis.inventory
1999
if file_id in basis_inv:
2001
if inv.is_root(file_id) and len(basis_inv) == 0:
2003
path = inv.id2path(file_id)
2004
if not os.access(osutils.abspath(path), os.F_OK):
2007
self.outf.write(path + '\0')
2009
self.outf.write(osutils.quotefn(path) + '\n')
2072
def run(self, null=False, directory=u'.'):
2073
wt = WorkingTree.open_containing(directory)[0]
2074
self.add_cleanup(wt.lock_read().unlock)
2075
basis = wt.basis_tree()
2076
self.add_cleanup(basis.lock_read().unlock)
2077
basis_inv = basis.inventory
2080
if file_id in basis_inv:
2082
if inv.is_root(file_id) and len(basis_inv) == 0:
2084
path = inv.id2path(file_id)
2085
if not os.access(osutils.pathjoin(wt.basedir, path), os.F_OK):
2088
self.outf.write(path + '\0')
2090
self.outf.write(osutils.quotefn(path) + '\n')
2016
2093
class cmd_root(Command):
2017
"""Show the tree root directory.
2094
__doc__ = """Show the tree root directory.
2019
2096
The root is the nearest enclosing directory with a .bzr control
2317
2408
diff_type = 'full'
2321
# Build the log formatter
2322
if log_format is None:
2323
log_format = log.log_formatter_registry.get_default(b)
2324
lf = log_format(show_ids=show_ids, to_file=self.outf,
2325
show_timezone=timezone,
2326
delta_format=get_verbosity_level(),
2328
show_advice=levels is None)
2330
# Choose the algorithm for doing the logging. It's annoying
2331
# having multiple code paths like this but necessary until
2332
# the underlying repository format is faster at generating
2333
# deltas or can provide everything we need from the indices.
2334
# The default algorithm - match-using-deltas - works for
2335
# multiple files and directories and is faster for small
2336
# amounts of history (200 revisions say). However, it's too
2337
# slow for logging a single file in a repository with deep
2338
# history, i.e. > 10K revisions. In the spirit of "do no
2339
# evil when adding features", we continue to use the
2340
# original algorithm - per-file-graph - for the "single
2341
# file that isn't a directory without showing a delta" case.
2342
partial_history = revision and b.repository._format.supports_chks
2343
match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2344
or delta_type or partial_history)
2346
# Build the LogRequest and execute it
2347
if len(file_ids) == 0:
2349
rqst = make_log_request_dict(
2350
direction=direction, specific_fileids=file_ids,
2351
start_revision=rev1, end_revision=rev2, limit=limit,
2352
message_search=message, delta_type=delta_type,
2353
diff_type=diff_type, _match_using_deltas=match_using_deltas)
2354
Logger(b, rqst).show(lf)
2410
# Build the log formatter
2411
if log_format is None:
2412
log_format = log.log_formatter_registry.get_default(b)
2413
# Make a non-encoding output to include the diffs - bug 328007
2414
unencoded_output = ui.ui_factory.make_output_stream(encoding_type='exact')
2415
lf = log_format(show_ids=show_ids, to_file=self.outf,
2416
to_exact_file=unencoded_output,
2417
show_timezone=timezone,
2418
delta_format=get_verbosity_level(),
2420
show_advice=levels is None,
2421
author_list_handler=authors)
2423
# Choose the algorithm for doing the logging. It's annoying
2424
# having multiple code paths like this but necessary until
2425
# the underlying repository format is faster at generating
2426
# deltas or can provide everything we need from the indices.
2427
# The default algorithm - match-using-deltas - works for
2428
# multiple files and directories and is faster for small
2429
# amounts of history (200 revisions say). However, it's too
2430
# slow for logging a single file in a repository with deep
2431
# history, i.e. > 10K revisions. In the spirit of "do no
2432
# evil when adding features", we continue to use the
2433
# original algorithm - per-file-graph - for the "single
2434
# file that isn't a directory without showing a delta" case.
2435
partial_history = revision and b.repository._format.supports_chks
2436
match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2437
or delta_type or partial_history)
2439
# Build the LogRequest and execute it
2440
if len(file_ids) == 0:
2442
rqst = make_log_request_dict(
2443
direction=direction, specific_fileids=file_ids,
2444
start_revision=rev1, end_revision=rev2, limit=limit,
2445
message_search=message, delta_type=delta_type,
2446
diff_type=diff_type, _match_using_deltas=match_using_deltas,
2447
exclude_common_ancestry=exclude_common_ancestry,
2449
Logger(b, rqst).show(lf)
2359
2452
def _get_revision_range(revisionspec_list, branch, command_name):
2442
2541
help='Recurse into subdirectories.'),
2443
2542
Option('from-root',
2444
2543
help='Print paths relative to the root of the branch.'),
2445
Option('unknown', help='Print unknown files.'),
2544
Option('unknown', short_name='u',
2545
help='Print unknown files.'),
2446
2546
Option('versioned', help='Print versioned files.',
2447
2547
short_name='V'),
2448
Option('ignored', help='Print ignored files.'),
2450
help='Write an ascii NUL (\\0) separator '
2451
'between files rather than a newline.'),
2548
Option('ignored', short_name='i',
2549
help='Print ignored files.'),
2550
Option('kind', short_name='k',
2453
2551
help='List entries of a particular kind: file, directory, symlink.',
2457
2557
@display_command
2458
2558
def run(self, revision=None, verbose=False,
2459
2559
recursive=False, from_root=False,
2460
2560
unknown=False, versioned=False, ignored=False,
2461
null=False, kind=None, show_ids=False, path=None):
2561
null=False, kind=None, show_ids=False, path=None, directory=None):
2463
2563
if kind and kind not in ('file', 'directory', 'symlink'):
2464
2564
raise errors.BzrCommandError('invalid kind specified')
2498
2598
view_str = views.view_display_str(view_files)
2499
2599
note("Ignoring files outside view. View is %s" % view_str)
2503
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2504
from_dir=relpath, recursive=recursive):
2505
# Apply additional masking
2506
if not all and not selection[fc]:
2508
if kind is not None and fkind != kind:
2513
fullpath = osutils.pathjoin(relpath, fp)
2516
views.check_path_in_view(tree, fullpath)
2517
except errors.FileOutsideView:
2601
self.add_cleanup(tree.lock_read().unlock)
2602
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2603
from_dir=relpath, recursive=recursive):
2604
# Apply additional masking
2605
if not all and not selection[fc]:
2607
if kind is not None and fkind != kind:
2612
fullpath = osutils.pathjoin(relpath, fp)
2615
views.check_path_in_view(tree, fullpath)
2616
except errors.FileOutsideView:
2522
fp = osutils.pathjoin(prefix, fp)
2523
kindch = entry.kind_character()
2524
outstring = fp + kindch
2525
ui.ui_factory.clear_term()
2527
outstring = '%-8s %s' % (fc, outstring)
2528
if show_ids and fid is not None:
2529
outstring = "%-50s %s" % (outstring, fid)
2621
fp = osutils.pathjoin(prefix, fp)
2622
kindch = entry.kind_character()
2623
outstring = fp + kindch
2624
ui.ui_factory.clear_term()
2626
outstring = '%-8s %s' % (fc, outstring)
2627
if show_ids and fid is not None:
2628
outstring = "%-50s %s" % (outstring, fid)
2629
self.outf.write(outstring + '\n')
2631
self.outf.write(fp + '\0')
2634
self.outf.write(fid)
2635
self.outf.write('\0')
2643
self.outf.write('%-50s %s\n' % (outstring, my_id))
2530
2645
self.outf.write(outstring + '\n')
2532
self.outf.write(fp + '\0')
2535
self.outf.write(fid)
2536
self.outf.write('\0')
2544
self.outf.write('%-50s %s\n' % (outstring, my_id))
2546
self.outf.write(outstring + '\n')
2551
2648
class cmd_unknowns(Command):
2552
"""List unknown files.
2649
__doc__ = """List unknown files.
2556
2653
_see_also = ['ls']
2654
takes_options = ['directory']
2558
2656
@display_command
2560
for f in WorkingTree.open_containing(u'.')[0].unknowns():
2657
def run(self, directory=u'.'):
2658
for f in WorkingTree.open_containing(directory)[0].unknowns():
2561
2659
self.outf.write(osutils.quotefn(f) + '\n')
2564
2662
class cmd_ignore(Command):
2565
"""Ignore specified files or patterns.
2663
__doc__ = """Ignore specified files or patterns.
2567
2665
See ``bzr help patterns`` for details on the syntax of patterns.
2667
If a .bzrignore file does not exist, the ignore command
2668
will create one and add the specified files or patterns to the newly
2669
created file. The ignore command will also automatically add the
2670
.bzrignore file to be versioned. Creating a .bzrignore file without
2671
the use of the ignore command will require an explicit add command.
2569
2673
To remove patterns from the ignore list, edit the .bzrignore file.
2570
2674
After adding, editing or deleting that file either indirectly by
2571
2675
using this command or directly by using an editor, be sure to commit
2574
Note: ignore patterns containing shell wildcards must be quoted from
2678
Bazaar also supports a global ignore file ~/.bazaar/ignore. On Windows
2679
the global ignore file can be found in the application data directory as
2680
C:\\Documents and Settings\\<user>\\Application Data\\Bazaar\\2.0\\ignore.
2681
Global ignores are not touched by this command. The global ignore file
2682
can be edited directly using an editor.
2684
Patterns prefixed with '!' are exceptions to ignore patterns and take
2685
precedence over regular ignores. Such exceptions are used to specify
2686
files that should be versioned which would otherwise be ignored.
2688
Patterns prefixed with '!!' act as regular ignore patterns, but have
2689
precedence over the '!' exception patterns.
2693
* Ignore patterns containing shell wildcards must be quoted from
2696
* Ignore patterns starting with "#" act as comments in the ignore file.
2697
To ignore patterns that begin with that character, use the "RE:" prefix.
2578
2700
Ignore the top level Makefile::
2580
2702
bzr ignore ./Makefile
2582
Ignore class files in all directories::
2704
Ignore .class files in all directories...::
2584
2706
bzr ignore "*.class"
2708
...but do not ignore "special.class"::
2710
bzr ignore "!special.class"
2712
Ignore files whose name begins with the "#" character::
2586
2716
Ignore .o files under the lib directory::
2588
2718
bzr ignore "lib/**/*.o"
2594
2724
Ignore everything but the "debian" toplevel directory::
2596
2726
bzr ignore "RE:(?!debian/).*"
2728
Ignore everything except the "local" toplevel directory,
2729
but always ignore "*~" autosave files, even under local/::
2732
bzr ignore "!./local"
2599
2736
_see_also = ['status', 'ignored', 'patterns']
2600
2737
takes_args = ['name_pattern*']
2602
Option('old-default-rules',
2603
help='Write out the ignore rules bzr < 0.9 always used.')
2738
takes_options = ['directory',
2739
Option('default-rules',
2740
help='Display the default ignore rules that bzr uses.')
2606
def run(self, name_pattern_list=None, old_default_rules=None):
2743
def run(self, name_pattern_list=None, default_rules=None,
2607
2745
from bzrlib import ignores
2608
if old_default_rules is not None:
2609
# dump the rules and exit
2610
for pattern in ignores.OLD_DEFAULTS:
2746
if default_rules is not None:
2747
# dump the default rules and exit
2748
for pattern in ignores.USER_DEFAULTS:
2749
self.outf.write("%s\n" % pattern)
2613
2751
if not name_pattern_list:
2614
2752
raise errors.BzrCommandError("ignore requires at least one "
2615
"NAME_PATTERN or --old-default-rules")
2753
"NAME_PATTERN or --default-rules.")
2616
2754
name_pattern_list = [globbing.normalize_pattern(p)
2617
2755
for p in name_pattern_list]
2757
for p in name_pattern_list:
2758
if not globbing.Globster.is_pattern_valid(p):
2759
bad_patterns += ('\n %s' % p)
2761
msg = ('Invalid ignore pattern(s) found. %s' % bad_patterns)
2762
ui.ui_factory.show_error(msg)
2763
raise errors.InvalidPattern('')
2618
2764
for name_pattern in name_pattern_list:
2619
2765
if (name_pattern[0] == '/' or
2620
2766
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2621
2767
raise errors.BzrCommandError(
2622
2768
"NAME_PATTERN should not be an absolute path")
2623
tree, relpath = WorkingTree.open_containing(u'.')
2769
tree, relpath = WorkingTree.open_containing(directory)
2624
2770
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2625
2771
ignored = globbing.Globster(name_pattern_list)
2773
self.add_cleanup(tree.lock_read().unlock)
2628
2774
for entry in tree.list_files():
2630
2776
if id is not None:
2631
2777
filename = entry[0]
2632
2778
if ignored.match(filename):
2633
matches.append(filename.encode('utf-8'))
2779
matches.append(filename)
2635
2780
if len(matches) > 0:
2636
print "Warning: the following files are version controlled and" \
2637
" match your ignore pattern:\n%s" \
2638
"\nThese files will continue to be version controlled" \
2639
" unless you 'bzr remove' them." % ("\n".join(matches),)
2781
self.outf.write("Warning: the following files are version controlled and"
2782
" match your ignore pattern:\n%s"
2783
"\nThese files will continue to be version controlled"
2784
" unless you 'bzr remove' them.\n" % ("\n".join(matches),))
2642
2787
class cmd_ignored(Command):
2643
"""List ignored files and the patterns that matched them.
2788
__doc__ = """List ignored files and the patterns that matched them.
2645
2790
List all the ignored files and the ignore pattern that caused the file to
2653
2798
encoding_type = 'replace'
2654
2799
_see_also = ['ignore', 'ls']
2800
takes_options = ['directory']
2656
2802
@display_command
2658
tree = WorkingTree.open_containing(u'.')[0]
2661
for path, file_class, kind, file_id, entry in tree.list_files():
2662
if file_class != 'I':
2664
## XXX: Slightly inefficient since this was already calculated
2665
pat = tree.is_ignored(path)
2666
self.outf.write('%-50s %s\n' % (path, pat))
2803
def run(self, directory=u'.'):
2804
tree = WorkingTree.open_containing(directory)[0]
2805
self.add_cleanup(tree.lock_read().unlock)
2806
for path, file_class, kind, file_id, entry in tree.list_files():
2807
if file_class != 'I':
2809
## XXX: Slightly inefficient since this was already calculated
2810
pat = tree.is_ignored(path)
2811
self.outf.write('%-50s %s\n' % (path, pat))
2671
2814
class cmd_lookup_revision(Command):
2672
"""Lookup the revision-id from a revision-number
2815
__doc__ = """Lookup the revision-id from a revision-number
2675
2818
bzr lookup-revision 33
2678
2821
takes_args = ['revno']
2822
takes_options = ['directory']
2680
2824
@display_command
2681
def run(self, revno):
2825
def run(self, revno, directory=u'.'):
2683
2827
revno = int(revno)
2684
2828
except ValueError:
2685
raise errors.BzrCommandError("not a valid revision-number: %r" % revno)
2687
print WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
2829
raise errors.BzrCommandError("not a valid revision-number: %r"
2831
revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
2832
self.outf.write("%s\n" % revid)
2690
2835
class cmd_export(Command):
2691
"""Export current or past revision to a destination directory or archive.
2836
__doc__ = """Export current or past revision to a destination directory or archive.
2693
2838
If no revision is specified this exports the last committed revision.
2768
2917
@display_command
2769
2918
def run(self, filename, revision=None, name_from_revision=False,
2919
filters=False, directory=None):
2771
2920
if revision is not None and len(revision) != 1:
2772
2921
raise errors.BzrCommandError("bzr cat --revision takes exactly"
2773
2922
" one revision specifier")
2774
2923
tree, branch, relpath = \
2775
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
2778
return self._run(tree, branch, relpath, filename, revision,
2779
name_from_revision, filters)
2924
_open_directory_or_containing_tree_or_branch(filename, directory)
2925
self.add_cleanup(branch.lock_read().unlock)
2926
return self._run(tree, branch, relpath, filename, revision,
2927
name_from_revision, filters)
2783
2929
def _run(self, tree, b, relpath, filename, revision, name_from_revision,
2785
2931
if tree is None:
2786
2932
tree = b.basis_tree()
2787
2933
rev_tree = _get_one_revision_tree('cat', revision, branch=b)
2934
self.add_cleanup(rev_tree.lock_read().unlock)
2789
2936
old_file_id = rev_tree.path2id(relpath)
3015
3175
if local and not tree.branch.get_bound_location():
3016
3176
raise errors.LocalRequiresBoundBranch()
3178
if message is not None:
3180
file_exists = osutils.lexists(message)
3181
except UnicodeError:
3182
# The commit message contains unicode characters that can't be
3183
# represented in the filesystem encoding, so that can't be a
3188
'The commit message is a file name: "%(f)s".\n'
3189
'(use --file "%(f)s" to take commit message from that file)'
3191
ui.ui_factory.show_warning(warning_msg)
3193
message = message.replace('\r\n', '\n')
3194
message = message.replace('\r', '\n')
3196
raise errors.BzrCommandError(
3197
"please specify either --message or --file")
3018
3199
def get_message(commit_obj):
3019
3200
"""Callback to get commit message"""
3020
my_message = message
3021
if my_message is None and not file:
3022
t = make_commit_message_template_encoded(tree,
3204
my_message = f.read().decode(osutils.get_user_encoding())
3207
elif message is not None:
3208
my_message = message
3210
# No message supplied: make one up.
3211
# text is the status of the tree
3212
text = make_commit_message_template_encoded(tree,
3023
3213
selected_list, diff=show_diff,
3024
3214
output_encoding=osutils.get_user_encoding())
3215
# start_message is the template generated from hooks
3216
# XXX: Warning - looks like hooks return unicode,
3217
# make_commit_message_template_encoded returns user encoding.
3218
# We probably want to be using edit_commit_message instead to
3025
3220
start_message = generate_commit_message_template(commit_obj)
3026
my_message = edit_commit_message_encoded(t,
3221
my_message = edit_commit_message_encoded(text,
3027
3222
start_message=start_message)
3028
3223
if my_message is None:
3029
3224
raise errors.BzrCommandError("please specify a commit"
3030
3225
" message with either --message or --file")
3031
elif my_message and file:
3032
raise errors.BzrCommandError(
3033
"please specify either --message or --file")
3035
my_message = codecs.open(file, 'rt',
3036
osutils.get_user_encoding()).read()
3037
3226
if my_message == "":
3038
3227
raise errors.BzrCommandError("empty commit message specified")
3039
3228
return my_message
3425
3628
def run(self, testspecs_list=None, verbose=False, one=False,
3426
3629
transport=None, benchmark=None,
3427
lsprof_timed=None, cache_dir=None,
3428
3631
first=False, list_only=False,
3429
3632
randomize=None, exclude=None, strict=False,
3430
3633
load_list=None, debugflag=None, starting_with=None, subunit=False,
3432
from bzrlib.tests import selftest
3433
import bzrlib.benchmarks as benchmarks
3434
from bzrlib.benchmarks import tree_creator
3436
# Make deprecation warnings visible, unless -Werror is set
3437
symbol_versioning.activate_deprecation_warnings(override=False)
3439
if cache_dir is not None:
3440
tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
3634
parallel=None, lsprof_tests=False):
3635
from bzrlib import tests
3441
3637
if testspecs_list is not None:
3442
3638
pattern = '|'.join(testspecs_list)
3449
3645
raise errors.BzrCommandError("subunit not available. subunit "
3450
3646
"needs to be installed to use --subunit.")
3451
3647
self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3648
# On Windows, disable automatic conversion of '\n' to '\r\n' in
3649
# stdout, which would corrupt the subunit stream.
3650
# FIXME: This has been fixed in subunit trunk (>0.0.5) so the
3651
# following code can be deleted when it's sufficiently deployed
3652
# -- vila/mgz 20100514
3653
if (sys.platform == "win32"
3654
and getattr(sys.stdout, 'fileno', None) is not None):
3656
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
3453
3658
self.additional_selftest_args.setdefault(
3454
3659
'suite_decorators', []).append(parallel)
3456
test_suite_factory = benchmarks.test_suite
3457
# Unless user explicitly asks for quiet, be verbose in benchmarks
3458
verbose = not is_quiet()
3459
# TODO: should possibly lock the history file...
3460
benchfile = open(".perf_history", "at", buffering=1)
3462
test_suite_factory = None
3661
raise errors.BzrCommandError(
3662
"--benchmark is no longer supported from bzr 2.2; "
3663
"use bzr-usertest instead")
3664
test_suite_factory = None
3665
selftest_kwargs = {"verbose": verbose,
3667
"stop_on_failure": one,
3668
"transport": transport,
3669
"test_suite_factory": test_suite_factory,
3670
"lsprof_timed": lsprof_timed,
3671
"lsprof_tests": lsprof_tests,
3672
"matching_tests_first": first,
3673
"list_only": list_only,
3674
"random_seed": randomize,
3675
"exclude_pattern": exclude,
3677
"load_list": load_list,
3678
"debug_flags": debugflag,
3679
"starting_with": starting_with
3681
selftest_kwargs.update(self.additional_selftest_args)
3683
# Make deprecation warnings visible, unless -Werror is set
3684
cleanup = symbol_versioning.activate_deprecation_warnings(
3465
selftest_kwargs = {"verbose": verbose,
3467
"stop_on_failure": one,
3468
"transport": transport,
3469
"test_suite_factory": test_suite_factory,
3470
"lsprof_timed": lsprof_timed,
3471
"bench_history": benchfile,
3472
"matching_tests_first": first,
3473
"list_only": list_only,
3474
"random_seed": randomize,
3475
"exclude_pattern": exclude,
3477
"load_list": load_list,
3478
"debug_flags": debugflag,
3479
"starting_with": starting_with
3481
selftest_kwargs.update(self.additional_selftest_args)
3482
result = selftest(**selftest_kwargs)
3687
result = tests.selftest(**selftest_kwargs)
3484
if benchfile is not None:
3486
3690
return int(not result)
3489
3693
class cmd_version(Command):
3490
"""Show version of bzr."""
3694
__doc__ = """Show version of bzr."""
3492
3696
encoding_type = 'replace'
3493
3697
takes_options = [
3527
3731
branch1 = Branch.open_containing(branch)[0]
3528
3732
branch2 = Branch.open_containing(other)[0]
3533
last1 = ensure_null(branch1.last_revision())
3534
last2 = ensure_null(branch2.last_revision())
3536
graph = branch1.repository.get_graph(branch2.repository)
3537
base_rev_id = graph.find_unique_lca(last1, last2)
3539
print 'merge base is revision %s' % base_rev_id
3733
self.add_cleanup(branch1.lock_read().unlock)
3734
self.add_cleanup(branch2.lock_read().unlock)
3735
last1 = ensure_null(branch1.last_revision())
3736
last2 = ensure_null(branch2.last_revision())
3738
graph = branch1.repository.get_graph(branch2.repository)
3739
base_rev_id = graph.find_unique_lca(last1, last2)
3741
self.outf.write('merge base is revision %s\n' % base_rev_id)
3546
3744
class cmd_merge(Command):
3547
"""Perform a three-way merge.
3745
__doc__ = """Perform a three-way merge.
3549
3747
The source of the merge can be specified either in the form of a branch,
3550
3748
or in the form of a path to a file containing a merge directive generated
3551
3749
with bzr send. If neither is specified, the default is the upstream branch
3552
3750
or the branch most recently merged using --remember.
3554
When merging a branch, by default the tip will be merged. To pick a different
3555
revision, pass --revision. If you specify two values, the first will be used as
3556
BASE and the second one as OTHER. Merging individual revisions, or a subset of
3557
available revisions, like this is commonly referred to as "cherrypicking".
3559
Revision numbers are always relative to the branch being merged.
3561
By default, bzr will try to merge in all new work from the other
3562
branch, automatically determining an appropriate base. If this
3563
fails, you may need to give an explicit base.
3752
When merging from a branch, by default bzr will try to merge in all new
3753
work from the other branch, automatically determining an appropriate base
3754
revision. If this fails, you may need to give an explicit base.
3756
To pick a different ending revision, pass "--revision OTHER". bzr will
3757
try to merge in all new work up to and including revision OTHER.
3759
If you specify two values, "--revision BASE..OTHER", only revisions BASE
3760
through OTHER, excluding BASE but including OTHER, will be merged. If this
3761
causes some revisions to be skipped, i.e. if the destination branch does
3762
not already contain revision BASE, such a merge is commonly referred to as
3765
Revision numbers are always relative to the source branch.
3565
3767
Merge will do its best to combine the changes in two branches, but there
3566
3768
are some kinds of problems only a human can fix. When it encounters those,
3650
3861
verified = 'inapplicable'
3651
3862
tree = WorkingTree.open_containing(directory)[0]
3653
# die as quickly as possible if there are uncommitted changes
3655
3865
basis_tree = tree.revision_tree(tree.last_revision())
3656
3866
except errors.NoSuchRevision:
3657
3867
basis_tree = tree.basis_tree()
3869
# die as quickly as possible if there are uncommitted changes
3659
if tree.has_changes(basis_tree):
3871
if tree.has_changes():
3660
3872
raise errors.UncommittedChanges(tree)
3662
3874
view_info = _get_view_info_for_change_reporter(tree)
3663
3875
change_reporter = delta._ChangeReporter(
3664
3876
unversioned_filter=tree.is_ignored, view_info=view_info)
3667
pb = ui.ui_factory.nested_progress_bar()
3668
cleanups.append(pb.finished)
3670
cleanups.append(tree.unlock)
3671
if location is not None:
3673
mergeable = bundle.read_mergeable_from_url(location,
3674
possible_transports=possible_transports)
3675
except errors.NotABundle:
3679
raise errors.BzrCommandError('Cannot use --uncommitted'
3680
' with bundles or merge directives.')
3682
if revision is not None:
3683
raise errors.BzrCommandError(
3684
'Cannot use -r with merge directives or bundles')
3685
merger, verified = _mod_merge.Merger.from_mergeable(tree,
3688
if merger is None and uncommitted:
3689
if revision is not None and len(revision) > 0:
3690
raise errors.BzrCommandError('Cannot use --uncommitted and'
3691
' --revision at the same time.')
3692
merger = self.get_merger_from_uncommitted(tree, location, pb,
3694
allow_pending = False
3697
merger, allow_pending = self._get_merger_from_branch(tree,
3698
location, revision, remember, possible_transports, pb)
3700
merger.merge_type = merge_type
3701
merger.reprocess = reprocess
3702
merger.show_base = show_base
3703
self.sanity_check_merger(merger)
3704
if (merger.base_rev_id == merger.other_rev_id and
3705
merger.other_rev_id is not None):
3706
note('Nothing to do.')
3877
pb = ui.ui_factory.nested_progress_bar()
3878
self.add_cleanup(pb.finished)
3879
self.add_cleanup(tree.lock_write().unlock)
3880
if location is not None:
3882
mergeable = bundle.read_mergeable_from_url(location,
3883
possible_transports=possible_transports)
3884
except errors.NotABundle:
3888
raise errors.BzrCommandError('Cannot use --uncommitted'
3889
' with bundles or merge directives.')
3891
if revision is not None:
3892
raise errors.BzrCommandError(
3893
'Cannot use -r with merge directives or bundles')
3894
merger, verified = _mod_merge.Merger.from_mergeable(tree,
3897
if merger is None and uncommitted:
3898
if revision is not None and len(revision) > 0:
3899
raise errors.BzrCommandError('Cannot use --uncommitted and'
3900
' --revision at the same time.')
3901
merger = self.get_merger_from_uncommitted(tree, location, None)
3902
allow_pending = False
3905
merger, allow_pending = self._get_merger_from_branch(tree,
3906
location, revision, remember, possible_transports, None)
3908
merger.merge_type = merge_type
3909
merger.reprocess = reprocess
3910
merger.show_base = show_base
3911
self.sanity_check_merger(merger)
3912
if (merger.base_rev_id == merger.other_rev_id and
3913
merger.other_rev_id is not None):
3914
note('Nothing to do.')
3917
if merger.interesting_files is not None:
3918
raise errors.BzrCommandError('Cannot pull individual files')
3919
if (merger.base_rev_id == tree.last_revision()):
3920
result = tree.pull(merger.other_branch, False,
3921
merger.other_rev_id)
3922
result.report(self.outf)
3709
if merger.interesting_files is not None:
3710
raise errors.BzrCommandError('Cannot pull individual files')
3711
if (merger.base_rev_id == tree.last_revision()):
3712
result = tree.pull(merger.other_branch, False,
3713
merger.other_rev_id)
3714
result.report(self.outf)
3716
merger.check_basis(False)
3718
return self._do_preview(merger, cleanups)
3720
return self._do_interactive(merger, cleanups)
3722
return self._do_merge(merger, change_reporter, allow_pending,
3725
for cleanup in reversed(cleanups):
3924
if merger.this_basis is None:
3925
raise errors.BzrCommandError(
3926
"This branch has no commits."
3927
" (perhaps you would prefer 'bzr pull')")
3929
return self._do_preview(merger)
3931
return self._do_interactive(merger)
3933
return self._do_merge(merger, change_reporter, allow_pending,
3728
def _get_preview(self, merger, cleanups):
3936
def _get_preview(self, merger):
3729
3937
tree_merger = merger.make_merger()
3730
3938
tt = tree_merger.make_preview_transform()
3731
cleanups.append(tt.finalize)
3939
self.add_cleanup(tt.finalize)
3732
3940
result_tree = tt.get_preview_tree()
3733
3941
return result_tree
3735
def _do_preview(self, merger, cleanups):
3943
def _do_preview(self, merger):
3736
3944
from bzrlib.diff import show_diff_trees
3737
result_tree = self._get_preview(merger, cleanups)
3945
result_tree = self._get_preview(merger)
3946
path_encoding = osutils.get_diff_header_encoding()
3738
3947
show_diff_trees(merger.this_tree, result_tree, self.outf,
3739
old_label='', new_label='')
3948
old_label='', new_label='',
3949
path_encoding=path_encoding)
3741
3951
def _do_merge(self, merger, change_reporter, allow_pending, verified):
3742
3952
merger.change_reporter = change_reporter
3926
4139
def run(self, file_list=None, merge_type=None, show_base=False,
3927
4140
reprocess=False):
4141
from bzrlib.conflicts import restore
3928
4142
if merge_type is None:
3929
4143
merge_type = _mod_merge.Merge3Merger
3930
tree, file_list = tree_files(file_list)
3933
parents = tree.get_parent_ids()
3934
if len(parents) != 2:
3935
raise errors.BzrCommandError("Sorry, remerge only works after normal"
3936
" merges. Not cherrypicking or"
3938
repository = tree.branch.repository
3939
interesting_ids = None
3941
conflicts = tree.conflicts()
3942
if file_list is not None:
3943
interesting_ids = set()
3944
for filename in file_list:
3945
file_id = tree.path2id(filename)
3947
raise errors.NotVersionedError(filename)
3948
interesting_ids.add(file_id)
3949
if tree.kind(file_id) != "directory":
4144
tree, file_list = WorkingTree.open_containing_paths(file_list)
4145
self.add_cleanup(tree.lock_write().unlock)
4146
parents = tree.get_parent_ids()
4147
if len(parents) != 2:
4148
raise errors.BzrCommandError("Sorry, remerge only works after normal"
4149
" merges. Not cherrypicking or"
4151
repository = tree.branch.repository
4152
interesting_ids = None
4154
conflicts = tree.conflicts()
4155
if file_list is not None:
4156
interesting_ids = set()
4157
for filename in file_list:
4158
file_id = tree.path2id(filename)
4160
raise errors.NotVersionedError(filename)
4161
interesting_ids.add(file_id)
4162
if tree.kind(file_id) != "directory":
3952
for name, ie in tree.inventory.iter_entries(file_id):
3953
interesting_ids.add(ie.file_id)
3954
new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
3956
# Remerge only supports resolving contents conflicts
3957
allowed_conflicts = ('text conflict', 'contents conflict')
3958
restore_files = [c.path for c in conflicts
3959
if c.typestring in allowed_conflicts]
3960
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
3961
tree.set_conflicts(ConflictList(new_conflicts))
3962
if file_list is not None:
3963
restore_files = file_list
3964
for filename in restore_files:
3966
restore(tree.abspath(filename))
3967
except errors.NotConflicted:
3969
# Disable pending merges, because the file texts we are remerging
3970
# have not had those merges performed. If we use the wrong parents
3971
# list, we imply that the working tree text has seen and rejected
3972
# all the changes from the other tree, when in fact those changes
3973
# have not yet been seen.
3974
pb = ui.ui_factory.nested_progress_bar()
3975
tree.set_parent_ids(parents[:1])
4165
for name, ie in tree.inventory.iter_entries(file_id):
4166
interesting_ids.add(ie.file_id)
4167
new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
4169
# Remerge only supports resolving contents conflicts
4170
allowed_conflicts = ('text conflict', 'contents conflict')
4171
restore_files = [c.path for c in conflicts
4172
if c.typestring in allowed_conflicts]
4173
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
4174
tree.set_conflicts(ConflictList(new_conflicts))
4175
if file_list is not None:
4176
restore_files = file_list
4177
for filename in restore_files:
3977
merger = _mod_merge.Merger.from_revision_ids(pb,
3979
merger.interesting_ids = interesting_ids
3980
merger.merge_type = merge_type
3981
merger.show_base = show_base
3982
merger.reprocess = reprocess
3983
conflicts = merger.do_merge()
3985
tree.set_parent_ids(parents)
4179
restore(tree.abspath(filename))
4180
except errors.NotConflicted:
4182
# Disable pending merges, because the file texts we are remerging
4183
# have not had those merges performed. If we use the wrong parents
4184
# list, we imply that the working tree text has seen and rejected
4185
# all the changes from the other tree, when in fact those changes
4186
# have not yet been seen.
4187
tree.set_parent_ids(parents[:1])
4189
merger = _mod_merge.Merger.from_revision_ids(None, tree, parents[1])
4190
merger.interesting_ids = interesting_ids
4191
merger.merge_type = merge_type
4192
merger.show_base = show_base
4193
merger.reprocess = reprocess
4194
conflicts = merger.do_merge()
4196
tree.set_parent_ids(parents)
3989
4197
if conflicts > 0:
4013
4222
name. If you name a directory, all the contents of that directory will be
4016
Any files that have been newly added since that revision will be deleted,
4017
with a backup kept if appropriate. Directories containing unknown files
4018
will not be deleted.
4225
If you have newly added files since the target revision, they will be
4226
removed. If the files to be removed have been changed, backups will be
4227
created as above. Directories containing unknown files will not be
4020
The working tree contains a list of pending merged revisions, which will
4021
be included as parents in the next commit. Normally, revert clears that
4022
list as well as reverting the files. If any files are specified, revert
4023
leaves the pending merge list alone and reverts only the files. Use "bzr
4024
revert ." in the tree root to revert all files but keep the merge record,
4025
and "bzr revert --forget-merges" to clear the pending merge list without
4230
The working tree contains a list of revisions that have been merged but
4231
not yet committed. These revisions will be included as additional parents
4232
of the next commit. Normally, using revert clears that list as well as
4233
reverting the files. If any files are specified, revert leaves the list
4234
of uncommitted merges alone and reverts only the files. Use ``bzr revert
4235
.`` in the tree root to revert all files but keep the recorded merges,
4236
and ``bzr revert --forget-merges`` to clear the pending merge list without
4026
4237
reverting any files.
4239
Using "bzr revert --forget-merges", it is possible to apply all of the
4240
changes from a branch in a single revision. To do this, perform the merge
4241
as desired. Then doing revert with the "--forget-merges" option will keep
4242
the content of the tree as it was, but it will clear the list of pending
4243
merges. The next commit will then contain all of the changes that are
4244
present in the other branch, but without any other parent revisions.
4245
Because this technique forgets where these changes originated, it may
4246
cause additional conflicts on later merges involving the same source and
4029
_see_also = ['cat', 'export']
4250
_see_also = ['cat', 'export', 'merge', 'shelve']
4030
4251
takes_options = [
4032
4253
Option('no-backup', "Do not save backups of reverted files."),
4038
4259
def run(self, revision=None, no_backup=False, file_list=None,
4039
4260
forget_merges=None):
4040
tree, file_list = tree_files(file_list)
4044
tree.set_parent_ids(tree.get_parent_ids()[:1])
4046
self._revert_tree_to_revision(tree, revision, file_list, no_backup)
4261
tree, file_list = WorkingTree.open_containing_paths(file_list)
4262
self.add_cleanup(tree.lock_tree_write().unlock)
4264
tree.set_parent_ids(tree.get_parent_ids()[:1])
4266
self._revert_tree_to_revision(tree, revision, file_list, no_backup)
4051
4269
def _revert_tree_to_revision(tree, revision, file_list, no_backup):
4052
4270
rev_tree = _get_one_revision_tree('revert', revision, tree=tree)
4053
pb = ui.ui_factory.nested_progress_bar()
4055
tree.revert(file_list, rev_tree, not no_backup, pb,
4056
report_changes=True)
4271
tree.revert(file_list, rev_tree, not no_backup, None,
4272
report_changes=True)
4061
4275
class cmd_assert_fail(Command):
4062
"""Test reporting of assertion failures"""
4276
__doc__ = """Test reporting of assertion failures"""
4063
4277
# intended just for use in testing
4206
4430
_get_revision_range(revision,
4207
4431
remote_branch, self.name()))
4209
local_branch.lock_read()
4211
remote_branch.lock_read()
4213
local_extra, remote_extra = find_unmerged(
4214
local_branch, remote_branch, restrict,
4215
backward=not reverse,
4216
include_merges=include_merges,
4217
local_revid_range=local_revid_range,
4218
remote_revid_range=remote_revid_range)
4220
if log_format is None:
4221
registry = log.log_formatter_registry
4222
log_format = registry.get_default(local_branch)
4223
lf = log_format(to_file=self.outf,
4225
show_timezone='original')
4228
if local_extra and not theirs_only:
4229
message("You have %d extra revision(s):\n" %
4231
for revision in iter_log_revisions(local_extra,
4232
local_branch.repository,
4234
lf.log_revision(revision)
4235
printed_local = True
4238
printed_local = False
4240
if remote_extra and not mine_only:
4241
if printed_local is True:
4243
message("You are missing %d revision(s):\n" %
4245
for revision in iter_log_revisions(remote_extra,
4246
remote_branch.repository,
4248
lf.log_revision(revision)
4251
if mine_only and not local_extra:
4252
# We checked local, and found nothing extra
4253
message('This branch is up to date.\n')
4254
elif theirs_only and not remote_extra:
4255
# We checked remote, and found nothing extra
4256
message('Other branch is up to date.\n')
4257
elif not (mine_only or theirs_only or local_extra or
4259
# We checked both branches, and neither one had extra
4261
message("Branches are up to date.\n")
4263
remote_branch.unlock()
4265
local_branch.unlock()
4433
local_extra, remote_extra = find_unmerged(
4434
local_branch, remote_branch, restrict,
4435
backward=not reverse,
4436
include_merges=include_merges,
4437
local_revid_range=local_revid_range,
4438
remote_revid_range=remote_revid_range)
4440
if log_format is None:
4441
registry = log.log_formatter_registry
4442
log_format = registry.get_default(local_branch)
4443
lf = log_format(to_file=self.outf,
4445
show_timezone='original')
4448
if local_extra and not theirs_only:
4449
message("You have %d extra revision(s):\n" %
4451
for revision in iter_log_revisions(local_extra,
4452
local_branch.repository,
4454
lf.log_revision(revision)
4455
printed_local = True
4458
printed_local = False
4460
if remote_extra and not mine_only:
4461
if printed_local is True:
4463
message("You are missing %d revision(s):\n" %
4465
for revision in iter_log_revisions(remote_extra,
4466
remote_branch.repository,
4468
lf.log_revision(revision)
4471
if mine_only and not local_extra:
4472
# We checked local, and found nothing extra
4473
message('This branch is up to date.\n')
4474
elif theirs_only and not remote_extra:
4475
# We checked remote, and found nothing extra
4476
message('Other branch is up to date.\n')
4477
elif not (mine_only or theirs_only or local_extra or
4479
# We checked both branches, and neither one had extra
4481
message("Branches are up to date.\n")
4266
4483
if not status_code and parent is None and other_branch is not None:
4267
local_branch.lock_write()
4269
# handle race conditions - a parent might be set while we run.
4270
if local_branch.get_parent() is None:
4271
local_branch.set_parent(remote_branch.base)
4273
local_branch.unlock()
4484
self.add_cleanup(local_branch.lock_write().unlock)
4485
# handle race conditions - a parent might be set while we run.
4486
if local_branch.get_parent() is None:
4487
local_branch.set_parent(remote_branch.base)
4274
4488
return status_code
4277
4491
class cmd_pack(Command):
4278
"""Compress the data within a repository."""
4492
__doc__ = """Compress the data within a repository.
4494
This operation compresses the data within a bazaar repository. As
4495
bazaar supports automatic packing of repository, this operation is
4496
normally not required to be done manually.
4498
During the pack operation, bazaar takes a backup of existing repository
4499
data, i.e. pack files. This backup is eventually removed by bazaar
4500
automatically when it is safe to do so. To save disk space by removing
4501
the backed up pack files, the --clean-obsolete-packs option may be
4504
Warning: If you use --clean-obsolete-packs and your machine crashes
4505
during or immediately after repacking, you may be left with a state
4506
where the deletion has been written to disk but the new packs have not
4507
been. In this case the repository may be unusable.
4280
4510
_see_also = ['repositories']
4281
4511
takes_args = ['branch_or_repo?']
4513
Option('clean-obsolete-packs', 'Delete obsolete packs to save disk space.'),
4283
def run(self, branch_or_repo='.'):
4516
def run(self, branch_or_repo='.', clean_obsolete_packs=False):
4284
4517
dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
4286
4519
branch = dir.open_branch()
4287
4520
repository = branch.repository
4288
4521
except errors.NotBranchError:
4289
4522
repository = dir.open_repository()
4523
repository.pack(clean_obsolete_packs=clean_obsolete_packs)
4293
4526
class cmd_plugins(Command):
4294
"""List the installed plugins.
4527
__doc__ = """List the installed plugins.
4296
4529
This command displays the list of installed plugins including
4297
4530
version of plugin and a short description of each.
4387
4617
Option('long', help='Show commit date in annotations.'),
4391
4622
encoding_type = 'exact'
4393
4624
@display_command
4394
4625
def run(self, filename, all=False, long=False, revision=None,
4626
show_ids=False, directory=None):
4396
4627
from bzrlib.annotate import annotate_file, annotate_file_tree
4397
4628
wt, branch, relpath = \
4398
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
4404
tree = _get_one_revision_tree('annotate', revision, branch=branch)
4406
file_id = wt.path2id(relpath)
4408
file_id = tree.path2id(relpath)
4410
raise errors.NotVersionedError(filename)
4411
file_version = tree.inventory[file_id].revision
4412
if wt is not None and revision is None:
4413
# If there is a tree and we're not annotating historical
4414
# versions, annotate the working tree's content.
4415
annotate_file_tree(wt, file_id, self.outf, long, all,
4418
annotate_file(branch, file_version, file_id, long, all, self.outf,
4629
_open_directory_or_containing_tree_or_branch(filename, directory)
4631
self.add_cleanup(wt.lock_read().unlock)
4633
self.add_cleanup(branch.lock_read().unlock)
4634
tree = _get_one_revision_tree('annotate', revision, branch=branch)
4635
self.add_cleanup(tree.lock_read().unlock)
4637
file_id = wt.path2id(relpath)
4639
file_id = tree.path2id(relpath)
4641
raise errors.NotVersionedError(filename)
4642
file_version = tree.inventory[file_id].revision
4643
if wt is not None and revision is None:
4644
# If there is a tree and we're not annotating historical
4645
# versions, annotate the working tree's content.
4646
annotate_file_tree(wt, file_id, self.outf, long, all,
4649
annotate_file(branch, file_version, file_id, long, all, self.outf,
4427
4653
class cmd_re_sign(Command):
4428
"""Create a digital signature for an existing revision."""
4654
__doc__ = """Create a digital signature for an existing revision."""
4429
4655
# TODO be able to replace existing ones.
4431
4657
hidden = True # is this right ?
4432
4658
takes_args = ['revision_id*']
4433
takes_options = ['revision']
4659
takes_options = ['directory', 'revision']
4435
def run(self, revision_id_list=None, revision=None):
4661
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4436
4662
if revision_id_list is not None and revision is not None:
4437
4663
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4438
4664
if revision_id_list is None and revision is None:
4439
4665
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4440
b = WorkingTree.open_containing(u'.')[0].branch
4443
return self._run(b, revision_id_list, revision)
4666
b = WorkingTree.open_containing(directory)[0].branch
4667
self.add_cleanup(b.lock_write().unlock)
4668
return self._run(b, revision_id_list, revision)
4447
4670
def _run(self, b, revision_id_list, revision):
4448
4671
import bzrlib.gpg as gpg
4641
4861
end_revision=last_revno)
4644
print 'Dry-run, pretending to remove the above revisions.'
4646
val = raw_input('Press <enter> to continue')
4864
self.outf.write('Dry-run, pretending to remove'
4865
' the above revisions.\n')
4648
print 'The above revision(s) will be removed.'
4650
val = raw_input('Are you sure [y/N]? ')
4651
if val.lower() not in ('y', 'yes'):
4867
self.outf.write('The above revision(s) will be removed.\n')
4870
if not ui.ui_factory.confirm_action(
4871
'Uncommit these revisions',
4872
'bzrlib.builtins.uncommit',
4874
self.outf.write('Canceled\n')
4655
4877
mutter('Uncommitting from {%s} to {%s}',
4656
4878
last_rev_id, rev_id)
4657
4879
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
4658
4880
revno=revno, local=local)
4659
note('You can restore the old tip by running:\n'
4660
' bzr pull . -r revid:%s', last_rev_id)
4881
self.outf.write('You can restore the old tip by running:\n'
4882
' bzr pull . -r revid:%s\n' % last_rev_id)
4663
4885
class cmd_break_lock(Command):
4664
"""Break a dead lock on a repository, branch or working directory.
4886
__doc__ = """Break a dead lock.
4888
This command breaks a lock on a repository, branch, working directory or
4666
4891
CAUTION: Locks should only be broken when you are sure that the process
4667
4892
holding the lock has been stopped.
4669
You can get information on what locks are open via the 'bzr info' command.
4894
You can get information on what locks are open via the 'bzr info
4895
[location]' command.
4899
bzr break-lock bzr+ssh://example.com/bzr/foo
4900
bzr break-lock --conf ~/.bazaar
4674
4903
takes_args = ['location?']
4906
help='LOCATION is the directory where the config lock is.'),
4908
help='Do not ask for confirmation before breaking the lock.'),
4676
def run(self, location=None, show=False):
4911
def run(self, location=None, config=False, force=False):
4677
4912
if location is None:
4678
4913
location = u'.'
4679
control, relpath = bzrdir.BzrDir.open_containing(location)
4681
control.break_lock()
4682
except NotImplementedError:
4915
ui.ui_factory = ui.ConfirmationUserInterfacePolicy(ui.ui_factory,
4917
{'bzrlib.lockdir.break': True})
4919
conf = _mod_config.LockableConfig(file_name=location)
4922
control, relpath = bzrdir.BzrDir.open_containing(location)
4924
control.break_lock()
4925
except NotImplementedError:
4686
4929
class cmd_wait_until_signalled(Command):
4687
"""Test helper for test_start_and_stop_bzr_subprocess_send_signal.
4930
__doc__ = """Test helper for test_start_and_stop_bzr_subprocess_send_signal.
4689
4932
This just prints a line to signal when it is ready, then blocks on stdin.
4943
5191
directly from the merge directive, without retrieving data from a
4946
If --no-bundle is specified, then public_branch is needed (and must be
4947
up-to-date), so that the receiver can perform the merge using the
4948
public_branch. The public_branch is always included if known, so that
4949
people can check it later.
4951
The submit branch defaults to the parent, but can be overridden. Both
4952
submit branch and public branch will be remembered if supplied.
4954
If a public_branch is known for the submit_branch, that public submit
4955
branch is used in the merge instructions. This means that a local mirror
4956
can be used as your actual submit branch, once you have set public_branch
5194
`bzr send` creates a compact data set that, when applied using bzr
5195
merge, has the same effect as merging from the source branch.
5197
By default the merge directive is self-contained and can be applied to any
5198
branch containing submit_branch in its ancestory without needing access to
5201
If --no-bundle is specified, then Bazaar doesn't send the contents of the
5202
revisions, but only a structured request to merge from the
5203
public_location. In that case the public_branch is needed and it must be
5204
up-to-date and accessible to the recipient. The public_branch is always
5205
included if known, so that people can check it later.
5207
The submit branch defaults to the parent of the source branch, but can be
5208
overridden. Both submit branch and public branch will be remembered in
5209
branch.conf the first time they are used for a particular branch. The
5210
source branch defaults to that containing the working directory, but can
5211
be changed using --from.
5213
In order to calculate those changes, bzr must analyse the submit branch.
5214
Therefore it is most efficient for the submit branch to be a local mirror.
5215
If a public location is known for the submit_branch, that location is used
5216
in the merge directive.
5218
The default behaviour is to send the merge directive by mail, unless -o is
5219
given, in which case it is sent to a file.
4959
5221
Mail is sent using your preferred mail program. This should be transparent
4960
on Windows (it uses MAPI). On Linux, it requires the xdg-email utility.
5222
on Windows (it uses MAPI). On Unix, it requires the xdg-email utility.
4961
5223
If the preferred client can't be found (or used), your editor will be used.
4963
5225
To use a specific mail program, set the mail_client configuration option.
4964
5226
(For Thunderbird 1.5, this works around some bugs.) Supported values for
4965
specific clients are "claws", "evolution", "kmail", "mutt", and
4966
"thunderbird"; generic options are "default", "editor", "emacsclient",
4967
"mapi", and "xdg-email". Plugins may also add supported clients.
5227
specific clients are "claws", "evolution", "kmail", "mail.app" (MacOS X's
5228
Mail.app), "mutt", and "thunderbird"; generic options are "default",
5229
"editor", "emacsclient", "mapi", and "xdg-email". Plugins may also add
4969
5232
If mail is being sent, a to address is required. This can be supplied
4970
5233
either on the commandline, by setting the submit_to configuration
5117
5384
To rename a tag (change the name but keep it on the same revsion), run ``bzr
5118
5385
tag new-name -r tag:old-name`` and then ``bzr tag --delete oldname``.
5387
If no tag name is specified it will be determined through the
5388
'automatic_tag_name' hook. This can e.g. be used to automatically tag
5389
upstream releases by reading configure.ac. See ``bzr help hooks`` for
5121
5393
_see_also = ['commit', 'tags']
5122
takes_args = ['tag_name']
5394
takes_args = ['tag_name?']
5123
5395
takes_options = [
5124
5396
Option('delete',
5125
5397
help='Delete this tag rather than placing it.',
5128
help='Branch in which to place the tag.',
5399
custom_help('directory',
5400
help='Branch in which to place the tag.'),
5132
5401
Option('force',
5133
5402
help='Replace existing tags.',
5138
def run(self, tag_name,
5407
def run(self, tag_name=None,
5144
5413
branch, relpath = Branch.open_containing(directory)
5148
branch.tags.delete_tag(tag_name)
5149
self.outf.write('Deleted tag %s.\n' % tag_name)
5414
self.add_cleanup(branch.lock_write().unlock)
5416
if tag_name is None:
5417
raise errors.BzrCommandError("No tag specified to delete.")
5418
branch.tags.delete_tag(tag_name)
5419
note('Deleted tag %s.' % tag_name)
5422
if len(revision) != 1:
5423
raise errors.BzrCommandError(
5424
"Tags can only be placed on a single revision, "
5426
revision_id = revision[0].as_revision_id(branch)
5152
if len(revision) != 1:
5153
raise errors.BzrCommandError(
5154
"Tags can only be placed on a single revision, "
5156
revision_id = revision[0].as_revision_id(branch)
5158
revision_id = branch.last_revision()
5159
if (not force) and branch.tags.has_tag(tag_name):
5160
raise errors.TagAlreadyExists(tag_name)
5161
branch.tags.set_tag(tag_name, revision_id)
5162
self.outf.write('Created tag %s.\n' % tag_name)
5428
revision_id = branch.last_revision()
5429
if tag_name is None:
5430
tag_name = branch.automatic_tag_name(revision_id)
5431
if tag_name is None:
5432
raise errors.BzrCommandError(
5433
"Please specify a tag name.")
5434
if (not force) and branch.tags.has_tag(tag_name):
5435
raise errors.TagAlreadyExists(tag_name)
5436
branch.tags.set_tag(tag_name, revision_id)
5437
note('Created tag %s.' % tag_name)
5167
5440
class cmd_tags(Command):
5441
__doc__ = """List tags.
5170
5443
This command shows a table of tag names and the revisions they reference.
5173
5446
_see_also = ['tag']
5174
5447
takes_options = [
5176
help='Branch whose tags should be displayed.',
5448
custom_help('directory',
5449
help='Branch whose tags should be displayed.'),
5180
5450
RegistryOption.from_kwargs('sort',
5181
5451
'Sort tags by different criteria.', title='Sorting',
5182
alpha='Sort tags lexicographically (default).',
5452
natural='Sort numeric substrings as numbers:'
5453
' suitable for version numbers. (default)',
5454
alpha='Sort tags lexicographically.',
5183
5455
time='Sort tags chronologically.',
5205
graph = branch.repository.get_graph()
5206
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5207
revid1, revid2 = rev1.rev_id, rev2.rev_id
5208
# only show revisions between revid1 and revid2 (inclusive)
5209
tags = [(tag, revid) for tag, revid in tags if
5210
graph.is_between(revid, revid1, revid2)]
5213
elif sort == 'time':
5215
for tag, revid in tags:
5217
revobj = branch.repository.get_revision(revid)
5218
except errors.NoSuchRevision:
5219
timestamp = sys.maxint # place them at the end
5221
timestamp = revobj.timestamp
5222
timestamps[revid] = timestamp
5223
tags.sort(key=lambda x: timestamps[x[1]])
5225
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5226
for index, (tag, revid) in enumerate(tags):
5228
revno = branch.revision_id_to_dotted_revno(revid)
5229
if isinstance(revno, tuple):
5230
revno = '.'.join(map(str, revno))
5231
except errors.NoSuchRevision:
5232
# Bad tag data/merges can lead to tagged revisions
5233
# which are not in this branch. Fail gracefully ...
5235
tags[index] = (tag, revno)
5474
self.add_cleanup(branch.lock_read().unlock)
5476
graph = branch.repository.get_graph()
5477
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5478
revid1, revid2 = rev1.rev_id, rev2.rev_id
5479
# only show revisions between revid1 and revid2 (inclusive)
5480
tags = [(tag, revid) for tag, revid in tags if
5481
graph.is_between(revid, revid1, revid2)]
5482
if sort == 'natural':
5483
def natural_sort_key(tag):
5484
return [f(s) for f,s in
5485
zip(itertools.cycle((unicode.lower,int)),
5486
re.split('([0-9]+)', tag[0]))]
5487
tags.sort(key=natural_sort_key)
5488
elif sort == 'alpha':
5490
elif sort == 'time':
5492
for tag, revid in tags:
5494
revobj = branch.repository.get_revision(revid)
5495
except errors.NoSuchRevision:
5496
timestamp = sys.maxint # place them at the end
5498
timestamp = revobj.timestamp
5499
timestamps[revid] = timestamp
5500
tags.sort(key=lambda x: timestamps[x[1]])
5502
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
5503
for index, (tag, revid) in enumerate(tags):
5505
revno = branch.revision_id_to_dotted_revno(revid)
5506
if isinstance(revno, tuple):
5507
revno = '.'.join(map(str, revno))
5508
except errors.NoSuchRevision:
5509
# Bad tag data/merges can lead to tagged revisions
5510
# which are not in this branch. Fail gracefully ...
5512
tags[index] = (tag, revno)
5238
5514
for tag, revspec in tags:
5239
5515
self.outf.write('%-20s %s\n' % (tag, revspec))
5242
5518
class cmd_reconfigure(Command):
5243
"""Reconfigure the type of a bzr directory.
5519
__doc__ = """Reconfigure the type of a bzr directory.
5245
5521
A target configuration must be specified.
5349
5625
/path/to/newbranch.
5351
5627
Bound branches use the nickname of its master branch unless it is set
5352
locally, in which case switching will update the the local nickname to be
5628
locally, in which case switching will update the local nickname to be
5353
5629
that of the master.
5356
takes_args = ['to_location']
5357
takes_options = [Option('force',
5632
takes_args = ['to_location?']
5633
takes_options = ['directory',
5358
5635
help='Switch even if local commits will be lost.'),
5359
5637
Option('create-branch', short_name='b',
5360
5638
help='Create the target branch from this one before'
5361
5639
' switching to it.'),
5364
def run(self, to_location, force=False, create_branch=False):
5642
def run(self, to_location=None, force=False, create_branch=False,
5643
revision=None, directory=u'.'):
5365
5644
from bzrlib import switch
5645
tree_location = directory
5646
revision = _get_one_revision('switch', revision)
5367
5647
control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
5648
if to_location is None:
5649
if revision is None:
5650
raise errors.BzrCommandError('You must supply either a'
5651
' revision or a location')
5652
to_location = tree_location
5369
5654
branch = control_dir.open_branch()
5370
5655
had_explicit_nick = branch.get_config().has_explicit_nickname()
5634
5955
Option('destroy',
5635
5956
help='Destroy removed changes instead of shelving them.'),
5637
_see_also = ['unshelve']
5958
_see_also = ['unshelve', 'configuration']
5639
5960
def run(self, revision=None, all=False, file_list=None, message=None,
5640
writer=None, list=False, destroy=False):
5961
writer=None, list=False, destroy=False, directory=None):
5642
return self.run_for_list()
5963
return self.run_for_list(directory=directory)
5643
5964
from bzrlib.shelf_ui import Shelver
5644
5965
if writer is None:
5645
5966
writer = bzrlib.option.diff_writer_registry.get()
5647
5968
shelver = Shelver.from_args(writer(sys.stdout), revision, all,
5648
file_list, message, destroy=destroy)
5969
file_list, message, destroy=destroy, directory=directory)
5652
shelver.work_tree.unlock()
5653
5974
except errors.UserAbort:
5656
def run_for_list(self):
5657
tree = WorkingTree.open_containing('.')[0]
5660
manager = tree.get_shelf_manager()
5661
shelves = manager.active_shelves()
5662
if len(shelves) == 0:
5663
note('No shelved changes.')
5665
for shelf_id in reversed(shelves):
5666
message = manager.get_metadata(shelf_id).get('message')
5668
message = '<no message>'
5669
self.outf.write('%3d: %s\n' % (shelf_id, message))
5977
def run_for_list(self, directory=None):
5978
if directory is None:
5980
tree = WorkingTree.open_containing(directory)[0]
5981
self.add_cleanup(tree.lock_read().unlock)
5982
manager = tree.get_shelf_manager()
5983
shelves = manager.active_shelves()
5984
if len(shelves) == 0:
5985
note('No shelved changes.')
5987
for shelf_id in reversed(shelves):
5988
message = manager.get_metadata(shelf_id).get('message')
5990
message = '<no message>'
5991
self.outf.write('%3d: %s\n' % (shelf_id, message))
5675
5995
class cmd_unshelve(Command):
5676
"""Restore shelved changes.
5996
__doc__ = """Restore shelved changes.
5678
5998
By default, the most recently shelved changes are restored. However if you
5679
5999
specify a shelf by id those changes will be restored instead. This works
5683
6003
takes_args = ['shelf_id?']
5684
6004
takes_options = [
5685
6006
RegistryOption.from_kwargs(
5686
6007
'action', help="The action to perform.",
5687
6008
enum_switch=False, value_switches=True,
5688
6009
apply="Apply changes and remove from the shelf.",
5689
6010
dry_run="Show changes, but do not apply or remove them.",
5690
delete_only="Delete changes without applying them."
6011
preview="Instead of unshelving the changes, show the diff that "
6012
"would result from unshelving.",
6013
delete_only="Delete changes without applying them.",
6014
keep="Apply changes but don't delete them.",
5693
6017
_see_also = ['shelve']
5695
def run(self, shelf_id=None, action='apply'):
6019
def run(self, shelf_id=None, action='apply', directory=u'.'):
5696
6020
from bzrlib.shelf_ui import Unshelver
5697
unshelver = Unshelver.from_args(shelf_id, action)
6021
unshelver = Unshelver.from_args(shelf_id, action, directory=directory)
5699
6023
unshelver.run()
5782
6107
self.outf.write('%s %s\n' % (path, location))
5785
# these get imported and then picked up by the scan for cmd_*
5786
# TODO: Some more consistent way to split command definitions across files;
5787
# we do need to load at least some information about them to know of
5788
# aliases. ideally we would avoid loading the implementation until the
5789
# details were needed.
5790
from bzrlib.cmd_version_info import cmd_version_info
5791
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
5792
from bzrlib.bundle.commands import (
5795
from bzrlib.foreign import cmd_dpush
5796
from bzrlib.sign_my_commits import cmd_sign_my_commits
5797
from bzrlib.weave_commands import cmd_versionedfile_list, \
5798
cmd_weave_plan_merge, cmd_weave_merge_text
6110
def _register_lazy_builtins():
6111
# register lazy builtins from other modules; called at startup and should
6112
# be only called once.
6113
for (name, aliases, module_name) in [
6114
('cmd_bundle_info', [], 'bzrlib.bundle.commands'),
6115
('cmd_config', [], 'bzrlib.config'),
6116
('cmd_dpush', [], 'bzrlib.foreign'),
6117
('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6118
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6119
('cmd_conflicts', [], 'bzrlib.conflicts'),
6120
('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
6121
('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6123
builtin_command_registry.register_lazy(name, aliases, module_name)