334
333
def run(self, revision_id=None, revision=None, directory=u'.'):
335
334
if revision_id is not None and revision is not None:
336
raise errors.BzrCommandError(gettext('You can only supply one of'
337
' revision_id or --revision'))
335
raise errors.BzrCommandError('You can only supply one of'
336
' revision_id or --revision')
338
337
if revision_id is None and revision is None:
339
raise errors.BzrCommandError(gettext('You must supply either'
340
' --revision or a revision_id'))
338
raise errors.BzrCommandError('You must supply either'
339
' --revision or a revision_id')
342
341
b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
344
343
revisions = b.repository.revisions
345
344
if revisions is None:
346
raise errors.BzrCommandError(gettext('Repository %r does not support '
347
'access to raw revision texts'))
345
raise errors.BzrCommandError('Repository %r does not support '
346
'access to raw revision texts')
349
348
b.repository.lock_read()
355
354
self.print_revision(revisions, revision_id)
356
355
except errors.NoSuchRevision:
357
msg = gettext("The repository {0} contains no revision {1}.").format(
356
msg = "The repository %s contains no revision %s." % (
358
357
b.repository.base, revision_id)
359
358
raise errors.BzrCommandError(msg)
360
359
elif revision is not None:
361
360
for rev in revision:
363
362
raise errors.BzrCommandError(
364
gettext('You cannot specify a NULL revision.'))
363
'You cannot specify a NULL revision.')
365
364
rev_id = rev.as_revision_id(b)
366
365
self.print_revision(revisions, rev_id)
479
478
working = d.open_workingtree()
480
479
except errors.NoWorkingTree:
481
raise errors.BzrCommandError(gettext("No working tree to remove"))
480
raise errors.BzrCommandError("No working tree to remove")
482
481
except errors.NotLocalUrl:
483
raise errors.BzrCommandError(gettext("You cannot remove the working tree"
484
" of a remote path"))
482
raise errors.BzrCommandError("You cannot remove the working tree"
486
485
if (working.has_changes()):
487
486
raise errors.UncommittedChanges(working)
540
539
tree.reset_state(revision_ids)
541
540
except errors.BzrError, e:
542
541
if revision_ids is None:
543
extra = (gettext(', the header appears corrupt, try passing -r -1'
544
' to set the state to the last commit'))
542
extra = (', the header appears corrupt, try passing -r -1'
543
' to set the state to the last commit')
547
raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
546
raise errors.BzrCommandError('failed to reset the tree state'
550
550
class cmd_revno(Command):
793
789
def run(self, revision=None, show_ids=False, kind=None, file_list=None):
794
790
if kind and kind not in ['file', 'directory', 'symlink']:
795
raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
791
raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
797
793
revision = _get_one_revision('inventory', revision)
798
794
work_tree, file_list = WorkingTree.open_containing_paths(file_list)
863
859
return self.run_auto(names_list, after, dry_run)
865
raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
861
raise errors.BzrCommandError('--dry-run requires --auto.')
866
862
if names_list is None:
868
864
if len(names_list) < 2:
869
raise errors.BzrCommandError(gettext("missing file argument"))
865
raise errors.BzrCommandError("missing file argument")
870
866
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
871
867
self.add_cleanup(tree.lock_tree_write().unlock)
872
868
self._run(tree, names_list, rel_names, after)
874
870
def run_auto(self, names_list, after, dry_run):
875
871
if names_list is not None and len(names_list) > 1:
876
raise errors.BzrCommandError(gettext('Only one path may be specified to'
872
raise errors.BzrCommandError('Only one path may be specified to'
879
raise errors.BzrCommandError(gettext('--after cannot be specified with'
875
raise errors.BzrCommandError('--after cannot be specified with'
881
877
work_tree, file_list = WorkingTree.open_containing_paths(
882
878
names_list, default_directory='.')
883
879
self.add_cleanup(work_tree.lock_tree_write().unlock)
1043
1039
stored_loc = branch_to.get_parent()
1044
1040
if location is None:
1045
1041
if stored_loc is None:
1046
raise errors.BzrCommandError(gettext("No pull location known or"
1042
raise errors.BzrCommandError("No pull location known or"
1049
1045
display_url = urlutils.unescape_for_display(stored_loc,
1050
1046
self.outf.encoding)
1051
1047
if not is_quiet():
1052
self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1048
self.outf.write("Using saved parent location: %s\n" % display_url)
1053
1049
location = stored_loc
1055
1051
revision = _get_one_revision('pull', revision)
1056
1052
if mergeable is not None:
1057
1053
if revision is not None:
1058
raise errors.BzrCommandError(gettext(
1059
'Cannot use -r with merge directives or bundles'))
1054
raise errors.BzrCommandError(
1055
'Cannot use -r with merge directives or bundles')
1060
1056
mergeable.install_revisions(branch_to.repository)
1061
1057
base_revision_id, revision_id, verified = \
1062
1058
mergeable.get_merge_request(branch_to.repository)
1190
1186
# error by the feedback given to them. RBC 20080227.
1191
1187
stacked_on = parent_url
1192
1188
if not stacked_on:
1193
raise errors.BzrCommandError(gettext(
1194
"Could not determine branch to refer to."))
1189
raise errors.BzrCommandError(
1190
"Could not determine branch to refer to.")
1196
1192
# Get the destination location
1197
1193
if location is None:
1198
1194
stored_loc = br_from.get_push_location()
1199
1195
if stored_loc is None:
1200
raise errors.BzrCommandError(gettext(
1201
"No push location known or specified."))
1196
raise errors.BzrCommandError(
1197
"No push location known or specified.")
1203
1199
display_url = urlutils.unescape_for_display(stored_loc,
1204
1200
self.outf.encoding)
1205
note(gettext("Using saved push location: %s") % display_url)
1201
note("Using saved push location: %s" % display_url)
1206
1202
location = stored_loc
1208
1204
_show_push_branch(br_from, revision_id, location, self.outf,
1315
1311
branch = dir.open_branch()
1316
1312
except errors.NoSuchRevision:
1317
1313
to_transport.delete_tree('.')
1318
msg = gettext("The branch {0} has no revision {1}.").format(
1319
from_location, revision)
1314
msg = "The branch %s has no revision %s." % (from_location,
1320
1316
raise errors.BzrCommandError(msg)
1321
1317
_merge_tags_if_possible(br_from, branch)
1322
1318
# If the source branch is stacked, the new branch may
1323
1319
# be stacked whether we asked for that explicitly or not.
1324
1320
# We therefore need a try/except here and not just 'if stacked:'
1326
note(gettext('Created new stacked branch referring to %s.') %
1322
note('Created new stacked branch referring to %s.' %
1327
1323
branch.get_stacked_on_url())
1328
1324
except (errors.NotStacked, errors.UnstackableBranchFormat,
1329
1325
errors.UnstackableRepositoryFormat), e:
1330
note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1326
note('Branched %d revision(s).' % branch.revno())
1332
1328
# Bind to the parent
1333
1329
parent_branch = Branch.open(from_location)
1334
1330
branch.bind(parent_branch)
1335
note(gettext('New branch bound to %s') % from_location)
1331
note('New branch bound to %s' % from_location)
1337
1333
# Switch to the new branch
1338
1334
wt, _ = WorkingTree.open_containing('.')
1339
1335
_mod_switch.switch(wt.bzrdir, branch)
1340
note(gettext('Switched to branch: %s'),
1336
note('Switched to branch: %s',
1341
1337
urlutils.unescape_for_display(branch.base, 'utf-8'))
1344
1340
class cmd_branches(Command):
1345
1341
__doc__ = """List the branches available at the current location.
1347
This command will print the names of all the branches at the current
1343
This command will print the names of all the branches at the current location.
1351
1346
takes_args = ['location?']
1353
Option('recursive', short_name='R',
1354
help='Recursively scan for branches rather than '
1355
'just looking in the specified location.')]
1357
def run(self, location=".", recursive=False):
1359
t = transport.get_transport(location)
1360
if not t.listable():
1361
raise errors.BzrCommandError(
1362
"Can't scan this type of location.")
1363
for b in bzrdir.BzrDir.find_branches(t):
1364
self.outf.write("%s\n" % urlutils.unescape_for_display(
1365
urlutils.relative_url(t.base, b.base),
1366
self.outf.encoding).rstrip("/"))
1368
dir = bzrdir.BzrDir.open_containing(location)[0]
1369
for branch in dir.list_branches():
1370
if branch.name is None:
1371
self.outf.write(gettext(" (default)\n"))
1373
self.outf.write(" %s\n" % branch.name.encode(
1374
self.outf.encoding))
1348
def run(self, location="."):
1349
dir = bzrdir.BzrDir.open_containing(location)[0]
1350
for branch in dir.list_branches():
1351
if branch.name is None:
1352
self.outf.write(" (default)\n")
1354
self.outf.write(" %s\n" % branch.name.encode(self.outf.encoding))
1377
1357
class cmd_checkout(Command):
1481
1461
class cmd_update(Command):
1482
__doc__ = """Update a working tree to a new revision.
1484
This will perform a merge of the destination revision (the tip of the
1485
branch, or the specified revision) into the working tree, and then make
1486
that revision the basis revision for the working tree.
1488
You can use this to visit an older revision, or to update a working tree
1489
that is out of date from its branch.
1491
If there are any uncommitted changes in the tree, they will be carried
1492
across and remain as uncommitted changes after the update. To discard
1493
these changes, use 'bzr revert'. The uncommitted changes may conflict
1494
with the changes brought in by the change in basis revision.
1496
If the tree's branch is bound to a master branch, bzr will also update
1462
__doc__ = """Update a tree to have the latest code committed to its branch.
1464
This will perform a merge into the working tree, and may generate
1465
conflicts. If you have any local changes, you will still
1466
need to commit them after the update for the update to be complete.
1468
If you want to discard your local changes, you can just do a
1469
'bzr revert' instead of 'bzr commit' after the update.
1471
If you want to restore a file that has been removed locally, use
1472
'bzr revert' instead of 'bzr update'.
1474
If the tree's branch is bound to a master branch, it will also update
1497
1475
the branch from the master.
1499
You cannot update just a single file or directory, because each Bazaar
1500
working tree has just a single basis revision. If you want to restore a
1501
file that has been removed locally, use 'bzr revert' instead of 'bzr
1502
update'. If you want to restore a file to its state in a previous
1503
revision, use 'bzr revert' with a '-r' option, or use 'bzr cat' to write
1504
out the old content of that file to a new location.
1506
The 'dir' argument, if given, must be the location of the root of a
1507
working tree to update. By default, the working tree that contains the
1508
current working directory is used.
1511
1478
_see_also = ['pull', 'working-trees', 'status-flags']
1517
1484
aliases = ['up']
1519
def run(self, dir=None, revision=None, show_base=None):
1486
def run(self, dir='.', revision=None, show_base=None):
1520
1487
if revision is not None and len(revision) != 1:
1521
raise errors.BzrCommandError(gettext(
1522
"bzr update --revision takes exactly one revision"))
1524
tree = WorkingTree.open_containing('.')[0]
1526
tree, relpath = WorkingTree.open_containing(dir)
1529
raise errors.BzrCommandError(gettext(
1530
"bzr update can only update a whole tree, "
1531
"not a file or subdirectory"))
1488
raise errors.BzrCommandError(
1489
"bzr update --revision takes exactly one revision")
1490
tree = WorkingTree.open_containing(dir)[0]
1532
1491
branch = tree.branch
1533
1492
possible_transports = []
1534
1493
master = branch.get_master_branch(
1558
1517
revision_id = branch.last_revision()
1559
1518
if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1560
1519
revno = branch.revision_id_to_dotted_revno(revision_id)
1561
note(gettext("Tree is up to date at revision {0} of branch {1}"
1562
).format('.'.join(map(str, revno)), branch_location))
1520
note("Tree is up to date at revision %s of branch %s" %
1521
('.'.join(map(str, revno)), branch_location))
1564
1523
view_info = _get_view_info_for_change_reporter(tree)
1565
1524
change_reporter = delta._ChangeReporter(
1573
1532
old_tip=old_tip,
1574
1533
show_base=show_base)
1575
1534
except errors.NoSuchRevision, e:
1576
raise errors.BzrCommandError(gettext(
1535
raise errors.BzrCommandError(
1577
1536
"branch has no revision %s\n"
1578
1537
"bzr update --revision only works"
1579
" for a revision in the branch history")
1538
" for a revision in the branch history"
1580
1539
% (e.revision))
1581
1540
revno = tree.branch.revision_id_to_dotted_revno(
1582
1541
_mod_revision.ensure_null(tree.last_revision()))
1583
note(gettext('Updated to revision {0} of branch {1}').format(
1584
'.'.join(map(str, revno)), branch_location))
1542
note('Updated to revision %s of branch %s' %
1543
('.'.join(map(str, revno)), branch_location))
1585
1544
parent_ids = tree.get_parent_ids()
1586
1545
if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1587
note(gettext('Your local commits will now show as pending merges with '
1588
"'bzr status', and can be committed with 'bzr commit'."))
1546
note('Your local commits will now show as pending merges with '
1547
"'bzr status', and can be committed with 'bzr commit'.")
1589
1548
if conflicts != 0:
1663
1622
def run(self, file_list, verbose=False, new=False,
1664
1623
file_deletion_strategy='safe'):
1665
1624
if file_deletion_strategy == 'force':
1666
note(gettext("(The --force option is deprecated, rather use --no-backup "
1625
note("(The --force option is deprecated, rather use --no-backup "
1668
1627
file_deletion_strategy = 'no-backup'
1670
1629
tree, file_list = WorkingTree.open_containing_paths(file_list)
1908
1867
raise errors.BranchExistsWithoutWorkingTree(location)
1909
1868
raise errors.AlreadyBranchError(location)
1910
1869
branch = a_bzrdir.create_branch()
1911
if not no_tree and not a_bzrdir.has_workingtree():
1912
1871
a_bzrdir.create_workingtree()
1913
1872
if append_revisions_only:
1915
1874
branch.set_append_revisions_only(True)
1916
1875
except errors.UpgradeRequired:
1917
raise errors.BzrCommandError(gettext('This branch format cannot be set'
1918
' to append-revisions-only. Try --default.'))
1876
raise errors.BzrCommandError('This branch format cannot be set'
1877
' to append-revisions-only. Try --default.')
1919
1878
if not is_quiet():
1920
1879
from bzrlib.info import describe_layout, describe_format
1925
1884
repository = branch.repository
1926
1885
layout = describe_layout(repository, branch, tree).lower()
1927
1886
format = describe_format(a_bzrdir, repository, branch, tree)
1928
self.outf.write(gettext("Created a {0} (format: {1})\n").format(
1887
self.outf.write("Created a %s (format: %s)\n" % (layout, format))
1930
1888
if repository.is_shared():
1931
1889
#XXX: maybe this can be refactored into transport.path_or_url()
1932
1890
url = repository.bzrdir.root_transport.external_url()
2131
2089
elif ':' in prefix:
2132
2090
old_label, new_label = prefix.split(":")
2134
raise errors.BzrCommandError(gettext(
2092
raise errors.BzrCommandError(
2135
2093
'--prefix expects two values separated by a colon'
2136
' (eg "old/:new/")'))
2094
' (eg "old/:new/")')
2138
2096
if revision and len(revision) > 2:
2139
raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
2140
' one or two revision specifiers'))
2097
raise errors.BzrCommandError('bzr diff --revision takes exactly'
2098
' one or two revision specifiers')
2142
2100
if using is not None and format is not None:
2143
raise errors.BzrCommandError(gettext(
2144
'{0} and {1} are mutually exclusive').format(
2145
'--using', '--format'))
2101
raise errors.BzrCommandError('--using and --format are mutually '
2147
2104
(old_tree, new_tree,
2148
2105
old_branch, new_branch,
2462
2419
Option('show-diff',
2463
2420
short_name='p',
2464
2421
help='Show changes made in each revision as a patch.'),
2465
Option('include-merged',
2422
Option('include-merges',
2466
2423
help='Show merged revisions like --levels 0 does.'),
2467
Option('include-merges', hidden=True,
2468
help='Historical alias for --include-merged.'),
2469
Option('omit-merges',
2470
help='Do not report commits with more than one parent.'),
2471
2424
Option('exclude-common-ancestry',
2472
2425
help='Display only the revisions that are not part'
2473
2426
' of both ancestries (require -rX..Y)'
2528
2479
_get_info_for_log_files,
2530
2481
direction = (forward and 'forward') or 'reverse'
2531
if symbol_versioning.deprecated_passed(include_merges):
2532
ui.ui_factory.show_user_warning(
2533
'deprecated_command_option',
2534
deprecated_name='--include-merges',
2535
recommended_name='--include-merged',
2536
deprecated_in_version='2.5',
2537
command=self.invoked_as)
2538
if include_merged is None:
2539
include_merged = include_merges
2541
raise errors.BzrCommandError(gettext(
2542
'{0} and {1} are mutually exclusive').format(
2543
'--include-merges', '--include-merged'))
2544
if include_merged is None:
2545
include_merged = False
2546
2482
if (exclude_common_ancestry
2547
2483
and (revision is None or len(revision) != 2)):
2548
raise errors.BzrCommandError(gettext(
2549
'--exclude-common-ancestry requires -r with two revisions'))
2484
raise errors.BzrCommandError(
2485
'--exclude-common-ancestry requires -r with two revisions')
2551
2487
if levels is None:
2554
raise errors.BzrCommandError(gettext(
2555
'{0} and {1} are mutually exclusive').format(
2556
'--levels', '--include-merged'))
2490
raise errors.BzrCommandError(
2491
'--levels and --include-merges are mutually exclusive')
2558
2493
if change is not None:
2559
2494
if len(change) > 1:
2560
2495
raise errors.RangeInChangeOption()
2561
2496
if revision is not None:
2562
raise errors.BzrCommandError(gettext(
2563
'{0} and {1} are mutually exclusive').format(
2564
'--revision', '--change'))
2497
raise errors.BzrCommandError(
2498
'--revision and --change are mutually exclusive')
2566
2500
revision = change
2573
2507
revision, file_list, self.add_cleanup)
2574
2508
for relpath, file_id, kind in file_info_list:
2575
2509
if file_id is None:
2576
raise errors.BzrCommandError(gettext(
2577
"Path unknown at end or start of revision range: %s") %
2510
raise errors.BzrCommandError(
2511
"Path unknown at end or start of revision range: %s" %
2579
2513
# If the relpath is the top of the tree, we log everything
2580
2514
if relpath == '':
2690
2624
# b is taken from revision[0].get_branch(), and
2691
2625
# show_log will use its revision_history. Having
2692
2626
# different branches will lead to weird behaviors.
2693
raise errors.BzrCommandError(gettext(
2627
raise errors.BzrCommandError(
2694
2628
"bzr %s doesn't accept two revisions in different"
2695
" branches.") % command_name)
2629
" branches." % command_name)
2696
2630
if start_spec.spec is None:
2697
2631
# Avoid loading all the history.
2698
2632
rev1 = RevisionInfo(branch, None, None)
2784
2718
null=False, kind=None, show_ids=False, path=None, directory=None):
2786
2720
if kind and kind not in ('file', 'directory', 'symlink'):
2787
raise errors.BzrCommandError(gettext('invalid kind specified'))
2721
raise errors.BzrCommandError('invalid kind specified')
2789
2723
if verbose and null:
2790
raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2724
raise errors.BzrCommandError('Cannot set both --verbose and --null')
2791
2725
all = not (unknown or versioned or ignored)
2793
2727
selection = {'I':ignored, '?':unknown, 'V':versioned}
2972
2906
self.outf.write("%s\n" % pattern)
2974
2908
if not name_pattern_list:
2975
raise errors.BzrCommandError(gettext("ignore requires at least one "
2976
"NAME_PATTERN or --default-rules."))
2909
raise errors.BzrCommandError("ignore requires at least one "
2910
"NAME_PATTERN or --default-rules.")
2977
2911
name_pattern_list = [globbing.normalize_pattern(p)
2978
2912
for p in name_pattern_list]
2979
2913
bad_patterns = ''
2980
bad_patterns_count = 0
2981
2914
for p in name_pattern_list:
2982
2915
if not globbing.Globster.is_pattern_valid(p):
2983
bad_patterns_count += 1
2984
2916
bad_patterns += ('\n %s' % p)
2985
2917
if bad_patterns:
2986
msg = (ngettext('Invalid ignore pattern found. %s',
2987
'Invalid ignore patterns found. %s',
2988
bad_patterns_count) % bad_patterns)
2918
msg = ('Invalid ignore pattern(s) found. %s' % bad_patterns)
2989
2919
ui.ui_factory.show_error(msg)
2990
2920
raise errors.InvalidPattern('')
2991
2921
for name_pattern in name_pattern_list:
2992
2922
if (name_pattern[0] == '/' or
2993
2923
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2994
raise errors.BzrCommandError(gettext(
2995
"NAME_PATTERN should not be an absolute path"))
2924
raise errors.BzrCommandError(
2925
"NAME_PATTERN should not be an absolute path")
2996
2926
tree, relpath = WorkingTree.open_containing(directory)
2997
2927
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2998
2928
ignored = globbing.Globster(name_pattern_list)
3005
2935
if ignored.match(filename):
3006
2936
matches.append(filename)
3007
2937
if len(matches) > 0:
3008
self.outf.write(gettext("Warning: the following files are version "
3009
"controlled and match your ignore pattern:\n%s"
2938
self.outf.write("Warning: the following files are version controlled and"
2939
" match your ignore pattern:\n%s"
3010
2940
"\nThese files will continue to be version controlled"
3011
" unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2941
" unless you 'bzr remove' them.\n" % ("\n".join(matches),))
3014
2944
class cmd_ignored(Command):
3146
3076
def run(self, filename, revision=None, name_from_revision=False,
3147
3077
filters=False, directory=None):
3148
3078
if revision is not None and len(revision) != 1:
3149
raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
3150
" one revision specifier"))
3079
raise errors.BzrCommandError("bzr cat --revision takes exactly"
3080
" one revision specifier")
3151
3081
tree, branch, relpath = \
3152
3082
_open_directory_or_containing_tree_or_branch(filename, directory)
3153
3083
self.add_cleanup(branch.lock_read().unlock)
3316
3246
default_bugtracker = branch_config.get_user_option(
3318
3248
if default_bugtracker is None:
3319
raise errors.BzrCommandError(gettext(
3249
raise errors.BzrCommandError(
3320
3250
"No tracker specified for bug %s. Use the form "
3321
3251
"'tracker:id' or specify a default bug tracker "
3322
3252
"using the `bugtracker` option.\nSee "
3323
3253
"\"bzr help bugs\" for more information on this "
3324
"feature. Commit refused.") % fixed_bug)
3254
"feature. Commit refused." % fixed_bug)
3325
3255
tag = default_bugtracker
3326
3256
bug_id = tokens[0]
3327
3257
elif len(tokens) != 2:
3328
raise errors.BzrCommandError(gettext(
3258
raise errors.BzrCommandError(
3329
3259
"Invalid bug %s. Must be in the form of 'tracker:id'. "
3330
3260
"See \"bzr help bugs\" for more information on this "
3331
"feature.\nCommit refused.") % fixed_bug)
3261
"feature.\nCommit refused." % fixed_bug)
3333
3263
tag, bug_id = tokens
3335
3265
yield bugtracker.get_bug_url(tag, branch, bug_id)
3336
3266
except errors.UnknownBugTrackerAbbreviation:
3337
raise errors.BzrCommandError(gettext(
3338
'Unrecognized bug %s. Commit refused.') % fixed_bug)
3267
raise errors.BzrCommandError(
3268
'Unrecognized bug %s. Commit refused.' % fixed_bug)
3339
3269
except errors.MalformedBugIdentifier, e:
3340
raise errors.BzrCommandError(gettext(
3341
"%s\nCommit refused.") % (str(e),))
3270
raise errors.BzrCommandError(
3271
"%s\nCommit refused." % (str(e),))
3343
3273
def run(self, message=None, file=None, verbose=False, selected_list=None,
3344
3274
unchanged=False, strict=False, local=False, fixes=None,
3431
3361
my_message = edit_commit_message_encoded(text,
3432
3362
start_message=start_message)
3433
3363
if my_message is None:
3434
raise errors.BzrCommandError(gettext("please specify a commit"
3435
" message with either --message or --file"))
3364
raise errors.BzrCommandError("please specify a commit"
3365
" message with either --message or --file")
3436
3366
if my_message == "":
3437
raise errors.BzrCommandError(gettext("Empty commit message specified."
3367
raise errors.BzrCommandError("Empty commit message specified."
3438
3368
" Please specify a commit message with either"
3439
3369
" --message or --file or leave a blank message"
3440
" with --message \"\"."))
3370
" with --message \"\".")
3441
3371
return my_message
3443
3373
# The API permits a commit with a filter of [] to mean 'select nothing'
3454
3384
exclude=tree.safe_relpath_files(exclude),
3456
3386
except PointlessCommit:
3457
raise errors.BzrCommandError(gettext("No changes to commit."
3387
raise errors.BzrCommandError("No changes to commit."
3458
3388
" Please 'bzr add' the files you want to commit, or use"
3459
" --unchanged to force an empty commit."))
3389
" --unchanged to force an empty commit.")
3460
3390
except ConflictsInTree:
3461
raise errors.BzrCommandError(gettext('Conflicts detected in working '
3391
raise errors.BzrCommandError('Conflicts detected in working '
3462
3392
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
3464
3394
except StrictCommitFailed:
3465
raise errors.BzrCommandError(gettext("Commit refused because there are"
3466
" unknown files in the working tree."))
3395
raise errors.BzrCommandError("Commit refused because there are"
3396
" unknown files in the working tree.")
3467
3397
except errors.BoundBranchOutOfDate, e:
3468
e.extra_help = (gettext("\n"
3398
e.extra_help = ("\n"
3469
3399
'To commit to master branch, run update and then commit.\n'
3470
3400
'You can also pass --local to commit to continue working '
3901
3831
from bzrlib.tests import SubUnitBzrRunner
3902
3832
except ImportError:
3903
raise errors.BzrCommandError(gettext("subunit not available. subunit "
3904
"needs to be installed to use --subunit."))
3833
raise errors.BzrCommandError("subunit not available. subunit "
3834
"needs to be installed to use --subunit.")
3905
3835
self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3906
3836
# On Windows, disable automatic conversion of '\n' to '\r\n' in
3907
3837
# stdout, which would corrupt the subunit stream.
4169
4099
mergeable = None
4171
4101
if uncommitted:
4172
raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4173
' with bundles or merge directives.'))
4102
raise errors.BzrCommandError('Cannot use --uncommitted'
4103
' with bundles or merge directives.')
4175
4105
if revision is not None:
4176
raise errors.BzrCommandError(gettext(
4177
'Cannot use -r with merge directives or bundles'))
4106
raise errors.BzrCommandError(
4107
'Cannot use -r with merge directives or bundles')
4178
4108
merger, verified = _mod_merge.Merger.from_mergeable(tree,
4179
4109
mergeable, None)
4181
4111
if merger is None and uncommitted:
4182
4112
if revision is not None and len(revision) > 0:
4183
raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4184
' --revision at the same time.'))
4113
raise errors.BzrCommandError('Cannot use --uncommitted and'
4114
' --revision at the same time.')
4185
4115
merger = self.get_merger_from_uncommitted(tree, location, None)
4186
4116
allow_pending = False
4200
4130
if merger.interesting_files:
4201
4131
if not merger.other_tree.has_filename(
4202
4132
merger.interesting_files[0]):
4203
note(gettext("merger: ") + str(merger))
4133
note("merger: " + str(merger))
4204
4134
raise errors.PathsDoNotExist([location])
4205
note(gettext('Nothing to do.'))
4135
note('Nothing to do.')
4207
4137
if pull and not preview:
4208
4138
if merger.interesting_files is not None:
4209
raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4139
raise errors.BzrCommandError('Cannot pull individual files')
4210
4140
if (merger.base_rev_id == tree.last_revision()):
4211
4141
result = tree.pull(merger.other_branch, False,
4212
4142
merger.other_rev_id)
4213
4143
result.report(self.outf)
4215
4145
if merger.this_basis is None:
4216
raise errors.BzrCommandError(gettext(
4146
raise errors.BzrCommandError(
4217
4147
"This branch has no commits."
4218
" (perhaps you would prefer 'bzr pull')"))
4148
" (perhaps you would prefer 'bzr pull')")
4220
4150
return self._do_preview(merger)
4221
4151
elif interactive:
4281
4211
# Use reprocess if the merger supports it
4282
4212
merger.reprocess = merger.merge_type.supports_reprocess
4283
4213
if merger.reprocess and not merger.merge_type.supports_reprocess:
4284
raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
4285
" for merge type %s.") %
4214
raise errors.BzrCommandError("Conflict reduction is not supported"
4215
" for merge type %s." %
4286
4216
merger.merge_type)
4287
4217
if merger.reprocess and merger.show_base:
4288
raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4218
raise errors.BzrCommandError("Cannot do conflict reduction and"
4291
4221
def _get_merger_from_branch(self, tree, location, revision, remember,
4292
4222
possible_transports, pb):
4396
4326
stored_location_type = "parent"
4397
4327
mutter("%s", stored_location)
4398
4328
if stored_location is None:
4399
raise errors.BzrCommandError(gettext("No location specified or remembered"))
4329
raise errors.BzrCommandError("No location specified or remembered")
4400
4330
display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4401
note(gettext("{0} remembered {1} location {2}").format(verb_string,
4402
stored_location_type, display_url))
4331
note(u"%s remembered %s location %s", verb_string,
4332
stored_location_type, display_url)
4403
4333
return stored_location
4669
4599
type=_parse_revision_str,
4670
4600
help='Filter on local branch revisions (inclusive). '
4671
4601
'See "help revisionspec" for details.'),
4672
Option('include-merged',
4602
Option('include-merges',
4673
4603
'Show all revisions in addition to the mainline ones.'),
4674
Option('include-merges', hidden=True,
4675
help='Historical alias for --include-merged.'),
4677
4605
encoding_type = 'replace'
4681
4609
theirs_only=False,
4682
4610
log_format=None, long=False, short=False, line=False,
4683
4611
show_ids=False, verbose=False, this=False, other=False,
4684
include_merged=None, revision=None, my_revision=None,
4686
include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4612
include_merges=False, revision=None, my_revision=None,
4687
4614
from bzrlib.missing import find_unmerged, iter_log_revisions
4688
4615
def message(s):
4689
4616
if not is_quiet():
4690
4617
self.outf.write(s)
4692
if symbol_versioning.deprecated_passed(include_merges):
4693
ui.ui_factory.show_user_warning(
4694
'deprecated_command_option',
4695
deprecated_name='--include-merges',
4696
recommended_name='--include-merged',
4697
deprecated_in_version='2.5',
4698
command=self.invoked_as)
4699
if include_merged is None:
4700
include_merged = include_merges
4702
raise errors.BzrCommandError(gettext(
4703
'{0} and {1} are mutually exclusive').format(
4704
'--include-merges', '--include-merged'))
4705
if include_merged is None:
4706
include_merged = False
4708
4620
mine_only = this
4790
4698
if mine_only and not local_extra:
4791
4699
# We checked local, and found nothing extra
4792
message(gettext('This branch has no new revisions.\n'))
4700
message('This branch has no new revisions.\n')
4793
4701
elif theirs_only and not remote_extra:
4794
4702
# We checked remote, and found nothing extra
4795
message(gettext('Other branch has no new revisions.\n'))
4703
message('Other branch has no new revisions.\n')
4796
4704
elif not (mine_only or theirs_only or local_extra or
4798
4706
# We checked both branches, and neither one had extra
4800
message(gettext("Branches are up to date.\n"))
4708
message("Branches are up to date.\n")
4801
4709
self.cleanup_now()
4802
4710
if not status_code and parent is None and other_branch is not None:
4803
4711
self.add_cleanup(local_branch.lock_write().unlock)
4965
4873
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4966
4874
if revision_id_list is not None and revision is not None:
4967
raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
4875
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4968
4876
if revision_id_list is None and revision is None:
4969
raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
4877
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4970
4878
b = WorkingTree.open_containing(directory)[0].branch
4971
4879
self.add_cleanup(b.lock_write().unlock)
4972
4880
return self._run(b, revision_id_list, revision)
5042
4950
location = b.get_old_bound_location()
5043
4951
except errors.UpgradeRequired:
5044
raise errors.BzrCommandError(gettext('No location supplied. '
5045
'This format does not remember old locations.'))
4952
raise errors.BzrCommandError('No location supplied. '
4953
'This format does not remember old locations.')
5047
4955
if location is None:
5048
4956
if b.get_bound_location() is not None:
5049
raise errors.BzrCommandError(gettext('Branch is already bound'))
4957
raise errors.BzrCommandError('Branch is already bound')
5051
raise errors.BzrCommandError(gettext('No location supplied '
5052
'and no previous location known'))
4959
raise errors.BzrCommandError('No location supplied '
4960
'and no previous location known')
5053
4961
b_other = Branch.open(location)
5055
4963
b.bind(b_other)
5056
4964
except errors.DivergedBranches:
5057
raise errors.BzrCommandError(gettext('These branches have diverged.'
5058
' Try merging, and then bind again.'))
4965
raise errors.BzrCommandError('These branches have diverged.'
4966
' Try merging, and then bind again.')
5059
4967
if b.get_config().has_explicit_nickname():
5060
4968
b.nick = b_other.nick
5168
5076
end_revision=last_revno)
5171
self.outf.write(gettext('Dry-run, pretending to remove'
5172
' the above revisions.\n'))
5079
self.outf.write('Dry-run, pretending to remove'
5080
' the above revisions.\n')
5174
self.outf.write(gettext('The above revision(s) will be removed.\n'))
5082
self.outf.write('The above revision(s) will be removed.\n')
5177
5085
if not ui.ui_factory.confirm_action(
5178
gettext(u'Uncommit these revisions'),
5086
u'Uncommit these revisions',
5179
5087
'bzrlib.builtins.uncommit',
5181
self.outf.write(gettext('Canceled\n'))
5089
self.outf.write('Canceled\n')
5184
5092
mutter('Uncommitting from {%s} to {%s}',
5185
5093
last_rev_id, rev_id)
5186
5094
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5187
5095
revno=revno, local=local, keep_tags=keep_tags)
5188
self.outf.write(gettext('You can restore the old tip by running:\n'
5189
' bzr pull . -r revid:%s\n') % last_rev_id)
5096
self.outf.write('You can restore the old tip by running:\n'
5097
' bzr pull . -r revid:%s\n' % last_rev_id)
5192
5100
class cmd_break_lock(Command):
5311
5217
if not allow_writes:
5312
5218
url = 'readonly+' + url
5313
5219
t = transport.get_transport(url)
5315
protocol(t, host, port, inet, client_timeout)
5316
except TypeError, e:
5317
# We use symbol_versioning.deprecated_in just so that people
5318
# grepping can find it here.
5319
# symbol_versioning.deprecated_in((2, 5, 0))
5320
symbol_versioning.warn(
5321
'Got TypeError(%s)\ntrying to call protocol: %s.%s\n'
5322
'Most likely it needs to be updated to support a'
5323
' "timeout" parameter (added in bzr 2.5.0)'
5324
% (e, protocol.__module__, protocol),
5326
protocol(t, host, port, inet)
5220
protocol(t, host, port, inet)
5329
5223
class cmd_join(Command):
5362
5256
except errors.BadReferenceTarget, e:
5363
5257
# XXX: Would be better to just raise a nicely printable
5364
5258
# exception from the real origin. Also below. mbp 20070306
5365
raise errors.BzrCommandError(
5366
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5259
raise errors.BzrCommandError("Cannot join %s. %s" %
5369
5263
containing_tree.subsume(sub_tree)
5370
5264
except errors.BadSubsumeSource, e:
5371
raise errors.BzrCommandError(
5372
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5265
raise errors.BzrCommandError("Cannot join %s. %s" %
5375
5269
class cmd_split(Command):
5467
5361
elif stored_public_branch is None:
5468
5362
branch.set_public_branch(public_branch)
5469
5363
if not include_bundle and public_branch is None:
5470
raise errors.BzrCommandError(gettext('No public branch specified or'
5364
raise errors.BzrCommandError('No public branch specified or'
5472
5366
base_revision_id = None
5473
5367
if revision is not None:
5474
5368
if len(revision) > 2:
5475
raise errors.BzrCommandError(gettext('bzr merge-directive takes '
5476
'at most two one revision identifiers'))
5369
raise errors.BzrCommandError('bzr merge-directive takes '
5370
'at most two one revision identifiers')
5477
5371
revision_id = revision[-1].as_revision_id(branch)
5478
5372
if len(revision) == 2:
5479
5373
base_revision_id = revision[0].as_revision_id(branch)
5481
5375
revision_id = branch.last_revision()
5482
5376
revision_id = ensure_null(revision_id)
5483
5377
if revision_id == NULL_REVISION:
5484
raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5378
raise errors.BzrCommandError('No revisions to bundle.')
5485
5379
directive = merge_directive.MergeDirective2.from_objects(
5486
5380
branch.repository, revision_id, time.time(),
5487
5381
osutils.local_time_offset(), submit_branch,
5741
5635
self.add_cleanup(branch.lock_write().unlock)
5743
5637
if tag_name is None:
5744
raise errors.BzrCommandError(gettext("No tag specified to delete."))
5638
raise errors.BzrCommandError("No tag specified to delete.")
5745
5639
branch.tags.delete_tag(tag_name)
5746
note(gettext('Deleted tag %s.') % tag_name)
5640
note('Deleted tag %s.' % tag_name)
5749
5643
if len(revision) != 1:
5750
raise errors.BzrCommandError(gettext(
5644
raise errors.BzrCommandError(
5751
5645
"Tags can only be placed on a single revision, "
5753
5647
revision_id = revision[0].as_revision_id(branch)
5755
5649
revision_id = branch.last_revision()
5756
5650
if tag_name is None:
5757
5651
tag_name = branch.automatic_tag_name(revision_id)
5758
5652
if tag_name is None:
5759
raise errors.BzrCommandError(gettext(
5760
"Please specify a tag name."))
5653
raise errors.BzrCommandError(
5654
"Please specify a tag name.")
5762
5656
existing_target = branch.tags.lookup_tag(tag_name)
5763
5657
except errors.NoSuchTag:
5765
5659
if not force and existing_target not in (None, revision_id):
5766
5660
raise errors.TagAlreadyExists(tag_name)
5767
5661
if existing_target == revision_id:
5768
note(gettext('Tag %s already exists for that revision.') % tag_name)
5662
note('Tag %s already exists for that revision.' % tag_name)
5770
5664
branch.tags.set_tag(tag_name, revision_id)
5771
5665
if existing_target is None:
5772
note(gettext('Created tag %s.') % tag_name)
5666
note('Created tag %s.' % tag_name)
5774
note(gettext('Updated tag %s.') % tag_name)
5668
note('Updated tag %s.' % tag_name)
5777
5671
class cmd_tags(Command):
5804
5698
self.add_cleanup(branch.lock_read().unlock)
5806
# Restrict to the specified range
5807
tags = self._tags_for_range(branch, revision)
5700
graph = branch.repository.get_graph()
5701
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5702
revid1, revid2 = rev1.rev_id, rev2.rev_id
5703
# only show revisions between revid1 and revid2 (inclusive)
5704
tags = [(tag, revid) for tag, revid in tags if
5705
graph.is_between(revid, revid1, revid2)]
5808
5706
if sort is None:
5809
5707
sort = tag_sort_methods.get()
5810
5708
sort(branch, tags)
5815
5713
revno = branch.revision_id_to_dotted_revno(revid)
5816
5714
if isinstance(revno, tuple):
5817
5715
revno = '.'.join(map(str, revno))
5818
except (errors.NoSuchRevision,
5819
errors.GhostRevisionsHaveNoRevno,
5820
errors.UnsupportedOperation):
5716
except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
5821
5717
# Bad tag data/merges can lead to tagged revisions
5822
5718
# which are not in this branch. Fail gracefully ...
5826
5722
for tag, revspec in tags:
5827
5723
self.outf.write('%-20s %s\n' % (tag, revspec))
5829
def _tags_for_range(self, branch, revision):
5831
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5832
revid1, revid2 = rev1.rev_id, rev2.rev_id
5833
# _get_revision_range will always set revid2 if it's not specified.
5834
# If revid1 is None, it means we want to start from the branch
5835
# origin which is always a valid ancestor. If revid1 == revid2, the
5836
# ancestry check is useless.
5837
if revid1 and revid1 != revid2:
5838
# FIXME: We really want to use the same graph than
5839
# branch.iter_merge_sorted_revisions below, but this is not
5840
# easily available -- vila 2011-09-23
5841
if branch.repository.get_graph().is_ancestor(revid2, revid1):
5842
# We don't want to output anything in this case...
5844
# only show revisions between revid1 and revid2 (inclusive)
5845
tagged_revids = branch.tags.get_reverse_tag_dict()
5847
for r in branch.iter_merge_sorted_revisions(
5848
start_revision_id=revid2, stop_revision_id=revid1,
5849
stop_rule='include'):
5850
revid_tags = tagged_revids.get(r[0], None)
5852
found.extend([(tag, r[0]) for tag in revid_tags])
5856
5726
class cmd_reconfigure(Command):
5857
5727
__doc__ = """Reconfigure the type of a bzr directory.
5871
5741
takes_args = ['location?']
5872
5742
takes_options = [
5873
5743
RegistryOption.from_kwargs(
5876
help='The relation between branch and tree.',
5745
title='Target type',
5746
help='The type to reconfigure the directory to.',
5877
5747
value_switches=True, enum_switch=False,
5878
5748
branch='Reconfigure to be an unbound branch with no working tree.',
5879
5749
tree='Reconfigure to be an unbound branch with a working tree.',
5880
5750
checkout='Reconfigure to be a bound branch with a working tree.',
5881
5751
lightweight_checkout='Reconfigure to be a lightweight'
5882
5752
' checkout (with no local history).',
5884
RegistryOption.from_kwargs(
5886
title='Repository type',
5887
help='Location fo the repository.',
5888
value_switches=True, enum_switch=False,
5889
5753
standalone='Reconfigure to be a standalone branch '
5890
5754
'(i.e. stop using shared repository).',
5891
5755
use_shared='Reconfigure to use a shared repository.',
5893
RegistryOption.from_kwargs(
5895
title='Trees in Repository',
5896
help='Whether new branches in the repository have trees.',
5897
value_switches=True, enum_switch=False,
5898
5756
with_trees='Reconfigure repository to create '
5899
5757
'working trees on branches by default.',
5900
5758
with_no_trees='Reconfigure repository to not create '
5917
def run(self, location=None, bind_to=None, force=False,
5918
tree_type=None, repository_type=None, repository_trees=None,
5919
stacked_on=None, unstacked=None):
5775
def run(self, location=None, target_type=None, bind_to=None, force=False,
5920
5778
directory = bzrdir.BzrDir.open(location)
5921
5779
if stacked_on and unstacked:
5922
raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5780
raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
5923
5781
elif stacked_on is not None:
5924
5782
reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5925
5783
elif unstacked:
5927
5785
# At the moment you can use --stacked-on and a different
5928
5786
# reconfiguration shape at the same time; there seems no good reason
5930
if (tree_type is None and
5931
repository_type is None and
5932
repository_trees is None):
5788
if target_type is None:
5933
5789
if stacked_on or unstacked:
5936
raise errors.BzrCommandError(gettext('No target configuration '
5938
reconfiguration = None
5939
if tree_type == 'branch':
5792
raise errors.BzrCommandError('No target configuration '
5794
elif target_type == 'branch':
5940
5795
reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5941
elif tree_type == 'tree':
5796
elif target_type == 'tree':
5942
5797
reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5943
elif tree_type == 'checkout':
5798
elif target_type == 'checkout':
5944
5799
reconfiguration = reconfigure.Reconfigure.to_checkout(
5945
5800
directory, bind_to)
5946
elif tree_type == 'lightweight-checkout':
5801
elif target_type == 'lightweight-checkout':
5947
5802
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5948
5803
directory, bind_to)
5950
reconfiguration.apply(force)
5951
reconfiguration = None
5952
if repository_type == 'use-shared':
5804
elif target_type == 'use-shared':
5953
5805
reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5954
elif repository_type == 'standalone':
5806
elif target_type == 'standalone':
5955
5807
reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5957
reconfiguration.apply(force)
5958
reconfiguration = None
5959
if repository_trees == 'with-trees':
5808
elif target_type == 'with-trees':
5960
5809
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5961
5810
directory, True)
5962
elif repository_trees == 'with-no-trees':
5811
elif target_type == 'with-no-trees':
5963
5812
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5964
5813
directory, False)
5966
reconfiguration.apply(force)
5967
reconfiguration = None
5814
reconfiguration.apply(force)
5970
5817
class cmd_switch(Command):
6158
6005
name = current_view
6161
raise errors.BzrCommandError(gettext(
6162
"Both --delete and a file list specified"))
6008
raise errors.BzrCommandError(
6009
"Both --delete and a file list specified")
6164
raise errors.BzrCommandError(gettext(
6165
"Both --delete and --switch specified"))
6011
raise errors.BzrCommandError(
6012
"Both --delete and --switch specified")
6167
6014
tree.views.set_view_info(None, {})
6168
self.outf.write(gettext("Deleted all views.\n"))
6015
self.outf.write("Deleted all views.\n")
6169
6016
elif name is None:
6170
raise errors.BzrCommandError(gettext("No current view to delete"))
6017
raise errors.BzrCommandError("No current view to delete")
6172
6019
tree.views.delete_view(name)
6173
self.outf.write(gettext("Deleted '%s' view.\n") % name)
6020
self.outf.write("Deleted '%s' view.\n" % name)
6176
raise errors.BzrCommandError(gettext(
6177
"Both --switch and a file list specified"))
6023
raise errors.BzrCommandError(
6024
"Both --switch and a file list specified")
6179
raise errors.BzrCommandError(gettext(
6180
"Both --switch and --all specified"))
6026
raise errors.BzrCommandError(
6027
"Both --switch and --all specified")
6181
6028
elif switch == 'off':
6182
6029
if current_view is None:
6183
raise errors.BzrCommandError(gettext("No current view to disable"))
6030
raise errors.BzrCommandError("No current view to disable")
6184
6031
tree.views.set_view_info(None, view_dict)
6185
self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
6032
self.outf.write("Disabled '%s' view.\n" % (current_view))
6187
6034
tree.views.set_view_info(switch, view_dict)
6188
6035
view_str = views.view_display_str(tree.views.lookup_view())
6189
self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
6036
self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
6192
self.outf.write(gettext('Views defined:\n'))
6039
self.outf.write('Views defined:\n')
6193
6040
for view in sorted(view_dict):
6194
6041
if view == current_view:
6198
6045
view_str = views.view_display_str(view_dict[view])
6199
6046
self.outf.write('%s %-20s %s\n' % (active, view, view_str))
6201
self.outf.write(gettext('No views defined.\n'))
6048
self.outf.write('No views defined.\n')
6202
6049
elif file_list:
6203
6050
if name is None:
6204
6051
# No name given and no current view set
6206
6053
elif name == 'off':
6207
raise errors.BzrCommandError(gettext(
6208
"Cannot change the 'off' pseudo view"))
6054
raise errors.BzrCommandError(
6055
"Cannot change the 'off' pseudo view")
6209
6056
tree.views.set_view(name, sorted(file_list))
6210
6057
view_str = views.view_display_str(tree.views.lookup_view())
6211
self.outf.write(gettext("Using '{0}' view: {1}\n").format(name, view_str))
6058
self.outf.write("Using '%s' view: %s\n" % (name, view_str))
6213
6060
# list the files
6214
6061
if name is None:
6215
6062
# No name given and no current view set
6216
self.outf.write(gettext('No current view.\n'))
6063
self.outf.write('No current view.\n')
6218
6065
view_str = views.view_display_str(tree.views.lookup_view(name))
6219
self.outf.write(gettext("'{0}' view is: {1}\n").format(name, view_str))
6066
self.outf.write("'%s' view is: %s\n" % (name, view_str))
6222
6069
class cmd_hooks(Command):
6472
6319
__doc__ = """Export command helps and error messages in po format."""
6475
takes_options = [Option('plugin',
6476
help='Export help text from named command '\
6477
'(defaults to all built in commands).',
6480
def run(self, plugin=None):
6481
6324
from bzrlib.export_pot import export_pot
6482
export_pot(self.outf, plugin)
6325
export_pot(self.outf)
6485
6328
def _register_lazy_builtins():