63
63
from breezy.branch import Branch
64
from breezy.conflicts import ConflictList
64
65
from breezy.transport import memory
65
66
from breezy.smtp_connection import SMTPConnection
66
67
from breezy.workingtree import WorkingTree
395
396
from .status import show_tree_status
397
398
if revision and len(revision) > 2:
398
raise errors.CommandError(
399
raise errors.BzrCommandError(
399
400
gettext('brz status --revision takes exactly'
400
401
' one or two revision specifiers'))
441
442
def run(self, revision_id=None, revision=None, directory=u'.'):
442
443
if revision_id is not None and revision is not None:
443
raise errors.CommandError(gettext('You can only supply one of'
444
raise errors.BzrCommandError(gettext('You can only supply one of'
444
445
' revision_id or --revision'))
445
446
if revision_id is None and revision is None:
446
raise errors.CommandError(
447
raise errors.BzrCommandError(
447
448
gettext('You must supply either --revision or a revision_id'))
449
450
b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
451
452
revisions = getattr(b.repository, "revisions", None)
452
453
if revisions is None:
453
raise errors.CommandError(
454
raise errors.BzrCommandError(
454
455
gettext('Repository %r does not support '
455
456
'access to raw revision texts') % b.repository)
465
466
"The repository {0} contains no revision {1}.").format(
466
467
b.repository.base, revision_id.decode('utf-8'))
467
raise errors.CommandError(msg)
468
raise errors.BzrCommandError(msg)
468
469
elif revision is not None:
469
470
for rev in revision:
471
raise errors.CommandError(
472
raise errors.BzrCommandError(
472
473
gettext('You cannot specify a NULL revision.'))
473
474
rev_id = rev.as_revision_id(b)
474
475
self.print_revision(revisions, rev_id)
501
502
working = d.open_workingtree()
502
503
except errors.NoWorkingTree:
503
raise errors.CommandError(
504
raise errors.BzrCommandError(
504
505
gettext("No working tree to remove"))
505
506
except errors.NotLocalUrl:
506
raise errors.CommandError(
507
raise errors.BzrCommandError(
507
508
gettext("You cannot remove the working tree"
508
509
" of a remote path"))
513
514
raise errors.ShelvedChanges(working)
515
516
if working.user_url != working.branch.user_url:
516
raise errors.CommandError(
517
raise errors.BzrCommandError(
517
518
gettext("You cannot remove the working tree"
518
519
" from a lightweight checkout"))
554
555
pass # There seems to be a real error here, so we'll reset
557
raise errors.CommandError(gettext(
558
raise errors.BzrCommandError(gettext(
558
559
'The tree does not appear to be corrupt. You probably'
559
560
' want "brz revert" instead. Use "--force" if you are'
560
561
' sure you want to reset the working tree.'))
591
592
def run(self, tree=False, location=u'.', revision=None):
592
593
if revision is not None and tree:
593
raise errors.CommandError(
594
raise errors.BzrCommandError(
594
595
gettext("--tree and --revision can not be used together"))
606
607
self.enter_context(b.lock_read())
608
609
if len(revision) != 1:
609
raise errors.CommandError(gettext(
610
raise errors.BzrCommandError(gettext(
610
611
"Revision numbers only make sense for single "
611
612
"revisions, not ranges"))
612
613
revid = revision[0].as_revision_id(b)
870
871
def run(self, revision=None, show_ids=False, kind=None, include_root=False,
872
873
if kind and kind not in ['file', 'directory', 'symlink']:
873
raise errors.CommandError(
874
raise errors.BzrCommandError(
874
875
gettext('invalid kind %r specified') % (kind,))
876
877
revision = _get_one_revision('inventory', revision)
933
934
if names_list is None:
935
936
if len(names_list) < 2:
936
raise errors.CommandError(gettext("missing file argument"))
937
raise errors.BzrCommandError(gettext("missing file argument"))
937
938
tree, rel_names = WorkingTree.open_containing_paths(
938
939
names_list, canonicalize=False)
939
940
for file_name in rel_names[0:-1]:
940
941
if file_name == '':
941
raise errors.CommandError(
942
raise errors.BzrCommandError(
942
943
gettext("can not copy root of branch"))
943
944
self.enter_context(tree.lock_tree_write())
944
945
into_existing = osutils.isdir(names_list[-1])
961
962
src_kind = tree.stored_kind(src)
962
963
except errors.NoSuchFile:
963
raise errors.CommandError(
964
raise errors.BzrCommandError(
964
965
gettext('Could not copy %s => %s: %s is not versioned.')
965
966
% (src, dst, src))
966
967
if src_kind is None:
967
raise errors.CommandError(
968
raise errors.BzrCommandError(
968
969
gettext('Could not copy %s => %s . %s is not versioned\\.'
969
970
% (src, dst, src)))
970
971
if src_kind == 'directory':
971
raise errors.CommandError(
972
raise errors.BzrCommandError(
972
973
gettext('Could not copy %s => %s . %s is a directory.'
973
974
% (src, dst, src)))
974
975
dst_parent = osutils.split(dst)[0]
977
978
dst_parent_kind = tree.stored_kind(dst_parent)
978
979
except errors.NoSuchFile:
979
raise errors.CommandError(
980
raise errors.BzrCommandError(
980
981
gettext('Could not copy %s => %s: %s is not versioned.')
981
982
% (src, dst, dst_parent))
982
983
if dst_parent_kind != 'directory':
983
raise errors.CommandError(
984
raise errors.BzrCommandError(
984
985
gettext('Could not copy to %s: %s is not a directory.')
985
986
% (dst_parent, dst_parent))
1023
1024
return self.run_auto(names_list, after, dry_run)
1025
raise errors.CommandError(gettext('--dry-run requires --auto.'))
1026
raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
1026
1027
if names_list is None:
1027
1028
names_list = []
1028
1029
if len(names_list) < 2:
1029
raise errors.CommandError(gettext("missing file argument"))
1030
raise errors.BzrCommandError(gettext("missing file argument"))
1030
1031
tree, rel_names = WorkingTree.open_containing_paths(
1031
1032
names_list, canonicalize=False)
1032
1033
for file_name in rel_names[0:-1]:
1033
1034
if file_name == '':
1034
raise errors.CommandError(
1035
raise errors.BzrCommandError(
1035
1036
gettext("can not move root of branch"))
1036
1037
self.enter_context(tree.lock_tree_write())
1037
1038
self._run(tree, names_list, rel_names, after)
1039
1040
def run_auto(self, names_list, after, dry_run):
1040
1041
if names_list is not None and len(names_list) > 1:
1041
raise errors.CommandError(
1042
raise errors.BzrCommandError(
1042
1043
gettext('Only one path may be specified to --auto.'))
1044
raise errors.CommandError(
1045
raise errors.BzrCommandError(
1045
1046
gettext('--after cannot be specified with --auto.'))
1046
1047
work_tree, file_list = WorkingTree.open_containing_paths(
1047
1048
names_list, default_directory='.')
1078
1079
self.outf.write("%s => %s\n" % (src, dest))
1080
1081
if len(names_list) != 2:
1081
raise errors.CommandError(gettext('to mv multiple files the'
1082
raise errors.BzrCommandError(gettext('to mv multiple files the'
1082
1083
' destination must be a versioned'
1221
1222
stored_loc = branch_to.get_parent()
1222
1223
if location is None:
1223
1224
if stored_loc is None:
1224
raise errors.CommandError(gettext("No pull location known or"
1225
raise errors.BzrCommandError(gettext("No pull location known or"
1225
1226
" specified."))
1227
1228
display_url = urlutils.unescape_for_display(stored_loc,
1234
1235
revision = _get_one_revision('pull', revision)
1235
1236
if mergeable is not None:
1236
1237
if revision is not None:
1237
raise errors.CommandError(gettext(
1238
raise errors.BzrCommandError(gettext(
1238
1239
'Cannot use -r with merge directives or bundles'))
1239
1240
mergeable.install_revisions(branch_to.repository)
1240
1241
base_revision_id, revision_id, verified = \
1389
1390
# error by the feedback given to them. RBC 20080227.
1390
1391
stacked_on = parent_url
1391
1392
if not stacked_on:
1392
raise errors.CommandError(gettext(
1393
raise errors.BzrCommandError(gettext(
1393
1394
"Could not determine branch to refer to."))
1395
1396
# Get the destination location
1398
1399
if stored_loc is None:
1399
1400
parent_loc = br_from.get_parent()
1401
raise errors.CommandError(gettext(
1402
raise errors.BzrCommandError(gettext(
1402
1403
"No push location known or specified. To push to the "
1403
1404
"parent branch (at %s), use 'brz push :parent'." %
1404
1405
urlutils.unescape_for_display(parent_loc,
1405
1406
self.outf.encoding)))
1407
raise errors.CommandError(gettext(
1408
raise errors.BzrCommandError(gettext(
1408
1409
"No push location known or specified."))
1410
1411
display_url = urlutils.unescape_for_display(stored_loc,
1516
1517
raise errors.AlreadyBranchError(to_location)
1517
1518
except errors.NoSuchFile:
1518
raise errors.CommandError(gettext('Parent of "%s" does not exist.')
1519
raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1536
1537
to_transport.delete_tree('.')
1537
1538
msg = gettext("The branch {0} has no revision {1}.").format(
1538
1539
from_location, revision)
1539
raise errors.CommandError(msg)
1540
raise errors.BzrCommandError(msg)
1542
1543
to_repo = to_dir.open_repository()
1593
1594
t = transport.get_transport(location, purpose='read')
1594
1595
if not t.listable():
1595
raise errors.CommandError(
1596
raise errors.BzrCommandError(
1596
1597
"Can't scan this type of location.")
1597
1598
for b in controldir.ControlDir.find_branches(t):
1598
1599
self.outf.write("%s\n" % urlutils.unescape_for_display(
1798
1799
def run(self, dir=None, revision=None, show_base=None):
1799
1800
if revision is not None and len(revision) != 1:
1800
raise errors.CommandError(gettext(
1801
raise errors.BzrCommandError(gettext(
1801
1802
"brz update --revision takes exactly one revision"))
1802
1803
if dir is None:
1803
1804
tree = WorkingTree.open_containing('.')[0]
1805
1806
tree, relpath = WorkingTree.open_containing(dir)
1807
1808
# See bug 557886.
1808
raise errors.CommandError(gettext(
1809
raise errors.BzrCommandError(gettext(
1809
1810
"brz update can only update a whole tree, "
1810
1811
"not a file or subdirectory"))
1811
1812
branch = tree.branch
1851
1852
old_tip=old_tip,
1852
1853
show_base=show_base)
1853
1854
except errors.NoSuchRevision as e:
1854
raise errors.CommandError(gettext(
1855
raise errors.BzrCommandError(gettext(
1855
1856
"branch has no revision %s\n"
1856
1857
"brz update --revision only works"
1857
1858
" for a revision in the branch history")
1953
1954
specific_files=file_list).added
1954
1955
file_list = sorted([f.path[1] for f in added], reverse=True)
1955
1956
if len(file_list) == 0:
1956
raise errors.CommandError(gettext('No matching files.'))
1957
raise errors.BzrCommandError(gettext('No matching files.'))
1957
1958
elif file_list is None:
1958
1959
# missing files show up in iter_changes(basis) as
1959
1960
# versioned-with-no-kind.
2115
2116
to_transport.ensure_base()
2116
2117
except errors.NoSuchFile:
2117
2118
if not create_prefix:
2118
raise errors.CommandError(gettext("Parent directory of %s"
2119
raise errors.BzrCommandError(gettext("Parent directory of %s"
2119
2120
" does not exist."
2120
2121
"\nYou may supply --create-prefix to create all"
2121
2122
" leading parent directories.")
2151
2152
branch.set_append_revisions_only(True)
2152
2153
except errors.UpgradeRequired:
2153
raise errors.CommandError(gettext('This branch format cannot be set'
2154
raise errors.BzrCommandError(gettext('This branch format cannot be set'
2154
2155
' to append-revisions-only. Try --default.'))
2155
2156
if not is_quiet():
2156
2157
from .info import describe_layout, describe_format
2394
2395
elif u':' in prefix:
2395
2396
old_label, new_label = prefix.split(u":")
2397
raise errors.CommandError(gettext(
2398
raise errors.BzrCommandError(gettext(
2398
2399
'--prefix expects two values separated by a colon'
2399
2400
' (eg "old/:new/")'))
2401
2402
if revision and len(revision) > 2:
2402
raise errors.CommandError(gettext('brz diff --revision takes exactly'
2403
raise errors.BzrCommandError(gettext('brz diff --revision takes exactly'
2403
2404
' one or two revision specifiers'))
2405
2406
if using is not None and format is not None:
2406
raise errors.CommandError(gettext(
2407
raise errors.BzrCommandError(gettext(
2407
2408
'{0} and {1} are mutually exclusive').format(
2408
2409
'--using', '--format'))
2803
2804
include_merged = False
2804
2805
if (exclude_common_ancestry
2805
2806
and (revision is None or len(revision) != 2)):
2806
raise errors.CommandError(gettext(
2807
raise errors.BzrCommandError(gettext(
2807
2808
'--exclude-common-ancestry requires -r with two revisions'))
2808
2809
if include_merged:
2809
2810
if levels is None:
2812
raise errors.CommandError(gettext(
2813
raise errors.BzrCommandError(gettext(
2813
2814
'{0} and {1} are mutually exclusive').format(
2814
2815
'--levels', '--include-merged'))
2817
2818
if len(change) > 1:
2818
2819
raise errors.RangeInChangeOption()
2819
2820
if revision is not None:
2820
raise errors.CommandError(gettext(
2821
raise errors.BzrCommandError(gettext(
2821
2822
'{0} and {1} are mutually exclusive').format(
2822
2823
'--revision', '--change'))
2824
2825
revision = change
2827
2828
filter_by_dir = False
2829
2830
# find the file ids to log and check for directory filtering
2830
2831
b, file_info_list, rev1, rev2 = _get_info_for_log_files(
2831
2832
revision, file_list, self._exit_stack)
2832
for relpath, kind in file_info_list:
2834
raise errors.CommandError(gettext(
2833
for relpath, file_id, kind in file_info_list:
2835
raise errors.BzrCommandError(gettext(
2835
2836
"Path unknown at end or start of revision range: %s") %
2837
2838
# If the relpath is the top of the tree, we log everything
2838
2839
if relpath == '':
2842
files.append(relpath)
2843
file_ids.append(file_id)
2843
2844
filter_by_dir = filter_by_dir or (
2844
2845
kind in ['directory', 'tree-reference'])
2902
2903
# original algorithm - per-file-graph - for the "single
2903
2904
# file that isn't a directory without showing a delta" case.
2904
2905
partial_history = revision and b.repository._format.supports_chks
2905
match_using_deltas = (len(files) != 1 or filter_by_dir
2906
match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2906
2907
or delta_type or partial_history)
2908
2909
match_dict = {}
2918
2919
match_dict['bugs'] = match_bugs
2920
2921
# Build the LogRequest and execute it
2922
if len(file_ids) == 0:
2923
2924
rqst = make_log_request_dict(
2924
direction=direction, specific_files=files,
2925
direction=direction, specific_fileids=file_ids,
2925
2926
start_revision=rev1, end_revision=rev2, limit=limit,
2926
2927
message_search=message, delta_type=delta_type,
2927
2928
diff_type=diff_type, _match_using_deltas=match_using_deltas,
2949
2950
# b is taken from revision[0].get_branch(), and
2950
2951
# show_log will use its revision_history. Having
2951
2952
# different branches will lead to weird behaviors.
2952
raise errors.CommandError(gettext(
2953
raise errors.BzrCommandError(gettext(
2953
2954
"brz %s doesn't accept two revisions in different"
2954
2955
" branches.") % command_name)
2955
2956
if start_spec.spec is None:
3045
3046
null=False, kind=None, show_ids=False, path=None, directory=None):
3047
3048
if kind and kind not in ('file', 'directory', 'symlink', 'tree-reference'):
3048
raise errors.CommandError(gettext('invalid kind specified'))
3049
raise errors.BzrCommandError(gettext('invalid kind specified'))
3050
3051
if verbose and null:
3051
raise errors.CommandError(
3052
raise errors.BzrCommandError(
3052
3053
gettext('Cannot set both --verbose and --null'))
3053
3054
all = not (unknown or versioned or ignored)
3235
3236
self.outf.write("%s\n" % pattern)
3237
3238
if not name_pattern_list:
3238
raise errors.CommandError(gettext("ignore requires at least one "
3239
raise errors.BzrCommandError(gettext("ignore requires at least one "
3239
3240
"NAME_PATTERN or --default-rules."))
3240
3241
name_pattern_list = [globbing.normalize_pattern(p)
3241
3242
for p in name_pattern_list]
3254
3255
for name_pattern in name_pattern_list:
3255
3256
if (name_pattern[0] == '/' or
3256
3257
(len(name_pattern) > 1 and name_pattern[1] == ':')):
3257
raise errors.CommandError(gettext(
3258
raise errors.BzrCommandError(gettext(
3258
3259
"NAME_PATTERN should not be an absolute path"))
3259
3260
tree, relpath = WorkingTree.open_containing(directory)
3260
3261
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
3316
3317
revno = int(revno)
3317
3318
except ValueError:
3318
raise errors.CommandError(gettext("not a valid revision-number: %r")
3319
raise errors.BzrCommandError(gettext("not a valid revision-number: %r")
3320
3321
revid = WorkingTree.open_containing(
3321
3322
directory)[0].branch.get_rev_id(revno)
3414
3415
export(export_tree, dest, format, root, subdir,
3415
3416
per_file_timestamps=per_file_timestamps)
3416
3417
except errors.NoSuchExportFormat as e:
3417
raise errors.CommandError(
3418
raise errors.BzrCommandError(
3418
3419
gettext('Unsupported export format: %s') % e.format)
3442
3443
def run(self, filename, revision=None, name_from_revision=False,
3443
3444
filters=False, directory=None):
3444
3445
if revision is not None and len(revision) != 1:
3445
raise errors.CommandError(gettext("brz cat --revision takes exactly"
3446
raise errors.BzrCommandError(gettext("brz cat --revision takes exactly"
3446
3447
" one revision specifier"))
3447
3448
tree, branch, relpath = \
3448
3449
_open_directory_or_containing_tree_or_branch(filename, directory)
3461
3462
if name_from_revision:
3462
3463
# Try in revision if requested
3463
3464
if not rev_tree.is_versioned(relpath):
3464
raise errors.CommandError(gettext(
3465
raise errors.BzrCommandError(gettext(
3465
3466
"{0!r} is not present in revision {1}").format(
3466
3467
filename, rev_tree.get_revision_id()))
3467
3468
rev_tree_path = relpath
3475
3476
if rev_tree_path is None:
3476
3477
# Path didn't exist in working tree
3477
3478
if not rev_tree.is_versioned(relpath):
3478
raise errors.CommandError(gettext(
3479
raise errors.BzrCommandError(gettext(
3479
3480
"{0!r} is not present in revision {1}").format(
3480
3481
filename, rev_tree.get_revision_id()))
3618
3619
default_bugtracker = branch_config.get(
3620
3621
if default_bugtracker is None:
3621
raise errors.CommandError(gettext(
3622
raise errors.BzrCommandError(gettext(
3622
3623
"No tracker specified for bug %s. Use the form "
3623
3624
"'tracker:id' or specify a default bug tracker "
3624
3625
"using the `bugtracker` option.\nSee "
3627
3628
tag = default_bugtracker
3628
3629
bug_id = tokens[0]
3629
3630
elif len(tokens) != 2:
3630
raise errors.CommandError(gettext(
3631
raise errors.BzrCommandError(gettext(
3631
3632
"Invalid bug %s. Must be in the form of 'tracker:id'. "
3632
3633
"See \"brz help bugs\" for more information on this "
3633
3634
"feature.\nCommit refused.") % bug)
3637
3638
yield bugtracker.get_bug_url(tag, branch, bug_id), status
3638
3639
except bugtracker.UnknownBugTrackerAbbreviation:
3639
raise errors.CommandError(gettext(
3640
raise errors.BzrCommandError(gettext(
3640
3641
'Unrecognized bug %s. Commit refused.') % bug)
3641
3642
except bugtracker.MalformedBugIdentifier as e:
3642
raise errors.CommandError(gettext(
3643
raise errors.BzrCommandError(gettext(
3643
3644
u"%s\nCommit refused.") % (e,))
3645
3646
def run(self, message=None, file=None, verbose=False, selected_list=None,
3667
3668
commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3668
3669
except ValueError as e:
3669
raise errors.CommandError(gettext(
3670
raise errors.BzrCommandError(gettext(
3670
3671
"Could not parse --commit-time: " + str(e)))
3672
3673
properties = {}
3710
3711
message = message.replace('\r\n', '\n')
3711
3712
message = message.replace('\r', '\n')
3713
raise errors.CommandError(gettext(
3714
raise errors.BzrCommandError(gettext(
3714
3715
"please specify either --message or --file"))
3716
3717
def get_message(commit_obj):
3741
3742
my_message = edit_commit_message_encoded(text,
3742
3743
start_message=start_message)
3743
3744
if my_message is None:
3744
raise errors.CommandError(gettext("please specify a commit"
3745
raise errors.BzrCommandError(gettext("please specify a commit"
3745
3746
" message with either --message or --file"))
3746
3747
if my_message == "":
3747
raise errors.CommandError(gettext("Empty commit message specified."
3748
raise errors.BzrCommandError(gettext("Empty commit message specified."
3748
3749
" Please specify a commit message with either"
3749
3750
" --message or --file or leave a blank message"
3750
3751
" with --message \"\"."))
3764
3765
exclude=tree.safe_relpath_files(exclude),
3766
3767
except PointlessCommit:
3767
raise errors.CommandError(gettext("No changes to commit."
3768
raise errors.BzrCommandError(gettext("No changes to commit."
3768
3769
" Please 'brz add' the files you want to commit, or use"
3769
3770
" --unchanged to force an empty commit."))
3770
3771
except ConflictsInTree:
3771
raise errors.CommandError(gettext('Conflicts detected in working '
3772
raise errors.BzrCommandError(gettext('Conflicts detected in working '
3772
3773
'tree. Use "brz conflicts" to list, "brz resolve FILE" to'
3774
3775
except StrictCommitFailed:
3775
raise errors.CommandError(gettext("Commit refused because there are"
3776
raise errors.BzrCommandError(gettext("Commit refused because there are"
3776
3777
" unknown files in the working tree."))
3777
3778
except errors.BoundBranchOutOfDate as e:
3778
3779
e.extra_help = (gettext("\n"
4045
4046
def remove_alias(self, alias_name):
4046
4047
if alias_name is None:
4047
raise errors.CommandError(gettext(
4048
raise errors.BzrCommandError(gettext(
4048
4049
'brz alias --remove expects an alias to remove.'))
4049
4050
# If alias is not found, print something like:
4050
4051
# unalias: foo: not found
4139
4140
return test_server.FakeNFSServer
4140
4141
msg = "No known transport type %s. Supported types are: sftp\n" %\
4142
raise errors.CommandError(msg)
4143
raise errors.BzrCommandError(msg)
4145
4146
takes_args = ['testspecs*']
4236
4237
from .tests import SubUnitBzrRunnerv1
4237
4238
except ImportError:
4238
raise errors.CommandError(gettext(
4239
raise errors.BzrCommandError(gettext(
4239
4240
"subunit not available. subunit needs to be installed "
4240
4241
"to use --subunit."))
4241
4242
self.additional_selftest_args['runner_class'] = SubUnitBzrRunnerv1
4253
4254
from .tests import SubUnitBzrRunnerv2
4254
4255
except ImportError:
4255
raise errors.CommandError(gettext(
4256
raise errors.BzrCommandError(gettext(
4256
4257
"subunit not available. subunit "
4257
4258
"needs to be installed to use --subunit2."))
4258
4259
self.additional_selftest_args['runner_class'] = SubUnitBzrRunnerv2
4261
4262
self.additional_selftest_args.setdefault(
4262
4263
'suite_decorators', []).append(parallel)
4264
raise errors.CommandError(gettext(
4265
raise errors.BzrCommandError(gettext(
4265
4266
"--benchmark is no longer supported from brz 2.2; "
4266
4267
"use bzr-usertest instead"))
4267
4268
test_suite_factory = None
4490
4491
tree = WorkingTree.open_containing(directory)[0]
4491
4492
if tree.branch.last_revision() == _mod_revision.NULL_REVISION:
4492
raise errors.CommandError(gettext('Merging into empty branches not currently supported, '
4493
raise errors.BzrCommandError(gettext('Merging into empty branches not currently supported, '
4493
4494
'https://bugs.launchpad.net/bzr/+bug/308562'))
4495
4496
# die as quickly as possible if there are uncommitted changes
4511
4512
mergeable = None
4513
4514
if uncommitted:
4514
raise errors.CommandError(gettext('Cannot use --uncommitted'
4515
raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4515
4516
' with bundles or merge directives.'))
4517
4518
if revision is not None:
4518
raise errors.CommandError(gettext(
4519
raise errors.BzrCommandError(gettext(
4519
4520
'Cannot use -r with merge directives or bundles'))
4520
4521
merger, verified = _mod_merge.Merger.from_mergeable(tree,
4523
4524
if merger is None and uncommitted:
4524
4525
if revision is not None and len(revision) > 0:
4525
raise errors.CommandError(gettext('Cannot use --uncommitted and'
4526
raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4526
4527
' --revision at the same time.'))
4527
4528
merger = self.get_merger_from_uncommitted(tree, location, None)
4528
4529
allow_pending = False
4549
4550
if pull and not preview:
4550
4551
if merger.interesting_files is not None:
4551
raise errors.CommandError(
4552
raise errors.BzrCommandError(
4552
4553
gettext('Cannot pull individual files'))
4553
4554
if (merger.base_rev_id == tree.last_revision()):
4554
4555
result = tree.pull(merger.other_branch, False,
4556
4557
result.report(self.outf)
4558
4559
if merger.this_basis is None:
4559
raise errors.CommandError(gettext(
4560
raise errors.BzrCommandError(gettext(
4560
4561
"This branch has no commits."
4561
4562
" (perhaps you would prefer 'brz pull')"))
4615
4616
def sanity_check_merger(self, merger):
4616
4617
if (merger.show_base and
4617
4618
merger.merge_type is not _mod_merge.Merge3Merger):
4618
raise errors.CommandError(gettext("Show-base is not supported for this"
4619
raise errors.BzrCommandError(gettext("Show-base is not supported for this"
4619
4620
" merge type. %s") % merger.merge_type)
4620
4621
if merger.reprocess is None:
4621
4622
if merger.show_base:
4624
4625
# Use reprocess if the merger supports it
4625
4626
merger.reprocess = merger.merge_type.supports_reprocess
4626
4627
if merger.reprocess and not merger.merge_type.supports_reprocess:
4627
raise errors.CommandError(gettext("Conflict reduction is not supported"
4628
raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
4628
4629
" for merge type %s.") %
4629
4630
merger.merge_type)
4630
4631
if merger.reprocess and merger.show_base:
4631
raise errors.CommandError(gettext("Cannot do conflict reduction and"
4632
raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4632
4633
" show base."))
4634
4635
if (merger.merge_type.requires_file_merge_plan and
4636
4637
not getattr(merger.other_tree, 'plan_file_merge', None) or
4637
4638
(merger.base_tree is not None and
4638
4639
not getattr(merger.base_tree, 'plan_file_merge', None)))):
4639
raise errors.CommandError(
4640
raise errors.BzrCommandError(
4640
4641
gettext('Plan file merge unsupported: '
4641
4642
'Merge type incompatible with tree formats.'))
4747
4748
stored_location_type = "parent"
4748
4749
mutter("%s", stored_location)
4749
4750
if stored_location is None:
4750
raise errors.CommandError(
4751
raise errors.BzrCommandError(
4751
4752
gettext("No location specified or remembered"))
4752
4753
display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4753
4754
note(gettext("{0} remembered {1} location {2}").format(verb_string,
4794
4795
self.enter_context(tree.lock_write())
4795
4796
parents = tree.get_parent_ids()
4796
4797
if len(parents) != 2:
4797
raise errors.CommandError(
4798
raise errors.BzrCommandError(
4798
4799
gettext("Sorry, remerge only works after normal"
4799
4800
" merges. Not cherrypicking or multi-merges."))
4800
4801
interesting_files = None
4819
4820
restore_files = [c.path for c in conflicts
4820
4821
if c.typestring in allowed_conflicts]
4821
4822
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_files)
4822
tree.set_conflicts(new_conflicts)
4823
tree.set_conflicts(ConflictList(new_conflicts))
4823
4824
if file_list is not None:
4824
4825
restore_files = file_list
4825
4826
for filename in restore_files:
5318
5319
def run(self, revision_id_list=None, revision=None, directory=u'.'):
5319
5320
if revision_id_list is not None and revision is not None:
5320
raise errors.CommandError(
5321
raise errors.BzrCommandError(
5321
5322
gettext('You can only supply one of revision_id or --revision'))
5322
5323
if revision_id_list is None and revision is None:
5323
raise errors.CommandError(
5324
raise errors.BzrCommandError(
5324
5325
gettext('You must supply either --revision or a revision_id'))
5325
5326
b = WorkingTree.open_containing(directory)[0].branch
5326
5327
self.enter_context(b.lock_write())
5348
5349
if to_revid is None:
5349
5350
to_revno = b.revno()
5350
5351
if from_revno is None or to_revno is None:
5351
raise errors.CommandError(
5352
raise errors.BzrCommandError(
5352
5353
gettext('Cannot sign a range of non-revision-history revisions'))
5353
5354
with WriteGroup(b.repository):
5354
5355
for revno in range(from_revno, to_revno + 1):
5355
5356
b.repository.sign_revision(b.get_rev_id(revno),
5358
raise errors.CommandError(
5359
raise errors.BzrCommandError(
5359
5360
gettext('Please supply either one revision, or a range.'))
5382
5383
location = b.get_old_bound_location()
5383
5384
except errors.UpgradeRequired:
5384
raise errors.CommandError(
5385
raise errors.BzrCommandError(
5385
5386
gettext('No location supplied. '
5386
5387
'This format does not remember old locations.'))
5388
5389
if location is None:
5389
5390
if b.get_bound_location() is not None:
5390
raise errors.CommandError(
5391
raise errors.BzrCommandError(
5391
5392
gettext('Branch is already bound'))
5393
raise errors.CommandError(
5394
raise errors.BzrCommandError(
5394
5395
gettext('No location supplied'
5395
5396
' and no previous location known'))
5396
5397
b_other = Branch.open(location)
5398
5399
b.bind(b_other)
5399
5400
except errors.DivergedBranches:
5400
raise errors.CommandError(
5401
raise errors.BzrCommandError(
5401
5402
gettext('These branches have diverged.'
5402
5403
' Try merging, and then bind again.'))
5403
5404
if b.get_config().has_explicit_nickname():
5418
5419
def run(self, directory=u'.'):
5419
5420
b, relpath = Branch.open_containing(directory)
5420
5421
if not b.unbind():
5421
raise errors.CommandError(gettext('Local branch is not bound'))
5422
raise errors.BzrCommandError(gettext('Local branch is not bound'))
5424
5425
class cmd_uncommit(Command):
5677
5678
containing_tree = WorkingTree.open_containing(parent_dir)[0]
5678
5679
repo = containing_tree.branch.repository
5679
5680
if not repo.supports_rich_root():
5680
raise errors.CommandError(gettext(
5681
raise errors.BzrCommandError(gettext(
5681
5682
"Can't join trees because %s doesn't support rich root data.\n"
5682
5683
"You can use brz upgrade on the repository.")
5687
5688
except BadReferenceTarget as e:
5688
5689
# XXX: Would be better to just raise a nicely printable
5689
5690
# exception from the real origin. Also below. mbp 20070306
5690
raise errors.CommandError(
5691
raise errors.BzrCommandError(
5691
5692
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5694
5695
containing_tree.subsume(sub_tree)
5695
5696
except errors.BadSubsumeSource as e:
5696
raise errors.CommandError(
5697
raise errors.BzrCommandError(
5697
5698
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5785
5786
if submit_branch is None:
5786
5787
submit_branch = branch.get_parent()
5787
5788
if submit_branch is None:
5788
raise errors.CommandError(
5789
raise errors.BzrCommandError(
5789
5790
gettext('No submit branch specified or known'))
5791
5792
stored_public_branch = branch.get_public_branch()
5795
5796
# FIXME: Should be done only if we succeed ? -- vila 2012-01-03
5796
5797
branch.set_public_branch(public_branch)
5797
5798
if not include_bundle and public_branch is None:
5798
raise errors.CommandError(
5799
raise errors.BzrCommandError(
5799
5800
gettext('No public branch specified or known'))
5800
5801
base_revision_id = None
5801
5802
if revision is not None:
5802
5803
if len(revision) > 2:
5803
raise errors.CommandError(
5804
raise errors.BzrCommandError(
5804
5805
gettext('brz merge-directive takes '
5805
5806
'at most two one revision identifiers'))
5806
5807
revision_id = revision[-1].as_revision_id(branch)
5810
5811
revision_id = branch.last_revision()
5811
5812
revision_id = ensure_null(revision_id)
5812
5813
if revision_id == NULL_REVISION:
5813
raise errors.CommandError(gettext('No revisions to bundle.'))
5814
raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5814
5815
directive = merge_directive.MergeDirective2.from_objects(
5815
5816
branch.repository, revision_id, time.time(),
5816
5817
osutils.local_time_offset(), submit_branch,
6057
6058
self.enter_context(branch.lock_write())
6059
6060
if tag_name is None:
6060
raise errors.CommandError(
6061
raise errors.BzrCommandError(
6061
6062
gettext("No tag specified to delete."))
6062
6063
branch.tags.delete_tag(tag_name)
6063
6064
note(gettext('Deleted tag %s.') % tag_name)
6066
6067
if len(revision) != 1:
6067
raise errors.CommandError(gettext(
6068
raise errors.BzrCommandError(gettext(
6068
6069
"Tags can only be placed on a single revision, "
6069
6070
"not on a range"))
6070
6071
revision_id = revision[0].as_revision_id(branch)
6073
6074
if tag_name is None:
6074
6075
tag_name = branch.automatic_tag_name(revision_id)
6075
6076
if tag_name is None:
6076
raise errors.CommandError(gettext(
6077
raise errors.BzrCommandError(gettext(
6077
6078
"Please specify a tag name."))
6079
6080
existing_target = branch.tags.lookup_tag(tag_name)
6237
6238
stacked_on=None, unstacked=None):
6238
6239
directory = controldir.ControlDir.open(location)
6239
6240
if stacked_on and unstacked:
6240
raise errors.CommandError(
6241
raise errors.BzrCommandError(
6241
6242
gettext("Can't use both --stacked-on and --unstacked"))
6242
6243
elif stacked_on is not None:
6243
6244
reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
6331
6332
possible_transports = [control_dir.root_transport]
6332
6333
if to_location is None:
6333
6334
if revision is None:
6334
raise errors.CommandError(gettext('You must supply either a'
6335
raise errors.BzrCommandError(gettext('You must supply either a'
6335
6336
' revision or a location'))
6336
6337
to_location = tree_location
6345
6346
possible_transports.append(branch.user_transport)
6346
6347
if create_branch:
6347
6348
if branch is None:
6348
raise errors.CommandError(
6349
raise errors.BzrCommandError(
6349
6350
gettext('cannot create branch without source branch'))
6350
6351
to_location = lookup_new_sibling_branch(
6351
6352
control_dir, to_location,
6373
6374
store_uncommitted=store,
6374
6375
possible_transports=possible_transports)
6375
6376
except controldir.BranchReferenceLoop:
6376
raise errors.CommandError(
6377
raise errors.BzrCommandError(
6377
6378
gettext('switching would create a branch reference loop. '
6378
6379
'Use the "bzr up" command to switch to a '
6379
6380
'different revision.'))
6485
6486
name = current_view
6488
raise errors.CommandError(gettext(
6489
raise errors.BzrCommandError(gettext(
6489
6490
"Both --delete and a file list specified"))
6491
raise errors.CommandError(gettext(
6492
raise errors.BzrCommandError(gettext(
6492
6493
"Both --delete and --switch specified"))
6494
6495
tree.views.set_view_info(None, {})
6495
6496
self.outf.write(gettext("Deleted all views.\n"))
6496
6497
elif name is None:
6497
raise errors.CommandError(
6498
raise errors.BzrCommandError(
6498
6499
gettext("No current view to delete"))
6500
6501
tree.views.delete_view(name)
6501
6502
self.outf.write(gettext("Deleted '%s' view.\n") % name)
6504
raise errors.CommandError(gettext(
6505
raise errors.BzrCommandError(gettext(
6505
6506
"Both --switch and a file list specified"))
6507
raise errors.CommandError(gettext(
6508
raise errors.BzrCommandError(gettext(
6508
6509
"Both --switch and --all specified"))
6509
6510
elif switch == 'off':
6510
6511
if current_view is None:
6511
raise errors.CommandError(
6512
raise errors.BzrCommandError(
6512
6513
gettext("No current view to disable"))
6513
6514
tree.views.set_view_info(None, view_dict)
6514
6515
self.outf.write(gettext("Disabled '%s' view.\n") %
6535
6536
# No name given and no current view set
6537
6538
elif name == 'off':
6538
raise errors.CommandError(gettext(
6539
raise errors.BzrCommandError(gettext(
6539
6540
"Cannot change the 'off' pseudo view"))
6540
6541
tree.views.set_view(name, sorted(file_list))
6541
6542
view_str = views.view_display_str(tree.views.lookup_view())
6602
6603
active_branch = None
6603
6604
if (active_branch is not None and
6604
6605
br.control_url == active_branch.control_url):
6605
raise errors.CommandError(
6606
raise errors.BzrCommandError(
6606
6607
gettext("Branch is active. Use --force to remove it."))
6607
6608
br.controldir.destroy_branch(br.name)
6971
6972
path_list = ['.']
6974
raise errors.CommandError(
6975
raise errors.BzrCommandError(
6975
6976
'cannot specify both --from-root and PATH.')
6977
6978
if files_with_matches and files_without_match:
6978
raise errors.CommandError(
6979
raise errors.BzrCommandError(
6979
6980
'cannot specify both '
6980
6981
'-l/--files-with-matches and -L/--files-without-matches.')
6988
6989
color = 'never'
6990
6991
if color not in ['always', 'never', 'auto']:
6991
raise errors.CommandError('Valid values for --color are '
6992
raise errors.BzrCommandError('Valid values for --color are '
6992
6993
'"always", "never" or "auto".')
6994
6995
if levels is None: