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