57
57
from bzrlib.revisionspec import RevisionSpec, RevisionInfo
58
58
from bzrlib.smtp_connection import SMTPConnection
59
59
from bzrlib.workingtree import WorkingTree
60
from bzrlib.i18n import gettext
62
63
from bzrlib.commands import (
288
289
from bzrlib.status import show_tree_status
290
291
if revision and len(revision) > 2:
291
raise errors.BzrCommandError('bzr status --revision takes exactly'
292
' one or two revision specifiers')
292
raise errors.BzrCommandError(gettext('bzr status --revision takes exactly'
293
' one or two revision specifiers'))
294
295
tree, relfile_list = WorkingTree.open_containing_paths(file_list)
295
296
# Avoid asking for specific files when that is not needed.
333
334
def run(self, revision_id=None, revision=None, directory=u'.'):
334
335
if revision_id is not None and revision is not None:
335
raise errors.BzrCommandError('You can only supply one of'
336
' revision_id or --revision')
336
raise errors.BzrCommandError(gettext('You can only supply one of'
337
' revision_id or --revision'))
337
338
if revision_id is None and revision is None:
338
raise errors.BzrCommandError('You must supply either'
339
' --revision or a revision_id')
339
raise errors.BzrCommandError(gettext('You must supply either'
340
' --revision or a revision_id'))
341
342
b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
343
344
revisions = b.repository.revisions
344
345
if revisions is None:
345
raise errors.BzrCommandError('Repository %r does not support '
346
'access to raw revision texts')
346
raise errors.BzrCommandError(gettext('Repository %r does not support '
347
'access to raw revision texts'))
348
349
b.repository.lock_read()
354
355
self.print_revision(revisions, revision_id)
355
356
except errors.NoSuchRevision:
356
msg = "The repository %s contains no revision %s." % (
357
msg = gettext("The repository {0} contains no revision {1}.").format(
357
358
b.repository.base, revision_id)
358
359
raise errors.BzrCommandError(msg)
359
360
elif revision is not None:
360
361
for rev in revision:
362
363
raise errors.BzrCommandError(
363
'You cannot specify a NULL revision.')
364
gettext('You cannot specify a NULL revision.'))
364
365
rev_id = rev.as_revision_id(b)
365
366
self.print_revision(revisions, rev_id)
478
479
working = d.open_workingtree()
479
480
except errors.NoWorkingTree:
480
raise errors.BzrCommandError("No working tree to remove")
481
raise errors.BzrCommandError(gettext("No working tree to remove"))
481
482
except errors.NotLocalUrl:
482
raise errors.BzrCommandError("You cannot remove the working tree"
483
raise errors.BzrCommandError(gettext("You cannot remove the working tree"
484
" of a remote path"))
485
486
if (working.has_changes()):
486
487
raise errors.UncommittedChanges(working)
488
489
raise errors.ShelvedChanges(working)
490
491
if working.user_url != working.branch.user_url:
491
raise errors.BzrCommandError("You cannot remove the working tree"
492
" from a lightweight checkout")
492
raise errors.BzrCommandError(gettext("You cannot remove the working tree"
493
" from a lightweight checkout"))
494
495
d.destroy_workingtree()
527
528
pass # There seems to be a real error here, so we'll reset
530
raise errors.BzrCommandError(
531
raise errors.BzrCommandError(gettext(
531
532
'The tree does not appear to be corrupt. You probably'
532
533
' want "bzr revert" instead. Use "--force" if you are'
533
' sure you want to reset the working tree.')
534
' sure you want to reset the working tree.'))
534
535
if revision is None:
535
536
revision_ids = None
539
540
tree.reset_state(revision_ids)
540
541
except errors.BzrError, e:
541
542
if revision_ids is None:
542
extra = (', the header appears corrupt, try passing -r -1'
543
' to set the state to the last commit')
543
extra = (gettext(', the header appears corrupt, try passing -r -1'
544
' to set the state to the last commit'))
546
raise errors.BzrCommandError('failed to reset the tree state'
547
raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
550
550
class cmd_revno(Command):
706
710
action = bzrlib.add.AddFromBaseAction(base_tree, base_path,
707
711
to_file=self.outf, should_print=(not is_quiet()))
709
action = bzrlib.add.AddAction(to_file=self.outf,
713
action = bzrlib.add.AddWithSkipLargeAction(to_file=self.outf,
710
714
should_print=(not is_quiet()))
785
790
def run(self, revision=None, show_ids=False, kind=None, file_list=None):
786
791
if kind and kind not in ['file', 'directory', 'symlink']:
787
raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
792
raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
789
794
revision = _get_one_revision('inventory', revision)
790
795
work_tree, file_list = WorkingTree.open_containing_paths(file_list)
855
860
return self.run_auto(names_list, after, dry_run)
857
raise errors.BzrCommandError('--dry-run requires --auto.')
862
raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
858
863
if names_list is None:
860
865
if len(names_list) < 2:
861
raise errors.BzrCommandError("missing file argument")
866
raise errors.BzrCommandError(gettext("missing file argument"))
862
867
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
863
868
self.add_cleanup(tree.lock_tree_write().unlock)
864
869
self._run(tree, names_list, rel_names, after)
866
871
def run_auto(self, names_list, after, dry_run):
867
872
if names_list is not None and len(names_list) > 1:
868
raise errors.BzrCommandError('Only one path may be specified to'
873
raise errors.BzrCommandError(gettext('Only one path may be specified to'
871
raise errors.BzrCommandError('--after cannot be specified with'
876
raise errors.BzrCommandError(gettext('--after cannot be specified with'
873
878
work_tree, file_list = WorkingTree.open_containing_paths(
874
879
names_list, default_directory='.')
875
880
self.add_cleanup(work_tree.lock_tree_write().unlock)
905
910
self.outf.write("%s => %s\n" % (src, dest))
907
912
if len(names_list) != 2:
908
raise errors.BzrCommandError('to mv multiple files the'
913
raise errors.BzrCommandError(gettext('to mv multiple files the'
909
914
' destination must be a versioned'
912
917
# for cicp file-systems: the src references an existing inventory
973
978
branches have diverged.
975
980
If there is no default location set, the first pull will set it (use
976
--no-remember to avoid settting it). After that, you can omit the
981
--no-remember to avoid setting it). After that, you can omit the
977
982
location to use the default. To change the default, use --remember. The
978
983
value will only be saved if the remote location can be accessed.
1019
1024
self.add_cleanup(branch_to.lock_write().unlock)
1021
1026
if tree_to is None and show_base:
1022
raise errors.BzrCommandError("Need working tree for --show-base.")
1027
raise errors.BzrCommandError(gettext("Need working tree for --show-base."))
1024
1029
if local and not branch_to.get_bound_location():
1025
1030
raise errors.LocalRequiresBoundBranch()
1035
1040
stored_loc = branch_to.get_parent()
1036
1041
if location is None:
1037
1042
if stored_loc is None:
1038
raise errors.BzrCommandError("No pull location known or"
1043
raise errors.BzrCommandError(gettext("No pull location known or"
1041
1046
display_url = urlutils.unescape_for_display(stored_loc,
1042
1047
self.outf.encoding)
1043
1048
if not is_quiet():
1044
self.outf.write("Using saved parent location: %s\n" % display_url)
1049
self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1045
1050
location = stored_loc
1047
1052
revision = _get_one_revision('pull', revision)
1048
1053
if mergeable is not None:
1049
1054
if revision is not None:
1050
raise errors.BzrCommandError(
1051
'Cannot use -r with merge directives or bundles')
1055
raise errors.BzrCommandError(gettext(
1056
'Cannot use -r with merge directives or bundles'))
1052
1057
mergeable.install_revisions(branch_to.repository)
1053
1058
base_revision_id, revision_id, verified = \
1054
1059
mergeable.get_merge_request(branch_to.repository)
1072
1077
view_info=view_info)
1073
1078
result = tree_to.pull(
1074
1079
branch_from, overwrite, revision_id, change_reporter,
1075
possible_transports=possible_transports, local=local,
1076
show_base=show_base)
1080
local=local, show_base=show_base)
1078
1082
result = branch_to.pull(
1079
1083
branch_from, overwrite, revision_id, local=local)
1110
1114
After that you will be able to do a push without '--overwrite'.
1112
1116
If there is no default push location set, the first push will set it (use
1113
--no-remember to avoid settting it). After that, you can omit the
1117
--no-remember to avoid setting it). After that, you can omit the
1114
1118
location to use the default. To change the default, use --remember. The
1115
1119
value will only be saved if the remote location can be accessed.
1183
1187
# error by the feedback given to them. RBC 20080227.
1184
1188
stacked_on = parent_url
1185
1189
if not stacked_on:
1186
raise errors.BzrCommandError(
1187
"Could not determine branch to refer to.")
1190
raise errors.BzrCommandError(gettext(
1191
"Could not determine branch to refer to."))
1189
1193
# Get the destination location
1190
1194
if location is None:
1191
1195
stored_loc = br_from.get_push_location()
1192
1196
if stored_loc is None:
1193
raise errors.BzrCommandError(
1194
"No push location known or specified.")
1197
raise errors.BzrCommandError(gettext(
1198
"No push location known or specified."))
1196
1200
display_url = urlutils.unescape_for_display(stored_loc,
1197
1201
self.outf.encoding)
1198
note("Using saved push location: %s" % display_url)
1202
note(gettext("Using saved push location: %s") % display_url)
1199
1203
location = stored_loc
1201
1205
_show_push_branch(br_from, revision_id, location, self.outf,
1284
1288
to_transport.mkdir('.')
1285
1289
except errors.FileExists:
1286
1290
if not use_existing_dir:
1287
raise errors.BzrCommandError('Target directory "%s" '
1288
'already exists.' % to_location)
1291
raise errors.BzrCommandError(gettext('Target directory "%s" '
1292
'already exists.') % to_location)
1291
1295
bzrdir.BzrDir.open_from_transport(to_transport)
1308
1312
branch = dir.open_branch()
1309
1313
except errors.NoSuchRevision:
1310
1314
to_transport.delete_tree('.')
1311
msg = "The branch %s has no revision %s." % (from_location,
1315
msg = gettext("The branch {0} has no revision {1}.").format(
1316
from_location, revision)
1313
1317
raise errors.BzrCommandError(msg)
1314
1318
_merge_tags_if_possible(br_from, branch)
1315
1319
# If the source branch is stacked, the new branch may
1316
1320
# be stacked whether we asked for that explicitly or not.
1317
1321
# We therefore need a try/except here and not just 'if stacked:'
1319
note('Created new stacked branch referring to %s.' %
1323
note(gettext('Created new stacked branch referring to %s.') %
1320
1324
branch.get_stacked_on_url())
1321
1325
except (errors.NotStacked, errors.UnstackableBranchFormat,
1322
1326
errors.UnstackableRepositoryFormat), e:
1323
note('Branched %d revision(s).' % branch.revno())
1327
note(gettext('Branched %d revision(s).') % branch.revno())
1325
1329
# Bind to the parent
1326
1330
parent_branch = Branch.open(from_location)
1327
1331
branch.bind(parent_branch)
1328
note('New branch bound to %s' % from_location)
1332
note(gettext('New branch bound to %s') % from_location)
1330
1334
# Switch to the new branch
1331
1335
wt, _ = WorkingTree.open_containing('.')
1332
1336
_mod_switch.switch(wt.bzrdir, branch)
1333
note('Switched to branch: %s',
1337
note(gettext('Switched to branch: %s'),
1334
1338
urlutils.unescape_for_display(branch.base, 'utf-8'))
1341
class cmd_branches(Command):
1342
__doc__ = """List the branches available at the current location.
1344
This command will print the names of all the branches at the current location.
1347
takes_args = ['location?']
1349
def run(self, location="."):
1350
dir = bzrdir.BzrDir.open_containing(location)[0]
1351
for branch in dir.list_branches():
1352
if branch.name is None:
1353
self.outf.write(gettext(" (default)\n"))
1355
self.outf.write(" %s\n" % branch.name.encode(self.outf.encoding))
1337
1358
class cmd_checkout(Command):
1338
1359
__doc__ = """Create a new checkout of an existing branch.
1466
1487
def run(self, dir='.', revision=None, show_base=None):
1467
1488
if revision is not None and len(revision) != 1:
1468
raise errors.BzrCommandError(
1469
"bzr update --revision takes exactly one revision")
1489
raise errors.BzrCommandError(gettext(
1490
"bzr update --revision takes exactly one revision"))
1470
1491
tree = WorkingTree.open_containing(dir)[0]
1471
1492
branch = tree.branch
1472
1493
possible_transports = []
1497
1518
revision_id = branch.last_revision()
1498
1519
if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1499
1520
revno = branch.revision_id_to_dotted_revno(revision_id)
1500
note("Tree is up to date at revision %s of branch %s" %
1501
('.'.join(map(str, revno)), branch_location))
1521
note(gettext("Tree is up to date at revision {0} of branch {1}"
1522
).format('.'.join(map(str, revno)), branch_location))
1503
1524
view_info = _get_view_info_for_change_reporter(tree)
1504
1525
change_reporter = delta._ChangeReporter(
1512
1533
old_tip=old_tip,
1513
1534
show_base=show_base)
1514
1535
except errors.NoSuchRevision, e:
1515
raise errors.BzrCommandError(
1536
raise errors.BzrCommandError(gettext(
1516
1537
"branch has no revision %s\n"
1517
1538
"bzr update --revision only works"
1518
" for a revision in the branch history"
1539
" for a revision in the branch history")
1519
1540
% (e.revision))
1520
1541
revno = tree.branch.revision_id_to_dotted_revno(
1521
1542
_mod_revision.ensure_null(tree.last_revision()))
1522
note('Updated to revision %s of branch %s' %
1523
('.'.join(map(str, revno)), branch_location))
1543
note(gettext('Updated to revision {0} of branch {1}').format(
1544
'.'.join(map(str, revno)), branch_location))
1524
1545
parent_ids = tree.get_parent_ids()
1525
1546
if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1526
note('Your local commits will now show as pending merges with '
1527
"'bzr status', and can be committed with 'bzr commit'.")
1547
note(gettext('Your local commits will now show as pending merges with '
1548
"'bzr status', and can be committed with 'bzr commit'."))
1528
1549
if conflicts != 0:
1602
1623
def run(self, file_list, verbose=False, new=False,
1603
1624
file_deletion_strategy='safe'):
1604
1625
if file_deletion_strategy == 'force':
1605
note("(The --force option is deprecated, rather use --no-backup "
1626
note(gettext("(The --force option is deprecated, rather use --no-backup "
1607
1628
file_deletion_strategy = 'no-backup'
1609
1630
tree, file_list = WorkingTree.open_containing_paths(file_list)
1619
1640
specific_files=file_list).added
1620
1641
file_list = sorted([f[0] for f in added], reverse=True)
1621
1642
if len(file_list) == 0:
1622
raise errors.BzrCommandError('No matching files.')
1643
raise errors.BzrCommandError(gettext('No matching files.'))
1623
1644
elif file_list is None:
1624
1645
# missing files show up in iter_changes(basis) as
1625
1646
# versioned-with-no-kind.
1819
1840
to_transport.ensure_base()
1820
1841
except errors.NoSuchFile:
1821
1842
if not create_prefix:
1822
raise errors.BzrCommandError("Parent directory of %s"
1843
raise errors.BzrCommandError(gettext("Parent directory of %s"
1823
1844
" does not exist."
1824
1845
"\nYou may supply --create-prefix to create all"
1825
" leading parent directories."
1846
" leading parent directories.")
1827
1848
to_transport.create_prefix()
1854
1875
branch.set_append_revisions_only(True)
1855
1876
except errors.UpgradeRequired:
1856
raise errors.BzrCommandError('This branch format cannot be set'
1857
' to append-revisions-only. Try --default.')
1877
raise errors.BzrCommandError(gettext('This branch format cannot be set'
1878
' to append-revisions-only. Try --default.'))
1858
1879
if not is_quiet():
1859
1880
from bzrlib.info import describe_layout, describe_format
1864
1885
repository = branch.repository
1865
1886
layout = describe_layout(repository, branch, tree).lower()
1866
1887
format = describe_format(a_bzrdir, repository, branch, tree)
1867
self.outf.write("Created a %s (format: %s)\n" % (layout, format))
1888
self.outf.write(gettext("Created a {0} (format: {1})\n").format(
1868
1890
if repository.is_shared():
1869
1891
#XXX: maybe this can be refactored into transport.path_or_url()
1870
1892
url = repository.bzrdir.root_transport.external_url()
2069
2091
elif ':' in prefix:
2070
2092
old_label, new_label = prefix.split(":")
2072
raise errors.BzrCommandError(
2094
raise errors.BzrCommandError(gettext(
2073
2095
'--prefix expects two values separated by a colon'
2074
' (eg "old/:new/")')
2096
' (eg "old/:new/")'))
2076
2098
if revision and len(revision) > 2:
2077
raise errors.BzrCommandError('bzr diff --revision takes exactly'
2078
' one or two revision specifiers')
2099
raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
2100
' one or two revision specifiers'))
2080
2102
if using is not None and format is not None:
2081
raise errors.BzrCommandError('--using and --format are mutually '
2103
raise errors.BzrCommandError(gettext('--using and --format are mutually '
2084
2106
(old_tree, new_tree,
2085
2107
old_branch, new_branch,
2461
2483
direction = (forward and 'forward') or 'reverse'
2462
2484
if (exclude_common_ancestry
2463
2485
and (revision is None or len(revision) != 2)):
2464
raise errors.BzrCommandError(
2465
'--exclude-common-ancestry requires -r with two revisions')
2486
raise errors.BzrCommandError(gettext(
2487
'--exclude-common-ancestry requires -r with two revisions'))
2466
2488
if include_merges:
2467
2489
if levels is None:
2470
raise errors.BzrCommandError(
2471
'--levels and --include-merges are mutually exclusive')
2492
raise errors.BzrCommandError(gettext(
2493
'--levels and --include-merges are mutually exclusive'))
2473
2495
if change is not None:
2474
2496
if len(change) > 1:
2475
2497
raise errors.RangeInChangeOption()
2476
2498
if revision is not None:
2477
raise errors.BzrCommandError(
2478
'--revision and --change are mutually exclusive')
2499
raise errors.BzrCommandError(gettext(
2500
'--revision and --change are mutually exclusive'))
2480
2502
revision = change
2487
2509
revision, file_list, self.add_cleanup)
2488
2510
for relpath, file_id, kind in file_info_list:
2489
2511
if file_id is None:
2490
raise errors.BzrCommandError(
2491
"Path unknown at end or start of revision range: %s" %
2512
raise errors.BzrCommandError(gettext(
2513
"Path unknown at end or start of revision range: %s") %
2493
2515
# If the relpath is the top of the tree, we log everything
2494
2516
if relpath == '':
2604
2626
# b is taken from revision[0].get_branch(), and
2605
2627
# show_log will use its revision_history. Having
2606
2628
# different branches will lead to weird behaviors.
2607
raise errors.BzrCommandError(
2629
raise errors.BzrCommandError(gettext(
2608
2630
"bzr %s doesn't accept two revisions in different"
2609
" branches." % command_name)
2631
" branches.") % command_name)
2610
2632
if start_spec.spec is None:
2611
2633
# Avoid loading all the history.
2612
2634
rev1 = RevisionInfo(branch, None, None)
2698
2720
null=False, kind=None, show_ids=False, path=None, directory=None):
2700
2722
if kind and kind not in ('file', 'directory', 'symlink'):
2701
raise errors.BzrCommandError('invalid kind specified')
2723
raise errors.BzrCommandError(gettext('invalid kind specified'))
2703
2725
if verbose and null:
2704
raise errors.BzrCommandError('Cannot set both --verbose and --null')
2726
raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2705
2727
all = not (unknown or versioned or ignored)
2707
2729
selection = {'I':ignored, '?':unknown, 'V':versioned}
2713
raise errors.BzrCommandError('cannot specify both --from-root'
2735
raise errors.BzrCommandError(gettext('cannot specify both --from-root'
2716
2738
tree, branch, relpath = \
2717
2739
_open_directory_or_containing_tree_or_branch(fs_path, directory)
2734
2756
apply_view = True
2735
2757
view_str = views.view_display_str(view_files)
2736
note("Ignoring files outside view. View is %s" % view_str)
2758
note(gettext("Ignoring files outside view. View is %s") % view_str)
2738
2760
self.add_cleanup(tree.lock_read().unlock)
2739
2761
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2886
2908
self.outf.write("%s\n" % pattern)
2888
2910
if not name_pattern_list:
2889
raise errors.BzrCommandError("ignore requires at least one "
2890
"NAME_PATTERN or --default-rules.")
2911
raise errors.BzrCommandError(gettext("ignore requires at least one "
2912
"NAME_PATTERN or --default-rules."))
2891
2913
name_pattern_list = [globbing.normalize_pattern(p)
2892
2914
for p in name_pattern_list]
2893
2915
bad_patterns = ''
2901
2923
for name_pattern in name_pattern_list:
2902
2924
if (name_pattern[0] == '/' or
2903
2925
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2904
raise errors.BzrCommandError(
2905
"NAME_PATTERN should not be an absolute path")
2926
raise errors.BzrCommandError(gettext(
2927
"NAME_PATTERN should not be an absolute path"))
2906
2928
tree, relpath = WorkingTree.open_containing(directory)
2907
2929
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2908
2930
ignored = globbing.Globster(name_pattern_list)
2915
2937
if ignored.match(filename):
2916
2938
matches.append(filename)
2917
2939
if len(matches) > 0:
2918
self.outf.write("Warning: the following files are version controlled and"
2919
" match your ignore pattern:\n%s"
2940
self.outf.write(gettext("Warning: the following files are version "
2941
"controlled and match your ignore pattern:\n%s"
2920
2942
"\nThese files will continue to be version controlled"
2921
" unless you 'bzr remove' them.\n" % ("\n".join(matches),))
2943
" unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2924
2946
class cmd_ignored(Command):
3030
3052
export(rev_tree, dest, format, root, subdir, filtered=filters,
3031
3053
per_file_timestamps=per_file_timestamps)
3032
3054
except errors.NoSuchExportFormat, e:
3033
raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
3055
raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
3036
3058
class cmd_cat(Command):
3056
3078
def run(self, filename, revision=None, name_from_revision=False,
3057
3079
filters=False, directory=None):
3058
3080
if revision is not None and len(revision) != 1:
3059
raise errors.BzrCommandError("bzr cat --revision takes exactly"
3060
" one revision specifier")
3081
raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
3082
" one revision specifier"))
3061
3083
tree, branch, relpath = \
3062
3084
_open_directory_or_containing_tree_or_branch(filename, directory)
3063
3085
self.add_cleanup(branch.lock_read().unlock)
3080
3102
if name_from_revision:
3081
3103
# Try in revision if requested
3082
3104
if old_file_id is None:
3083
raise errors.BzrCommandError(
3084
"%r is not present in revision %s" % (
3105
raise errors.BzrCommandError(gettext(
3106
"{0!r} is not present in revision {1}").format(
3085
3107
filename, rev_tree.get_revision_id()))
3087
3109
actual_file_id = old_file_id
3092
3114
elif old_file_id is not None:
3093
3115
actual_file_id = old_file_id
3095
raise errors.BzrCommandError(
3096
"%r is not present in revision %s" % (
3117
raise errors.BzrCommandError(gettext(
3118
"{0!r} is not present in revision {1}").format(
3097
3119
filename, rev_tree.get_revision_id()))
3099
3121
from bzrlib.filter_tree import ContentFilterTree
3216
3238
aliases = ['ci', 'checkin']
3218
3240
def _iter_bug_fix_urls(self, fixes, branch):
3241
default_bugtracker = None
3219
3242
# Configure the properties for bug fixing attributes.
3220
3243
for fixed_bug in fixes:
3221
3244
tokens = fixed_bug.split(':')
3222
if len(tokens) != 2:
3223
raise errors.BzrCommandError(
3245
if len(tokens) == 1:
3246
if default_bugtracker is None:
3247
branch_config = branch.get_config()
3248
default_bugtracker = branch_config.get_user_option(
3250
if default_bugtracker is None:
3251
raise errors.BzrCommandError(gettext(
3252
"No tracker specified for bug %s. Use the form "
3253
"'tracker:id' or specify a default bug tracker "
3254
"using the `bugtracker` option.\nSee "
3255
"\"bzr help bugs\" for more information on this "
3256
"feature. Commit refused.") % fixed_bug)
3257
tag = default_bugtracker
3259
elif len(tokens) != 2:
3260
raise errors.BzrCommandError(gettext(
3224
3261
"Invalid bug %s. Must be in the form of 'tracker:id'. "
3225
3262
"See \"bzr help bugs\" for more information on this "
3226
"feature.\nCommit refused." % fixed_bug)
3227
tag, bug_id = tokens
3263
"feature.\nCommit refused.") % fixed_bug)
3265
tag, bug_id = tokens
3229
3267
yield bugtracker.get_bug_url(tag, branch, bug_id)
3230
3268
except errors.UnknownBugTrackerAbbreviation:
3231
raise errors.BzrCommandError(
3232
'Unrecognized bug %s. Commit refused.' % fixed_bug)
3269
raise errors.BzrCommandError(gettext(
3270
'Unrecognized bug %s. Commit refused.') % fixed_bug)
3233
3271
except errors.MalformedBugIdentifier, e:
3234
raise errors.BzrCommandError(
3235
"%s\nCommit refused." % (str(e),))
3272
raise errors.BzrCommandError(gettext(
3273
"%s\nCommit refused.") % (str(e),))
3237
3275
def run(self, message=None, file=None, verbose=False, selected_list=None,
3238
3276
unchanged=False, strict=False, local=False, fixes=None,
3256
3294
commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3257
3295
except ValueError, e:
3258
raise errors.BzrCommandError(
3259
"Could not parse --commit-time: " + str(e))
3296
raise errors.BzrCommandError(gettext(
3297
"Could not parse --commit-time: " + str(e)))
3261
3299
properties = {}
3295
3333
message = message.replace('\r\n', '\n')
3296
3334
message = message.replace('\r', '\n')
3298
raise errors.BzrCommandError(
3299
"please specify either --message or --file")
3336
raise errors.BzrCommandError(gettext(
3337
"please specify either --message or --file"))
3301
3339
def get_message(commit_obj):
3302
3340
"""Callback to get commit message"""
3325
3363
my_message = edit_commit_message_encoded(text,
3326
3364
start_message=start_message)
3327
3365
if my_message is None:
3328
raise errors.BzrCommandError("please specify a commit"
3329
" message with either --message or --file")
3330
if my_message == "":
3331
raise errors.BzrCommandError("Empty commit message specified."
3332
" Please specify a commit message with either"
3333
" --message or --file or leave a blank message"
3334
" with --message \"\".")
3366
raise errors.BzrCommandError(gettext("please specify a commit"
3367
" message with either --message or --file"))
3368
if my_message == "":
3369
raise errors.BzrCommandError(gettext("Empty commit message specified."
3370
" Please specify a commit message with either"
3371
" --message or --file or leave a blank message"
3372
" with --message \"\"."))
3335
3373
return my_message
3337
3375
# The API permits a commit with a filter of [] to mean 'select nothing'
3348
3386
exclude=tree.safe_relpath_files(exclude),
3350
3388
except PointlessCommit:
3351
raise errors.BzrCommandError("No changes to commit."
3389
raise errors.BzrCommandError(gettext("No changes to commit."
3352
3390
" Please 'bzr add' the files you want to commit, or use"
3353
" --unchanged to force an empty commit.")
3391
" --unchanged to force an empty commit."))
3354
3392
except ConflictsInTree:
3355
raise errors.BzrCommandError('Conflicts detected in working '
3393
raise errors.BzrCommandError(gettext('Conflicts detected in working '
3356
3394
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
3358
3396
except StrictCommitFailed:
3359
raise errors.BzrCommandError("Commit refused because there are"
3360
" unknown files in the working tree.")
3397
raise errors.BzrCommandError(gettext("Commit refused because there are"
3398
" unknown files in the working tree."))
3361
3399
except errors.BoundBranchOutOfDate, e:
3362
e.extra_help = ("\n"
3400
e.extra_help = (gettext("\n"
3363
3401
'To commit to master branch, run update and then commit.\n'
3364
3402
'You can also pass --local to commit to continue working '
3622
3660
def remove_alias(self, alias_name):
3623
3661
if alias_name is None:
3624
raise errors.BzrCommandError(
3625
'bzr alias --remove expects an alias to remove.')
3662
raise errors.BzrCommandError(gettext(
3663
'bzr alias --remove expects an alias to remove.'))
3626
3664
# If alias is not found, print something like:
3627
3665
# unalias: foo: not found
3628
3666
c = _mod_config.GlobalConfig()
3766
3804
param_name='starting_with', short_name='s',
3768
3806
'Load only the tests starting with TESTID.'),
3808
help="By default we disable fsync and fdatasync"
3809
" while running the test suite.")
3770
3811
encoding_type = 'replace'
3779
3820
first=False, list_only=False,
3780
3821
randomize=None, exclude=None, strict=False,
3781
3822
load_list=None, debugflag=None, starting_with=None, subunit=False,
3782
parallel=None, lsprof_tests=False):
3823
parallel=None, lsprof_tests=False,
3783
3825
from bzrlib import tests
3785
3827
if testspecs_list is not None:
3791
3833
from bzrlib.tests import SubUnitBzrRunner
3792
3834
except ImportError:
3793
raise errors.BzrCommandError("subunit not available. subunit "
3794
"needs to be installed to use --subunit.")
3835
raise errors.BzrCommandError(gettext("subunit not available. subunit "
3836
"needs to be installed to use --subunit."))
3795
3837
self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3796
3838
# On Windows, disable automatic conversion of '\n' to '\r\n' in
3797
3839
# stdout, which would corrupt the subunit stream.
3806
3848
self.additional_selftest_args.setdefault(
3807
3849
'suite_decorators', []).append(parallel)
3809
raise errors.BzrCommandError(
3851
raise errors.BzrCommandError(gettext(
3810
3852
"--benchmark is no longer supported from bzr 2.2; "
3811
"use bzr-usertest instead")
3853
"use bzr-usertest instead"))
3812
3854
test_suite_factory = None
3813
3855
if not exclude:
3814
3856
exclude_pattern = None
3816
3858
exclude_pattern = '(' + '|'.join(exclude) + ')'
3860
self._disable_fsync()
3817
3861
selftest_kwargs = {"verbose": verbose,
3818
3862
"pattern": pattern,
3819
3863
"stop_on_failure": one,
3842
3886
return int(not result)
3888
def _disable_fsync(self):
3889
"""Change the 'os' functionality to not synchronize."""
3890
self._orig_fsync = getattr(os, 'fsync', None)
3891
if self._orig_fsync is not None:
3892
os.fsync = lambda filedes: None
3893
self._orig_fdatasync = getattr(os, 'fdatasync', None)
3894
if self._orig_fdatasync is not None:
3895
os.fdatasync = lambda filedes: None
3845
3898
class cmd_version(Command):
3846
3899
__doc__ = """Show version of bzr."""
3890
3943
graph = branch1.repository.get_graph(branch2.repository)
3891
3944
base_rev_id = graph.find_unique_lca(last1, last2)
3893
self.outf.write('merge base is revision %s\n' % base_rev_id)
3946
self.outf.write(gettext('merge base is revision %s\n') % base_rev_id)
3896
3949
class cmd_merge(Command):
3929
3982
Use bzr resolve when you have fixed a problem. See also bzr conflicts.
3931
3984
If there is no default branch set, the first merge will set it (use
3932
--no-remember to avoid settting it). After that, you can omit the branch
3985
--no-remember to avoid setting it). After that, you can omit the branch
3933
3986
to use the default. To change the default, use --remember. The value will
3934
3987
only be saved if the remote location can be accessed.
4022
4075
tree = WorkingTree.open_containing(directory)[0]
4023
4076
if tree.branch.revno() == 0:
4024
raise errors.BzrCommandError('Merging into empty branches not currently supported, '
4025
'https://bugs.launchpad.net/bzr/+bug/308562')
4077
raise errors.BzrCommandError(gettext('Merging into empty branches not currently supported, '
4078
'https://bugs.launchpad.net/bzr/+bug/308562'))
4028
4081
basis_tree = tree.revision_tree(tree.last_revision())
4048
4101
mergeable = None
4050
4103
if uncommitted:
4051
raise errors.BzrCommandError('Cannot use --uncommitted'
4052
' with bundles or merge directives.')
4104
raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4105
' with bundles or merge directives.'))
4054
4107
if revision is not None:
4055
raise errors.BzrCommandError(
4056
'Cannot use -r with merge directives or bundles')
4108
raise errors.BzrCommandError(gettext(
4109
'Cannot use -r with merge directives or bundles'))
4057
4110
merger, verified = _mod_merge.Merger.from_mergeable(tree,
4058
4111
mergeable, None)
4060
4113
if merger is None and uncommitted:
4061
4114
if revision is not None and len(revision) > 0:
4062
raise errors.BzrCommandError('Cannot use --uncommitted and'
4063
' --revision at the same time.')
4115
raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4116
' --revision at the same time.'))
4064
4117
merger = self.get_merger_from_uncommitted(tree, location, None)
4065
4118
allow_pending = False
4079
4132
if merger.interesting_files:
4080
4133
if not merger.other_tree.has_filename(
4081
4134
merger.interesting_files[0]):
4082
note("merger: " + str(merger))
4135
note(gettext("merger: ") + str(merger))
4083
4136
raise errors.PathsDoNotExist([location])
4084
note('Nothing to do.')
4137
note(gettext('Nothing to do.'))
4086
4139
if pull and not preview:
4087
4140
if merger.interesting_files is not None:
4088
raise errors.BzrCommandError('Cannot pull individual files')
4141
raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4089
4142
if (merger.base_rev_id == tree.last_revision()):
4090
4143
result = tree.pull(merger.other_branch, False,
4091
4144
merger.other_rev_id)
4092
4145
result.report(self.outf)
4094
4147
if merger.this_basis is None:
4095
raise errors.BzrCommandError(
4148
raise errors.BzrCommandError(gettext(
4096
4149
"This branch has no commits."
4097
" (perhaps you would prefer 'bzr pull')")
4150
" (perhaps you would prefer 'bzr pull')"))
4099
4152
return self._do_preview(merger)
4100
4153
elif interactive:
4151
4204
def sanity_check_merger(self, merger):
4152
4205
if (merger.show_base and
4153
4206
not merger.merge_type is _mod_merge.Merge3Merger):
4154
raise errors.BzrCommandError("Show-base is not supported for this"
4155
" merge type. %s" % merger.merge_type)
4207
raise errors.BzrCommandError(gettext("Show-base is not supported for this"
4208
" merge type. %s") % merger.merge_type)
4156
4209
if merger.reprocess is None:
4157
4210
if merger.show_base:
4158
4211
merger.reprocess = False
4160
4213
# Use reprocess if the merger supports it
4161
4214
merger.reprocess = merger.merge_type.supports_reprocess
4162
4215
if merger.reprocess and not merger.merge_type.supports_reprocess:
4163
raise errors.BzrCommandError("Conflict reduction is not supported"
4164
" for merge type %s." %
4216
raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
4217
" for merge type %s.") %
4165
4218
merger.merge_type)
4166
4219
if merger.reprocess and merger.show_base:
4167
raise errors.BzrCommandError("Cannot do conflict reduction and"
4220
raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4170
4223
def _get_merger_from_branch(self, tree, location, revision, remember,
4171
4224
possible_transports, pb):
4275
4328
stored_location_type = "parent"
4276
4329
mutter("%s", stored_location)
4277
4330
if stored_location is None:
4278
raise errors.BzrCommandError("No location specified or remembered")
4331
raise errors.BzrCommandError(gettext("No location specified or remembered"))
4279
4332
display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4280
note(u"%s remembered %s location %s", verb_string,
4281
stored_location_type, display_url)
4333
note(gettext("{0} remembered {1} location {2}").format(verb_string,
4334
stored_location_type, display_url))
4282
4335
return stored_location
4321
4374
self.add_cleanup(tree.lock_write().unlock)
4322
4375
parents = tree.get_parent_ids()
4323
4376
if len(parents) != 2:
4324
raise errors.BzrCommandError("Sorry, remerge only works after normal"
4377
raise errors.BzrCommandError(gettext("Sorry, remerge only works after normal"
4325
4378
" merges. Not cherrypicking or"
4327
4380
repository = tree.branch.repository
4328
4381
interesting_ids = None
4329
4382
new_conflicts = []
4585
4638
if other_branch is None:
4586
4639
other_branch = parent
4587
4640
if other_branch is None:
4588
raise errors.BzrCommandError("No peer location known"
4641
raise errors.BzrCommandError(gettext("No peer location known"
4590
4643
display_url = urlutils.unescape_for_display(parent,
4591
4644
self.outf.encoding)
4592
message("Using saved parent location: "
4593
+ display_url + "\n")
4645
message(gettext("Using saved parent location: {0}\n").format(
4595
4648
remote_branch = Branch.open(other_branch)
4596
4649
if remote_branch.base == local_branch.base:
4636
4689
if remote_extra and not mine_only:
4637
4690
if printed_local is True:
4638
4691
message("\n\n\n")
4639
message("You are missing %d revision(s):\n" %
4692
message(gettext("You are missing %d revision(s):\n") %
4640
4693
len(remote_extra))
4641
4694
for revision in iter_log_revisions(remote_extra,
4642
4695
remote_branch.repository,
4647
4700
if mine_only and not local_extra:
4648
4701
# We checked local, and found nothing extra
4649
message('This branch is up to date.\n')
4702
message(gettext('This branch has no new revisions.\n'))
4650
4703
elif theirs_only and not remote_extra:
4651
4704
# We checked remote, and found nothing extra
4652
message('Other branch is up to date.\n')
4705
message(gettext('Other branch has no new revisions.\n'))
4653
4706
elif not (mine_only or theirs_only or local_extra or
4655
4708
# We checked both branches, and neither one had extra
4657
message("Branches are up to date.\n")
4710
message(gettext("Branches are up to date.\n"))
4658
4711
self.cleanup_now()
4659
4712
if not status_code and parent is None and other_branch is not None:
4660
4713
self.add_cleanup(local_branch.lock_write().unlock)
4822
4875
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4823
4876
if revision_id_list is not None and revision is not None:
4824
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4877
raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
4825
4878
if revision_id_list is None and revision is None:
4826
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4879
raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
4827
4880
b = WorkingTree.open_containing(directory)[0].branch
4828
4881
self.add_cleanup(b.lock_write().unlock)
4829
4882
return self._run(b, revision_id_list, revision)
4861
4914
if to_revid is None:
4862
4915
to_revno = b.revno()
4863
4916
if from_revno is None or to_revno is None:
4864
raise errors.BzrCommandError('Cannot sign a range of non-revision-history revisions')
4917
raise errors.BzrCommandError(gettext('Cannot sign a range of non-revision-history revisions'))
4865
4918
b.repository.start_write_group()
4867
4920
for revno in range(from_revno, to_revno + 1):
4899
4952
location = b.get_old_bound_location()
4900
4953
except errors.UpgradeRequired:
4901
raise errors.BzrCommandError('No location supplied. '
4902
'This format does not remember old locations.')
4954
raise errors.BzrCommandError(gettext('No location supplied. '
4955
'This format does not remember old locations.'))
4904
4957
if location is None:
4905
4958
if b.get_bound_location() is not None:
4906
raise errors.BzrCommandError('Branch is already bound')
4959
raise errors.BzrCommandError(gettext('Branch is already bound'))
4908
raise errors.BzrCommandError('No location supplied '
4909
'and no previous location known')
4961
raise errors.BzrCommandError(gettext('No location supplied '
4962
'and no previous location known'))
4910
4963
b_other = Branch.open(location)
4912
4965
b.bind(b_other)
4913
4966
except errors.DivergedBranches:
4914
raise errors.BzrCommandError('These branches have diverged.'
4915
' Try merging, and then bind again.')
4967
raise errors.BzrCommandError(gettext('These branches have diverged.'
4968
' Try merging, and then bind again.'))
4916
4969
if b.get_config().has_explicit_nickname():
4917
4970
b.nick = b_other.nick
4931
4984
def run(self, directory=u'.'):
4932
4985
b, relpath = Branch.open_containing(directory)
4933
4986
if not b.unbind():
4934
raise errors.BzrCommandError('Local branch is not bound')
4987
raise errors.BzrCommandError(gettext('Local branch is not bound'))
4937
4990
class cmd_uncommit(Command):
4958
5011
takes_options = ['verbose', 'revision',
4959
5012
Option('dry-run', help='Don\'t actually make changes.'),
4960
5013
Option('force', help='Say yes to all questions.'),
5015
help='Keep tags that point to removed revisions.'),
4961
5016
Option('local',
4962
5017
help="Only remove the commits from the local branch"
4963
5018
" when in a checkout."
4968
5023
encoding_type = 'replace'
4970
def run(self, location=None,
4971
dry_run=False, verbose=False,
4972
revision=None, force=False, local=False):
5025
def run(self, location=None, dry_run=False, verbose=False,
5026
revision=None, force=False, local=False, keep_tags=False):
4973
5027
if location is None:
4974
5028
location = u'.'
4975
5029
control, relpath = bzrdir.BzrDir.open_containing(location)
4984
5038
self.add_cleanup(tree.lock_write().unlock)
4986
5040
self.add_cleanup(b.lock_write().unlock)
4987
return self._run(b, tree, dry_run, verbose, revision, force, local=local)
5041
return self._run(b, tree, dry_run, verbose, revision, force,
4989
def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
5044
def _run(self, b, tree, dry_run, verbose, revision, force, local,
4990
5046
from bzrlib.log import log_formatter, show_log
4991
5047
from bzrlib.uncommit import uncommit
5007
5063
rev_id = b.get_rev_id(revno)
5009
5065
if rev_id is None or _mod_revision.is_null(rev_id):
5010
self.outf.write('No revisions to uncommit.\n')
5066
self.outf.write(gettext('No revisions to uncommit.\n'))
5013
5069
lf = log_formatter('short',
5022
5078
end_revision=last_revno)
5025
self.outf.write('Dry-run, pretending to remove'
5026
' the above revisions.\n')
5081
self.outf.write(gettext('Dry-run, pretending to remove'
5082
' the above revisions.\n'))
5028
self.outf.write('The above revision(s) will be removed.\n')
5084
self.outf.write(gettext('The above revision(s) will be removed.\n'))
5031
5087
if not ui.ui_factory.confirm_action(
5032
u'Uncommit these revisions',
5088
gettext(u'Uncommit these revisions'),
5033
5089
'bzrlib.builtins.uncommit',
5035
self.outf.write('Canceled\n')
5091
self.outf.write(gettext('Canceled\n'))
5038
5094
mutter('Uncommitting from {%s} to {%s}',
5039
5095
last_rev_id, rev_id)
5040
5096
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5041
revno=revno, local=local)
5042
self.outf.write('You can restore the old tip by running:\n'
5043
' bzr pull . -r revid:%s\n' % last_rev_id)
5097
revno=revno, local=local, keep_tags=keep_tags)
5098
self.outf.write(gettext('You can restore the old tip by running:\n'
5099
' bzr pull . -r revid:%s\n') % last_rev_id)
5046
5102
class cmd_break_lock(Command):
5192
5248
containing_tree = WorkingTree.open_containing(parent_dir)[0]
5193
5249
repo = containing_tree.branch.repository
5194
5250
if not repo.supports_rich_root():
5195
raise errors.BzrCommandError(
5251
raise errors.BzrCommandError(gettext(
5196
5252
"Can't join trees because %s doesn't support rich root data.\n"
5197
"You can use bzr upgrade on the repository."
5253
"You can use bzr upgrade on the repository.")
5202
5258
except errors.BadReferenceTarget, e:
5203
5259
# XXX: Would be better to just raise a nicely printable
5204
5260
# exception from the real origin. Also below. mbp 20070306
5205
raise errors.BzrCommandError("Cannot join %s. %s" %
5261
raise errors.BzrCommandError(
5262
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5209
5265
containing_tree.subsume(sub_tree)
5210
5266
except errors.BadSubsumeSource, e:
5211
raise errors.BzrCommandError("Cannot join %s. %s" %
5267
raise errors.BzrCommandError(
5268
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5215
5271
class cmd_split(Command):
5299
5355
if submit_branch is None:
5300
5356
submit_branch = branch.get_parent()
5301
5357
if submit_branch is None:
5302
raise errors.BzrCommandError('No submit branch specified or known')
5358
raise errors.BzrCommandError(gettext('No submit branch specified or known'))
5304
5360
stored_public_branch = branch.get_public_branch()
5305
5361
if public_branch is None:
5307
5363
elif stored_public_branch is None:
5308
5364
branch.set_public_branch(public_branch)
5309
5365
if not include_bundle and public_branch is None:
5310
raise errors.BzrCommandError('No public branch specified or'
5366
raise errors.BzrCommandError(gettext('No public branch specified or'
5312
5368
base_revision_id = None
5313
5369
if revision is not None:
5314
5370
if len(revision) > 2:
5315
raise errors.BzrCommandError('bzr merge-directive takes '
5316
'at most two one revision identifiers')
5371
raise errors.BzrCommandError(gettext('bzr merge-directive takes '
5372
'at most two one revision identifiers'))
5317
5373
revision_id = revision[-1].as_revision_id(branch)
5318
5374
if len(revision) == 2:
5319
5375
base_revision_id = revision[0].as_revision_id(branch)
5321
5377
revision_id = branch.last_revision()
5322
5378
revision_id = ensure_null(revision_id)
5323
5379
if revision_id == NULL_REVISION:
5324
raise errors.BzrCommandError('No revisions to bundle.')
5380
raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5325
5381
directive = merge_directive.MergeDirective2.from_objects(
5326
5382
branch.repository, revision_id, time.time(),
5327
5383
osutils.local_time_offset(), submit_branch,
5374
5430
Both the submit branch and the public branch follow the usual behavior with
5375
5431
respect to --remember: If there is no default location set, the first send
5376
will set it (use --no-remember to avoid settting it). After that, you can
5432
will set it (use --no-remember to avoid setting it). After that, you can
5377
5433
omit the location to use the default. To change the default, use
5378
5434
--remember. The value will only be saved if the location can be accessed.
5581
5637
self.add_cleanup(branch.lock_write().unlock)
5583
5639
if tag_name is None:
5584
raise errors.BzrCommandError("No tag specified to delete.")
5640
raise errors.BzrCommandError(gettext("No tag specified to delete."))
5585
5641
branch.tags.delete_tag(tag_name)
5586
note('Deleted tag %s.' % tag_name)
5642
note(gettext('Deleted tag %s.') % tag_name)
5589
5645
if len(revision) != 1:
5590
raise errors.BzrCommandError(
5646
raise errors.BzrCommandError(gettext(
5591
5647
"Tags can only be placed on a single revision, "
5593
5649
revision_id = revision[0].as_revision_id(branch)
5595
5651
revision_id = branch.last_revision()
5596
5652
if tag_name is None:
5597
5653
tag_name = branch.automatic_tag_name(revision_id)
5598
5654
if tag_name is None:
5599
raise errors.BzrCommandError(
5600
"Please specify a tag name.")
5601
if (not force) and branch.tags.has_tag(tag_name):
5655
raise errors.BzrCommandError(gettext(
5656
"Please specify a tag name."))
5658
existing_target = branch.tags.lookup_tag(tag_name)
5659
except errors.NoSuchTag:
5660
existing_target = None
5661
if not force and existing_target not in (None, revision_id):
5602
5662
raise errors.TagAlreadyExists(tag_name)
5603
branch.tags.set_tag(tag_name, revision_id)
5604
note('Created tag %s.' % tag_name)
5663
if existing_target == revision_id:
5664
note(gettext('Tag %s already exists for that revision.') % tag_name)
5666
branch.tags.set_tag(tag_name, revision_id)
5667
if existing_target is None:
5668
note(gettext('Created tag %s.') % tag_name)
5670
note(gettext('Updated tag %s.') % tag_name)
5607
5673
class cmd_tags(Command):
5677
5743
takes_args = ['location?']
5678
5744
takes_options = [
5679
5745
RegistryOption.from_kwargs(
5681
title='Target type',
5682
help='The type to reconfigure the directory to.',
5748
help='The relation between branch and tree.',
5683
5749
value_switches=True, enum_switch=False,
5684
5750
branch='Reconfigure to be an unbound branch with no working tree.',
5685
5751
tree='Reconfigure to be an unbound branch with a working tree.',
5686
5752
checkout='Reconfigure to be a bound branch with a working tree.',
5687
5753
lightweight_checkout='Reconfigure to be a lightweight'
5688
5754
' checkout (with no local history).',
5756
RegistryOption.from_kwargs(
5758
title='Repository type',
5759
help='Location fo the repository.',
5760
value_switches=True, enum_switch=False,
5689
5761
standalone='Reconfigure to be a standalone branch '
5690
5762
'(i.e. stop using shared repository).',
5691
5763
use_shared='Reconfigure to use a shared repository.',
5765
RegistryOption.from_kwargs(
5767
title='Trees in Repository',
5768
help='Whether new branches in the repository have trees.',
5769
value_switches=True, enum_switch=False,
5692
5770
with_trees='Reconfigure repository to create '
5693
5771
'working trees on branches by default.',
5694
5772
with_no_trees='Reconfigure repository to not create '
5711
def run(self, location=None, target_type=None, bind_to=None, force=False,
5789
def run(self, location=None, bind_to=None, force=False,
5790
tree_type=None, repository_type=None, repository_trees=None,
5791
stacked_on=None, unstacked=None):
5714
5792
directory = bzrdir.BzrDir.open(location)
5715
5793
if stacked_on and unstacked:
5716
raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
5794
raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5717
5795
elif stacked_on is not None:
5718
5796
reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5719
5797
elif unstacked:
5721
5799
# At the moment you can use --stacked-on and a different
5722
5800
# reconfiguration shape at the same time; there seems no good reason
5724
if target_type is None:
5802
if (tree_type is None and
5803
repository_type is None and
5804
repository_trees is None):
5725
5805
if stacked_on or unstacked:
5728
raise errors.BzrCommandError('No target configuration '
5730
elif target_type == 'branch':
5808
raise errors.BzrCommandError(gettext('No target configuration '
5810
reconfiguration = None
5811
if tree_type == 'branch':
5731
5812
reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5732
elif target_type == 'tree':
5813
elif tree_type == 'tree':
5733
5814
reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5734
elif target_type == 'checkout':
5815
elif tree_type == 'checkout':
5735
5816
reconfiguration = reconfigure.Reconfigure.to_checkout(
5736
5817
directory, bind_to)
5737
elif target_type == 'lightweight-checkout':
5818
elif tree_type == 'lightweight-checkout':
5738
5819
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5739
5820
directory, bind_to)
5740
elif target_type == 'use-shared':
5822
reconfiguration.apply(force)
5823
reconfiguration = None
5824
if repository_type == 'use-shared':
5741
5825
reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5742
elif target_type == 'standalone':
5826
elif repository_type == 'standalone':
5743
5827
reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5744
elif target_type == 'with-trees':
5829
reconfiguration.apply(force)
5830
reconfiguration = None
5831
if repository_trees == 'with-trees':
5745
5832
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5746
5833
directory, True)
5747
elif target_type == 'with-no-trees':
5834
elif repository_trees == 'with-no-trees':
5748
5835
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5749
5836
directory, False)
5750
reconfiguration.apply(force)
5838
reconfiguration.apply(force)
5839
reconfiguration = None
5753
5842
class cmd_switch(Command):
5791
5880
control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
5792
5881
if to_location is None:
5793
5882
if revision is None:
5794
raise errors.BzrCommandError('You must supply either a'
5795
' revision or a location')
5883
raise errors.BzrCommandError(gettext('You must supply either a'
5884
' revision or a location'))
5796
5885
to_location = tree_location
5798
5887
branch = control_dir.open_branch()
5826
5915
if had_explicit_nick:
5827
5916
branch = control_dir.open_branch() #get the new branch!
5828
5917
branch.nick = to_branch.nick
5829
note('Switched to branch: %s',
5918
note(gettext('Switched to branch: %s'),
5830
5919
urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5832
5921
def _get_branch_location(self, control_dir):
5941
6030
name = current_view
5944
raise errors.BzrCommandError(
5945
"Both --delete and a file list specified")
6033
raise errors.BzrCommandError(gettext(
6034
"Both --delete and a file list specified"))
5947
raise errors.BzrCommandError(
5948
"Both --delete and --switch specified")
6036
raise errors.BzrCommandError(gettext(
6037
"Both --delete and --switch specified"))
5950
6039
tree.views.set_view_info(None, {})
5951
self.outf.write("Deleted all views.\n")
6040
self.outf.write(gettext("Deleted all views.\n"))
5952
6041
elif name is None:
5953
raise errors.BzrCommandError("No current view to delete")
6042
raise errors.BzrCommandError(gettext("No current view to delete"))
5955
6044
tree.views.delete_view(name)
5956
self.outf.write("Deleted '%s' view.\n" % name)
6045
self.outf.write(gettext("Deleted '%s' view.\n") % name)
5959
raise errors.BzrCommandError(
5960
"Both --switch and a file list specified")
6048
raise errors.BzrCommandError(gettext(
6049
"Both --switch and a file list specified"))
5962
raise errors.BzrCommandError(
5963
"Both --switch and --all specified")
6051
raise errors.BzrCommandError(gettext(
6052
"Both --switch and --all specified"))
5964
6053
elif switch == 'off':
5965
6054
if current_view is None:
5966
raise errors.BzrCommandError("No current view to disable")
6055
raise errors.BzrCommandError(gettext("No current view to disable"))
5967
6056
tree.views.set_view_info(None, view_dict)
5968
self.outf.write("Disabled '%s' view.\n" % (current_view))
6057
self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
5970
6059
tree.views.set_view_info(switch, view_dict)
5971
6060
view_str = views.view_display_str(tree.views.lookup_view())
5972
self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
6061
self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
5975
self.outf.write('Views defined:\n')
6064
self.outf.write(gettext('Views defined:\n'))
5976
6065
for view in sorted(view_dict):
5977
6066
if view == current_view:
5981
6070
view_str = views.view_display_str(view_dict[view])
5982
6071
self.outf.write('%s %-20s %s\n' % (active, view, view_str))
5984
self.outf.write('No views defined.\n')
6073
self.outf.write(gettext('No views defined.\n'))
5985
6074
elif file_list:
5986
6075
if name is None:
5987
6076
# No name given and no current view set
5989
6078
elif name == 'off':
5990
raise errors.BzrCommandError(
5991
"Cannot change the 'off' pseudo view")
6079
raise errors.BzrCommandError(gettext(
6080
"Cannot change the 'off' pseudo view"))
5992
6081
tree.views.set_view(name, sorted(file_list))
5993
6082
view_str = views.view_display_str(tree.views.lookup_view())
5994
self.outf.write("Using '%s' view: %s\n" % (name, view_str))
6083
self.outf.write(gettext("Using '{0}' view: {1}\n").format(name, view_str))
5996
6085
# list the files
5997
6086
if name is None:
5998
6087
# No name given and no current view set
5999
self.outf.write('No current view.\n')
6088
self.outf.write(gettext('No current view.\n'))
6001
6090
view_str = views.view_display_str(tree.views.lookup_view(name))
6002
self.outf.write("'%s' view is: %s\n" % (name, view_str))
6091
self.outf.write(gettext("'{0}' view is: {1}\n").format(name, view_str))
6005
6094
class cmd_hooks(Command):
6126
6215
manager = tree.get_shelf_manager()
6127
6216
shelves = manager.active_shelves()
6128
6217
if len(shelves) == 0:
6129
note('No shelved changes.')
6218
note(gettext('No shelved changes.'))
6131
6220
for shelf_id in reversed(shelves):
6132
6221
message = manager.get_metadata(shelf_id).get('message')