726
588
location = stored_loc
728
590
to_transport = transport.get_transport(location)
591
location_url = to_transport.base
730
br_to = repository_to = dir_to = None
732
dir_to = bzrdir.BzrDir.open_from_transport(to_transport)
595
dir_to = bzrdir.BzrDir.open(location_url)
596
br_to = dir_to.open_branch()
733
597
except errors.NotBranchError:
734
pass # Didn't find anything
736
# If we can open a branch, use its direct repository, otherwise see
737
# if there is a repository without a branch.
739
br_to = dir_to.open_branch()
740
except errors.NotBranchError:
741
# Didn't find a branch, can we find a repository?
599
to_transport = to_transport.clone('..')
600
if not create_prefix:
743
repository_to = dir_to.find_repository()
744
except errors.NoRepositoryPresent:
747
# Found a branch, so we must have found a repository
748
repository_to = br_to.repository
750
if revision is not None:
751
if len(revision) == 1:
752
revision_id = revision[0].in_history(br_from).rev_id
754
raise errors.BzrCommandError(
755
'bzr push --revision takes one value.')
757
revision_id = br_from.last_revision()
763
# The destination doesn't exist; create it.
764
# XXX: Refactor the create_prefix/no_create_prefix code into a
765
# common helper function
767
def make_directory(transport):
771
def redirected(redirected_transport, e, redirection_notice):
772
return transport.get_transport(e.get_target_url())
775
to_transport = transport.do_catching_redirections(
776
make_directory, to_transport, redirected)
777
except errors.FileExists:
778
if not use_existing_dir:
779
raise errors.BzrCommandError("Target directory %s"
780
" already exists, but does not have a valid .bzr"
781
" directory. Supply --use-existing-dir to push"
782
" there anyway." % location)
783
except errors.NoSuchFile:
784
if not create_prefix:
785
raise errors.BzrCommandError("Parent directory of %s"
787
"\nYou may supply --create-prefix to create all"
788
" leading parent directories."
790
_create_prefix(to_transport)
791
except errors.TooManyRedirections:
792
raise errors.BzrCommandError("Too many redirections trying "
793
"to make %s." % location)
795
# Now the target directory exists, but doesn't have a .bzr
796
# directory. So we need to create it, along with any work to create
797
# all of the dependent branches, etc.
798
dir_to = br_from.bzrdir.clone_on_transport(to_transport,
799
revision_id=revision_id)
602
relurl = to_transport.relpath(location_url)
603
mutter('creating directory %s => %s', location_url, relurl)
604
to_transport.mkdir(relurl)
605
except errors.NoSuchFile:
606
raise errors.BzrCommandError("Parent directory of %s "
607
"does not exist." % location)
609
current = to_transport.base
610
needed = [(to_transport, to_transport.relpath(location_url))]
613
to_transport, relpath = needed[-1]
614
to_transport.mkdir(relpath)
616
except errors.NoSuchFile:
617
new_transport = to_transport.clone('..')
618
needed.append((new_transport,
619
new_transport.relpath(to_transport.base)))
620
if new_transport.base == to_transport.base:
621
raise errors.BzrCommandError("Could not create "
623
dir_to = br_from.bzrdir.clone(location_url,
624
revision_id=br_from.last_revision())
800
625
br_to = dir_to.open_branch()
801
# TODO: Some more useful message about what was copied
802
note('Created new branch.')
626
count = len(br_to.revision_history())
803
627
# We successfully created the target, remember it
804
628
if br_from.get_push_location() is None or remember:
805
629
br_from.set_push_location(br_to.base)
806
elif repository_to is None:
807
# we have a bzrdir but no branch or repository
808
# XXX: Figure out what to do other than complain.
809
raise errors.BzrCommandError("At %s you have a valid .bzr control"
810
" directory, but not a branch or repository. This is an"
811
" unsupported configuration. Please move the target directory"
812
" out of the way and try again."
815
# We have a repository but no branch, copy the revisions, and then
817
repository_to.fetch(br_from.repository, revision_id=revision_id)
818
br_to = br_from.clone(dir_to, revision_id=revision_id)
819
note('Created new branch.')
820
if br_from.get_push_location() is None or remember:
821
br_from.set_push_location(br_to.base)
822
else: # We have a valid to branch
823
631
# We were able to connect to the remote location, so remember it
824
632
# we don't need to successfully push because of possible divergence.
825
633
if br_from.get_push_location() is None or remember:
826
634
br_from.set_push_location(br_to.base)
828
old_rh = br_to.revision_history()
635
old_rh = br_to.revision_history()
831
638
tree_to = dir_to.open_workingtree()
832
639
except errors.NotLocalUrl:
833
warning("This transport does not update the working "
834
"tree of: %s. See 'bzr help working-trees' for "
835
"more information." % br_to.base)
836
push_result = br_from.push(br_to, overwrite,
837
stop_revision=revision_id)
640
warning('This transport does not update the working '
641
'tree of: %s' % (br_to.base,))
642
count = br_to.pull(br_from, overwrite)
838
643
except errors.NoWorkingTree:
839
push_result = br_from.push(br_to, overwrite,
840
stop_revision=revision_id)
644
count = br_to.pull(br_from, overwrite)
844
push_result = br_from.push(tree_to.branch, overwrite,
845
stop_revision=revision_id)
646
count = tree_to.pull(br_from, overwrite)
849
647
except errors.DivergedBranches:
850
648
raise errors.BzrCommandError('These branches have diverged.'
851
649
' Try using "merge" and then "push".')
852
if push_result is not None:
853
push_result.report(self.outf)
650
note('%d revision(s) pushed.' % (count,))
855
653
new_rh = br_to.revision_history()
856
654
if old_rh != new_rh:
857
655
# Something changed
858
656
from bzrlib.log import show_changed_revisions
859
657
show_changed_revisions(br_to, old_rh, new_rh,
860
658
to_file=self.outf)
862
# we probably did a clone rather than a push, so a message was
867
661
class cmd_branch(Command):
1359
1092
raise errors.BranchExistsWithoutWorkingTree(location)
1360
1093
raise errors.AlreadyBranchError(location)
1362
branch = existing_bzrdir.create_branch()
1095
existing_bzrdir.create_branch()
1363
1096
existing_bzrdir.create_workingtree()
1364
if append_revisions_only:
1366
branch.set_append_revisions_only(True)
1367
except errors.UpgradeRequired:
1368
raise errors.BzrCommandError('This branch format cannot be set'
1369
' to append-revisions-only. Try --experimental-branch6')
1372
1099
class cmd_init_repository(Command):
1373
1100
"""Create a shared repository to hold branches.
1375
New branches created under the repository directory will store their
1376
revisions in the repository, not in the branch directory.
1378
If the --no-trees option is used then the branches in the repository
1379
will not have working trees by default.
1382
Create a shared repositories holding just branches::
1384
bzr init-repo --no-trees repo
1387
Make a lightweight checkout elsewhere::
1389
bzr checkout --lightweight repo/trunk trunk-checkout
1102
New branches created under the repository directory will store their revisions
1103
in the repository, not in the branch directory, if the branch format supports
1109
bzr checkout --lightweight repo/trunk trunk-checkout
1394
_see_also = ['init', 'branch', 'checkout', 'repositories']
1395
takes_args = ["location"]
1396
takes_options = [RegistryOption('format',
1397
help='Specify a format for this repository. See'
1398
' "bzr help formats" for details.',
1399
registry=bzrdir.format_registry,
1400
converter=bzrdir.format_registry.make_bzrdir,
1401
value_switches=True, title='Repository format'),
1403
help='Branches in the repository will default to'
1404
' not having a working tree.'),
1113
takes_args = ["location"]
1114
takes_options = [Option('format',
1115
help='Specify a format for this repository.'
1116
' Current formats are: default, knit,'
1117
' metaweave and weave. Default is knit;'
1118
' metaweave and weave are deprecated',
1119
type=get_format_type),
1121
help='Allows branches in repository to have'
1406
1123
aliases = ["init-repo"]
1408
def run(self, location, format=None, no_trees=False):
1124
def run(self, location, format=None, trees=False):
1409
1125
if format is None:
1410
format = bzrdir.format_registry.make_bzrdir('default')
1126
format = get_format_type('default')
1412
1128
if location is None:
1415
1131
to_transport = transport.get_transport(location)
1416
to_transport.ensure_base()
1133
to_transport.mkdir('.')
1134
except errors.FileExists:
1418
1137
newdir = format.initialize_on_transport(to_transport)
1419
1138
repo = newdir.create_repository(shared=True)
1420
repo.set_make_working_trees(not no_trees)
1139
repo.set_make_working_trees(trees)
1423
1142
class cmd_diff(Command):
1424
"""Show differences in the working tree, between revisions or branches.
1143
"""Show differences in the working tree or between revisions.
1426
If no arguments are given, all changes for the current tree are listed.
1427
If files are given, only the changes in those files are listed.
1428
Remote and multiple branches can be compared by using the --old and
1429
--new options. If not provided, the default for both is derived from
1430
the first argument, if any, or the current tree if no arguments are
1145
If files are listed, only the changes in those files are listed.
1146
Otherwise, all changes for the tree are listed.
1433
1148
"bzr diff -p1" is equivalent to "bzr diff --prefix old/:new/", and
1434
1149
produces patches suitable for "patch -p1".
1438
2 - unrepresentable changes
1443
Shows the difference in the working tree versus the last commit::
1447
Difference between the working tree and revision 1::
1451
Difference between revision 2 and revision 1::
1455
Difference between revision 2 and revision 1 for branch xxx::
1459
Show just the differences for file NEWS::
1463
Show the differences in working tree xxx for file NEWS::
1467
Show the differences from branch xxx to this working tree:
1471
Show the differences between two branches for file NEWS::
1473
bzr diff --old xxx --new yyy NEWS
1475
Same as 'bzr diff' but prefix paths with old/ and new/::
1477
bzr diff --prefix old/:new/
1153
Shows the difference in the working tree versus the last commit
1155
Difference between the working tree and revision 1
1157
Difference between revision 2 and revision 1
1158
bzr diff --diff-prefix old/:new/
1159
Same as 'bzr diff' but prefix paths with old/ and new/
1160
bzr diff bzr.mine bzr.dev
1161
Show the differences between the two working trees
1163
Show just the differences for 'foo.c'
1479
_see_also = ['status']
1165
# TODO: Option to use external diff command; could be GNU diff, wdiff,
1166
# or a graphical diff.
1168
# TODO: Python difflib is not exactly the same as unidiff; should
1169
# either fix it up or prefer to use an external diff.
1171
# TODO: Selected-file diff is inefficient and doesn't show you
1174
# TODO: This probably handles non-Unix newlines poorly.
1480
1176
takes_args = ['file*']
1482
Option('diff-options', type=str,
1483
help='Pass these options to the external diff program.'),
1484
Option('prefix', type=str,
1486
help='Set prefixes added to old and new filenames, as '
1487
'two values separated by a colon. (eg "old/:new/").'),
1489
help='Branch/tree to compare from.',
1493
help='Branch/tree to compare to.',
1499
help='Use this command to compare files.',
1177
takes_options = ['revision', 'diff-options', 'prefix']
1503
1178
aliases = ['di', 'dif']
1504
1179
encoding_type = 'exact'
1506
1181
@display_command
1507
1182
def run(self, revision=None, file_list=None, diff_options=None,
1508
prefix=None, old=None, new=None, using=None):
1509
from bzrlib.diff import _get_trees_to_diff, show_diff_trees
1184
from bzrlib.diff import diff_cmd_helper, show_diff_trees
1511
1186
if (prefix is None) or (prefix == '0'):
1512
1187
# diff -p0 format
2765
2130
default, use --remember. The value will only be saved if the remote
2766
2131
location can be accessed.
2768
The results of the merge are placed into the destination working
2769
directory, where they can be reviewed (with bzr diff), tested, and then
2770
committed to record the result of the merge.
2135
To merge the latest revision from bzr.dev
2136
bzr merge ../bzr.dev
2138
To merge changes up to and including revision 82 from bzr.dev
2139
bzr merge -r 82 ../bzr.dev
2141
To merge the changes introduced by 82, without previous changes:
2142
bzr merge -r 81..82 ../bzr.dev
2772
2144
merge refuses to run if there are any uncommitted changes, unless
2773
2145
--force is given.
2776
To merge the latest revision from bzr.dev::
2778
bzr merge ../bzr.dev
2780
To merge changes up to and including revision 82 from bzr.dev::
2782
bzr merge -r 82 ../bzr.dev
2784
To merge the changes introduced by 82, without previous changes::
2786
bzr merge -r 81..82 ../bzr.dev
2147
The following merge types are available:
2789
encoding_type = 'exact'
2790
_see_also = ['update', 'remerge', 'status-flags']
2791
2149
takes_args = ['branch?']
2796
help='Merge even if the destination tree has uncommitted changes.'),
2800
Option('show-base', help="Show base revision text in "
2802
Option('uncommitted', help='Apply uncommitted changes'
2803
' from a working copy, instead of branch changes.'),
2804
Option('pull', help='If the destination is already'
2805
' completely merged into the source, pull from the'
2806
' source rather than merging. When this happens,'
2807
' you do not need to commit the result.'),
2809
help='Branch to merge into, '
2810
'rather than the one containing the working directory.',
2814
Option('preview', help='Instead of merging, show a diff of the merge.')
2150
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2151
Option('show-base', help="Show base revision text in "
2153
Option('uncommitted', help='Apply uncommitted changes'
2154
' from a working copy, instead of branch changes')]
2157
from inspect import getdoc
2158
return getdoc(self) + '\n' + _mod_merge.merge_type_help()
2817
2160
def run(self, branch=None, revision=None, force=False, merge_type=None,
2818
show_base=False, reprocess=False, remember=False,
2819
uncommitted=False, pull=False,
2823
# This is actually a branch (or merge-directive) *location*.
2161
show_base=False, reprocess=False, remember=False,
2827
2163
if merge_type is None:
2828
2164
merge_type = _mod_merge.Merge3Merger
2830
if directory is None: directory = u'.'
2831
possible_transports = []
2833
allow_pending = True
2834
verified = 'inapplicable'
2835
tree = WorkingTree.open_containing(directory)[0]
2836
change_reporter = delta._ChangeReporter(
2837
unversioned_filter=tree.is_ignored)
2166
tree = WorkingTree.open_containing(u'.')[0]
2168
if branch is not None:
2170
reader = bundle.read_bundle_from_url(branch)
2171
except errors.NotABundle:
2172
pass # Continue on considering this url a Branch
2174
conflicts = merge_bundle(reader, tree, not force, merge_type,
2175
reprocess, show_base)
2181
if revision is None \
2182
or len(revision) < 1 or revision[0].needs_branch():
2183
branch = self._get_remembered_parent(tree, branch, 'Merging from')
2185
if revision is None or len(revision) < 1:
2188
other = [branch, None]
2191
other = [branch, -1]
2192
other_branch, path = Branch.open_containing(branch)
2195
raise errors.BzrCommandError('Cannot use --uncommitted and'
2196
' --revision at the same time.')
2197
branch = revision[0].get_branch() or branch
2198
if len(revision) == 1:
2200
other_branch, path = Branch.open_containing(branch)
2201
revno = revision[0].in_history(other_branch).revno
2202
other = [branch, revno]
2204
assert len(revision) == 2
2205
if None in revision:
2206
raise errors.BzrCommandError(
2207
"Merge doesn't permit empty revision specifier.")
2208
base_branch, path = Branch.open_containing(branch)
2209
branch1 = revision[1].get_branch() or branch
2210
other_branch, path1 = Branch.open_containing(branch1)
2211
if revision[0].get_branch() is not None:
2212
# then path was obtained from it, and is None.
2215
base = [branch, revision[0].in_history(base_branch).revno]
2216
other = [branch1, revision[1].in_history(other_branch).revno]
2218
if tree.branch.get_parent() is None or remember:
2219
tree.branch.set_parent(other_branch.base)
2222
interesting_files = [path]
2224
interesting_files = None
2225
pb = ui.ui_factory.nested_progress_bar()
2840
pb = ui.ui_factory.nested_progress_bar()
2841
cleanups.append(pb.finished)
2843
cleanups.append(tree.unlock)
2844
if location is not None:
2845
mergeable, other_transport = _get_mergeable_helper(location)
2848
raise errors.BzrCommandError('Cannot use --uncommitted'
2849
' with bundles or merge directives.')
2851
if revision is not None:
2852
raise errors.BzrCommandError(
2853
'Cannot use -r with merge directives or bundles')
2854
merger, verified = _mod_merge.Merger.from_mergeable(tree,
2856
possible_transports.append(other_transport)
2858
if merger is None and uncommitted:
2859
if revision is not None and len(revision) > 0:
2860
raise errors.BzrCommandError('Cannot use --uncommitted and'
2861
' --revision at the same time.')
2862
location = self._select_branch_location(tree, location)[0]
2863
other_tree, other_path = WorkingTree.open_containing(location)
2864
merger = _mod_merge.Merger.from_uncommitted(tree, other_tree,
2866
allow_pending = False
2867
if other_path != '':
2868
merger.interesting_files = [other_path]
2871
merger, allow_pending = self._get_merger_from_branch(tree,
2872
location, revision, remember, possible_transports, pb)
2874
merger.merge_type = merge_type
2875
merger.reprocess = reprocess
2876
merger.show_base = show_base
2877
self.sanity_check_merger(merger)
2878
if (merger.base_rev_id == merger.other_rev_id and
2879
merger.other_rev_id != None):
2880
note('Nothing to do.')
2228
conflict_count = _merge_helper(
2229
other, base, check_clean=(not force),
2230
merge_type=merge_type,
2231
reprocess=reprocess,
2232
show_base=show_base,
2233
pb=pb, file_list=interesting_files)
2236
if conflict_count != 0:
2883
if merger.interesting_files is not None:
2884
raise errors.BzrCommandError('Cannot pull individual files')
2885
if (merger.base_rev_id == tree.last_revision()):
2886
result = tree.pull(merger.other_branch, False,
2887
merger.other_rev_id)
2888
result.report(self.outf)
2890
merger.check_basis(not force)
2892
return self._do_preview(merger)
2894
return self._do_merge(merger, change_reporter, allow_pending,
2897
for cleanup in reversed(cleanups):
2900
def _do_preview(self, merger):
2901
from bzrlib.diff import show_diff_trees
2902
tree_merger = merger.make_merger()
2903
tt = tree_merger.make_preview_transform()
2905
result_tree = tt.get_preview_tree()
2906
show_diff_trees(merger.this_tree, result_tree, self.outf,
2907
old_label='', new_label='')
2911
def _do_merge(self, merger, change_reporter, allow_pending, verified):
2912
merger.change_reporter = change_reporter
2913
conflict_count = merger.do_merge()
2915
merger.set_pending()
2916
if verified == 'failed':
2917
warning('Preview patch does not match changes')
2918
if conflict_count != 0:
2923
def sanity_check_merger(self, merger):
2924
if (merger.show_base and
2925
not merger.merge_type is _mod_merge.Merge3Merger):
2926
raise errors.BzrCommandError("Show-base is not supported for this"
2927
" merge type. %s" % merger.merge_type)
2928
if merger.reprocess and not merger.merge_type.supports_reprocess:
2929
raise errors.BzrCommandError("Conflict reduction is not supported"
2930
" for merge type %s." %
2932
if merger.reprocess and merger.show_base:
2933
raise errors.BzrCommandError("Cannot do conflict reduction and"
2936
def _get_merger_from_branch(self, tree, location, revision, remember,
2937
possible_transports, pb):
2938
"""Produce a merger from a location, assuming it refers to a branch."""
2939
from bzrlib.tag import _merge_tags_if_possible
2940
assert revision is None or len(revision) < 3
2941
# find the branch locations
2942
other_loc, user_location = self._select_branch_location(tree, location,
2944
if revision is not None and len(revision) == 2:
2945
base_loc, _unused = self._select_branch_location(tree,
2946
location, revision, 0)
2948
base_loc = other_loc
2950
other_branch, other_path = Branch.open_containing(other_loc,
2951
possible_transports)
2952
if base_loc == other_loc:
2953
base_branch = other_branch
2955
base_branch, base_path = Branch.open_containing(base_loc,
2956
possible_transports)
2957
# Find the revision ids
2958
if revision is None or len(revision) < 1 or revision[-1] is None:
2959
other_revision_id = _mod_revision.ensure_null(
2960
other_branch.last_revision())
2962
other_revision_id = \
2963
_mod_revision.ensure_null(
2964
revision[-1].in_history(other_branch).rev_id)
2965
if (revision is not None and len(revision) == 2
2966
and revision[0] is not None):
2967
base_revision_id = \
2968
_mod_revision.ensure_null(
2969
revision[0].in_history(base_branch).rev_id)
2971
base_revision_id = None
2972
# Remember where we merge from
2973
if ((remember or tree.branch.get_submit_branch() is None) and
2974
user_location is not None):
2975
tree.branch.set_submit_branch(other_branch.base)
2976
_merge_tags_if_possible(other_branch, tree.branch)
2977
merger = _mod_merge.Merger.from_revision_ids(pb, tree,
2978
other_revision_id, base_revision_id, other_branch, base_branch)
2979
if other_path != '':
2980
allow_pending = False
2981
merger.interesting_files = [other_path]
2983
allow_pending = True
2984
return merger, allow_pending
2986
def _select_branch_location(self, tree, user_location, revision=None,
2988
"""Select a branch location, according to possible inputs.
2990
If provided, branches from ``revision`` are preferred. (Both
2991
``revision`` and ``index`` must be supplied.)
2993
Otherwise, the ``location`` parameter is used. If it is None, then the
2994
``submit`` or ``parent`` location is used, and a note is printed.
2996
:param tree: The working tree to select a branch for merging into
2997
:param location: The location entered by the user
2998
:param revision: The revision parameter to the command
2999
:param index: The index to use for the revision parameter. Negative
3000
indices are permitted.
3001
:return: (selected_location, user_location). The default location
3002
will be the user-entered location.
3004
if (revision is not None and index is not None
3005
and revision[index] is not None):
3006
branch = revision[index].get_branch()
3007
if branch is not None:
3008
return branch, branch
3009
if user_location is None:
3010
location = self._get_remembered(tree, 'Merging from')
3012
location = user_location
3013
return location, user_location
3015
def _get_remembered(self, tree, verb_string):
2240
except errors.AmbiguousBase, e:
2241
m = ("sorry, bzr can't determine the right merge base yet\n"
2242
"candidates are:\n "
2243
+ "\n ".join(e.bases)
2245
"please specify an explicit base with -r,\n"
2246
"and (if you want) report this to the bzr developers\n")
2249
# TODO: move up to common parent; this isn't merge-specific anymore.
2250
def _get_remembered_parent(self, tree, supplied_location, verb_string):
3016
2251
"""Use tree.branch's parent if none was supplied.
3018
2253
Report if the remembered location was used.
3020
stored_location = tree.branch.get_submit_branch()
3021
if stored_location is None:
3022
stored_location = tree.branch.get_parent()
2255
if supplied_location is not None:
2256
return supplied_location
2257
stored_location = tree.branch.get_parent()
3023
2258
mutter("%s", stored_location)
3024
2259
if stored_location is None:
3025
2260
raise errors.BzrCommandError("No location specified or remembered")
3026
display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
3027
note(u"%s remembered location %s", verb_string, display_url)
2261
display_url = urlutils.unescape_for_display(stored_location, self.outf.encoding)
2262
self.outf.write("%s remembered location %s\n" % (verb_string, display_url))
3028
2263
return stored_location
3765
2830
takes_options = [
3767
help='Serve on stdin/out for use from inetd or sshd.'),
2832
help='serve on stdin/out for use from inetd or sshd'),
3769
help='Listen for connections on nominated port of the form '
3770
'[hostname:]portnumber. Passing 0 as the port number will '
3771
'result in a dynamically allocated port. The default port is '
2834
help='listen for connections on nominated port of the form '
2835
'[hostname:]portnumber. Passing 0 as the port number will '
2836
'result in a dynamically allocated port.',
3774
2838
Option('directory',
3775
help='Serve contents of this directory.',
2839
help='serve contents of directory',
3777
2841
Option('allow-writes',
3778
help='By default the server is a readonly server. Supplying '
2842
help='By default the server is a readonly server. Supplying '
3779
2843
'--allow-writes enables write access to the contents of '
3780
'the served directory and below.'
2844
'the served directory and below. '
3784
2848
def run(self, port=None, inet=False, directory=None, allow_writes=False):
3785
from bzrlib import lockdir
3786
from bzrlib.smart import medium, server
2849
from bzrlib.transport import smart
3787
2850
from bzrlib.transport import get_transport
3788
from bzrlib.transport.chroot import ChrootServer
3789
2851
if directory is None:
3790
2852
directory = os.getcwd()
3791
2853
url = urlutils.local_path_to_url(directory)
3792
2854
if not allow_writes:
3793
2855
url = 'readonly+' + url
3794
chroot_server = ChrootServer(get_transport(url))
3795
chroot_server.setUp()
3796
t = get_transport(chroot_server.get_url())
2856
t = get_transport(url)
3798
smart_server = medium.SmartServerPipeStreamMedium(
3799
sys.stdin, sys.stdout, t)
3801
host = medium.BZR_DEFAULT_INTERFACE
3803
port = medium.BZR_DEFAULT_PORT
2858
server = smart.SmartStreamServer(sys.stdin, sys.stdout, t)
2859
elif port is not None:
2861
host, port = port.split(':')
3806
host, port = port.split(':')
3808
smart_server = server.SmartTCPServer(t, host=host, port=port)
3809
print 'listening on port: ', smart_server.port
2864
server = smart.SmartTCPServer(t, host=host, port=int(port))
2865
print 'listening on port: ', server.port
3810
2866
sys.stdout.flush()
3811
# for the duration of this server, no UI output is permitted.
3812
# note that this may cause problems with blackbox tests. This should
3813
# be changed with care though, as we dont want to use bandwidth sending
3814
# progress over stderr to smart server clients!
3815
old_factory = ui.ui_factory
3816
old_lockdir_timeout = lockdir._DEFAULT_TIMEOUT_SECONDS
3818
ui.ui_factory = ui.SilentUIFactory()
3819
lockdir._DEFAULT_TIMEOUT_SECONDS = 0
3820
smart_server.serve()
3822
ui.ui_factory = old_factory
3823
lockdir._DEFAULT_TIMEOUT_SECONDS = old_lockdir_timeout
3826
class cmd_join(Command):
3827
"""Combine a subtree into its containing tree.
3829
This command is for experimental use only. It requires the target tree
3830
to be in dirstate-with-subtree format, which cannot be converted into
3833
The TREE argument should be an independent tree, inside another tree, but
3834
not part of it. (Such trees can be produced by "bzr split", but also by
3835
running "bzr branch" with the target inside a tree.)
3837
The result is a combined tree, with the subtree no longer an independant
3838
part. This is marked as a merge of the subtree into the containing tree,
3839
and all history is preserved.
3841
If --reference is specified, the subtree retains its independence. It can
3842
be branched by itself, and can be part of multiple projects at the same
3843
time. But operations performed in the containing tree, such as commit
3844
and merge, will recurse into the subtree.
3847
_see_also = ['split']
3848
takes_args = ['tree']
3850
Option('reference', help='Join by reference.'),
3854
def run(self, tree, reference=False):
3855
sub_tree = WorkingTree.open(tree)
3856
parent_dir = osutils.dirname(sub_tree.basedir)
3857
containing_tree = WorkingTree.open_containing(parent_dir)[0]
3858
repo = containing_tree.branch.repository
3859
if not repo.supports_rich_root():
3860
raise errors.BzrCommandError(
3861
"Can't join trees because %s doesn't support rich root data.\n"
3862
"You can use bzr upgrade on the repository."
3866
containing_tree.add_reference(sub_tree)
3867
except errors.BadReferenceTarget, e:
3868
# XXX: Would be better to just raise a nicely printable
3869
# exception from the real origin. Also below. mbp 20070306
3870
raise errors.BzrCommandError("Cannot join %s. %s" %
3874
containing_tree.subsume(sub_tree)
3875
except errors.BadSubsumeSource, e:
3876
raise errors.BzrCommandError("Cannot join %s. %s" %
3880
class cmd_split(Command):
3881
"""Split a subdirectory of a tree into a separate tree.
3883
This command will produce a target tree in a format that supports
3884
rich roots, like 'rich-root' or 'rich-root-pack'. These formats cannot be
3885
converted into earlier formats like 'dirstate-tags'.
3887
The TREE argument should be a subdirectory of a working tree. That
3888
subdirectory will be converted into an independent tree, with its own
3889
branch. Commits in the top-level tree will not apply to the new subtree.
3892
# join is not un-hidden yet
3893
#_see_also = ['join']
3894
takes_args = ['tree']
3896
def run(self, tree):
3897
containing_tree, subdir = WorkingTree.open_containing(tree)
3898
sub_id = containing_tree.path2id(subdir)
3900
raise errors.NotVersionedError(subdir)
3902
containing_tree.extract(sub_id)
3903
except errors.RootNotRich:
3904
raise errors.UpgradeRequired(containing_tree.branch.base)
3907
class cmd_merge_directive(Command):
3908
"""Generate a merge directive for auto-merge tools.
3910
A directive requests a merge to be performed, and also provides all the
3911
information necessary to do so. This means it must either include a
3912
revision bundle, or the location of a branch containing the desired
3915
A submit branch (the location to merge into) must be supplied the first
3916
time the command is issued. After it has been supplied once, it will
3917
be remembered as the default.
3919
A public branch is optional if a revision bundle is supplied, but required
3920
if --diff or --plain is specified. It will be remembered as the default
3921
after the first use.
3924
takes_args = ['submit_branch?', 'public_branch?']
3928
_see_also = ['send']
3931
RegistryOption.from_kwargs('patch-type',
3932
'The type of patch to include in the directive.',
3934
value_switches=True,
3936
bundle='Bazaar revision bundle (default).',
3937
diff='Normal unified diff.',
3938
plain='No patch, just directive.'),
3939
Option('sign', help='GPG-sign the directive.'), 'revision',
3940
Option('mail-to', type=str,
3941
help='Instead of printing the directive, email to this address.'),
3942
Option('message', type=str, short_name='m',
3943
help='Message to use when committing this merge.')
3946
encoding_type = 'exact'
3948
def run(self, submit_branch=None, public_branch=None, patch_type='bundle',
3949
sign=False, revision=None, mail_to=None, message=None):
3950
from bzrlib.revision import ensure_null, NULL_REVISION
3951
include_patch, include_bundle = {
3952
'plain': (False, False),
3953
'diff': (True, False),
3954
'bundle': (True, True),
3956
branch = Branch.open('.')
3957
stored_submit_branch = branch.get_submit_branch()
3958
if submit_branch is None:
3959
submit_branch = stored_submit_branch
3961
if stored_submit_branch is None:
3962
branch.set_submit_branch(submit_branch)
3963
if submit_branch is None:
3964
submit_branch = branch.get_parent()
3965
if submit_branch is None:
3966
raise errors.BzrCommandError('No submit branch specified or known')
3968
stored_public_branch = branch.get_public_branch()
3969
if public_branch is None:
3970
public_branch = stored_public_branch
3971
elif stored_public_branch is None:
3972
branch.set_public_branch(public_branch)
3973
if not include_bundle and public_branch is None:
3974
raise errors.BzrCommandError('No public branch specified or'
3976
base_revision_id = None
3977
if revision is not None:
3978
if len(revision) > 2:
3979
raise errors.BzrCommandError('bzr merge-directive takes '
3980
'at most two one revision identifiers')
3981
revision_id = revision[-1].in_history(branch).rev_id
3982
if len(revision) == 2:
3983
base_revision_id = revision[0].in_history(branch).rev_id
3984
base_revision_id = ensure_null(base_revision_id)
3986
revision_id = branch.last_revision()
3987
revision_id = ensure_null(revision_id)
3988
if revision_id == NULL_REVISION:
3989
raise errors.BzrCommandError('No revisions to bundle.')
3990
directive = merge_directive.MergeDirective2.from_objects(
3991
branch.repository, revision_id, time.time(),
3992
osutils.local_time_offset(), submit_branch,
3993
public_branch=public_branch, include_patch=include_patch,
3994
include_bundle=include_bundle, message=message,
3995
base_revision_id=base_revision_id)
3998
self.outf.write(directive.to_signed(branch))
4000
self.outf.writelines(directive.to_lines())
4002
message = directive.to_email(mail_to, branch, sign)
4003
s = SMTPConnection(branch.get_config())
4004
s.send_email(message)
4007
class cmd_send(Command):
4008
"""Mail or create a merge-directive for submiting changes.
4010
A merge directive provides many things needed for requesting merges:
4012
* A machine-readable description of the merge to perform
4014
* An optional patch that is a preview of the changes requested
4016
* An optional bundle of revision data, so that the changes can be applied
4017
directly from the merge directive, without retrieving data from a
4020
If --no-bundle is specified, then public_branch is needed (and must be
4021
up-to-date), so that the receiver can perform the merge using the
4022
public_branch. The public_branch is always included if known, so that
4023
people can check it later.
4025
The submit branch defaults to the parent, but can be overridden. Both
4026
submit branch and public branch will be remembered if supplied.
4028
If a public_branch is known for the submit_branch, that public submit
4029
branch is used in the merge instructions. This means that a local mirror
4030
can be used as your actual submit branch, once you have set public_branch
4033
Mail is sent using your preferred mail program. This should be transparent
4034
on Windows (it uses MAPI). On Linux, it requires the xdg-email utility.
4035
If the preferred client can't be found (or used), your editor will be used.
4037
To use a specific mail program, set the mail_client configuration option.
4038
(For Thunderbird 1.5, this works around some bugs.) Supported values for
4039
specific clients are "evolution", "kmail", "mutt", and "thunderbird";
4040
generic options are "default", "editor", "mapi", and "xdg-email".
4042
If mail is being sent, a to address is required. This can be supplied
4043
either on the commandline, by setting the submit_to configuration
4044
option in the branch itself or the child_submit_to configuration option
4045
in the submit branch.
4047
Two formats are currently supported: "4" uses revision bundle format 4 and
4048
merge directive format 2. It is significantly faster and smaller than
4049
older formats. It is compatible with Bazaar 0.19 and later. It is the
4050
default. "0.9" uses revision bundle format 0.9 and merge directive
4051
format 1. It is compatible with Bazaar 0.12 - 0.18.
4054
encoding_type = 'exact'
4056
_see_also = ['merge']
4058
takes_args = ['submit_branch?', 'public_branch?']
4062
help='Do not include a bundle in the merge directive.'),
4063
Option('no-patch', help='Do not include a preview patch in the merge'
4066
help='Remember submit and public branch.'),
4068
help='Branch to generate the submission from, '
4069
'rather than the one containing the working directory.',
4072
Option('output', short_name='o', help='Write directive to this file.',
4074
Option('mail-to', help='Mail the request to this address.',
4078
RegistryOption.from_kwargs('format',
4079
'Use the specified output format.',
4080
**{'4': 'Bundle format 4, Merge Directive 2 (default)',
4081
'0.9': 'Bundle format 0.9, Merge Directive 1',})
4084
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
4085
no_patch=False, revision=None, remember=False, output=None,
4086
format='4', mail_to=None, message=None, **kwargs):
4087
return self._run(submit_branch, revision, public_branch, remember,
4088
format, no_bundle, no_patch, output,
4089
kwargs.get('from', '.'), mail_to, message)
4091
def _run(self, submit_branch, revision, public_branch, remember, format,
4092
no_bundle, no_patch, output, from_, mail_to, message):
4093
from bzrlib.revision import NULL_REVISION
4094
branch = Branch.open_containing(from_)[0]
4096
outfile = StringIO()
4100
outfile = open(output, 'wb')
4101
# we may need to write data into branch's repository to calculate
4106
config = branch.get_config()
4108
mail_to = config.get_user_option('submit_to')
4109
mail_client = config.get_mail_client()
4110
if remember and submit_branch is None:
4111
raise errors.BzrCommandError(
4112
'--remember requires a branch to be specified.')
4113
stored_submit_branch = branch.get_submit_branch()
4114
remembered_submit_branch = False
4115
if submit_branch is None:
4116
submit_branch = stored_submit_branch
4117
remembered_submit_branch = True
4119
if stored_submit_branch is None or remember:
4120
branch.set_submit_branch(submit_branch)
4121
if submit_branch is None:
4122
submit_branch = branch.get_parent()
4123
remembered_submit_branch = True
4124
if submit_branch is None:
4125
raise errors.BzrCommandError('No submit branch known or'
4127
if remembered_submit_branch:
4128
note('Using saved location: %s', submit_branch)
4131
submit_config = Branch.open(submit_branch).get_config()
4132
mail_to = submit_config.get_user_option("child_submit_to")
4134
stored_public_branch = branch.get_public_branch()
4135
if public_branch is None:
4136
public_branch = stored_public_branch
4137
elif stored_public_branch is None or remember:
4138
branch.set_public_branch(public_branch)
4139
if no_bundle and public_branch is None:
4140
raise errors.BzrCommandError('No public branch specified or'
4142
base_revision_id = None
4144
if revision is not None:
4145
if len(revision) > 2:
4146
raise errors.BzrCommandError('bzr send takes '
4147
'at most two one revision identifiers')
4148
revision_id = revision[-1].in_history(branch).rev_id
4149
if len(revision) == 2:
4150
base_revision_id = revision[0].in_history(branch).rev_id
4151
if revision_id is None:
4152
revision_id = branch.last_revision()
4153
if revision_id == NULL_REVISION:
4154
raise errors.BzrCommandError('No revisions to submit.')
4156
directive = merge_directive.MergeDirective2.from_objects(
4157
branch.repository, revision_id, time.time(),
4158
osutils.local_time_offset(), submit_branch,
4159
public_branch=public_branch, include_patch=not no_patch,
4160
include_bundle=not no_bundle, message=message,
4161
base_revision_id=base_revision_id)
4162
elif format == '0.9':
4165
patch_type = 'bundle'
4167
raise errors.BzrCommandError('Format 0.9 does not'
4168
' permit bundle with no patch')
4174
directive = merge_directive.MergeDirective.from_objects(
4175
branch.repository, revision_id, time.time(),
4176
osutils.local_time_offset(), submit_branch,
4177
public_branch=public_branch, patch_type=patch_type,
4180
outfile.writelines(directive.to_lines())
4182
subject = '[MERGE] '
4183
if message is not None:
4186
revision = branch.repository.get_revision(revision_id)
4187
subject += revision.get_summary()
4188
basename = directive.get_disk_name(branch)
4189
mail_client.compose_merge_request(mail_to, subject,
4190
outfile.getvalue(), basename)
4197
class cmd_bundle_revisions(cmd_send):
4199
"""Create a merge-directive for submiting changes.
4201
A merge directive provides many things needed for requesting merges:
4203
* A machine-readable description of the merge to perform
4205
* An optional patch that is a preview of the changes requested
4207
* An optional bundle of revision data, so that the changes can be applied
4208
directly from the merge directive, without retrieving data from a
4211
If --no-bundle is specified, then public_branch is needed (and must be
4212
up-to-date), so that the receiver can perform the merge using the
4213
public_branch. The public_branch is always included if known, so that
4214
people can check it later.
4216
The submit branch defaults to the parent, but can be overridden. Both
4217
submit branch and public branch will be remembered if supplied.
4219
If a public_branch is known for the submit_branch, that public submit
4220
branch is used in the merge instructions. This means that a local mirror
4221
can be used as your actual submit branch, once you have set public_branch
4224
Two formats are currently supported: "4" uses revision bundle format 4 and
4225
merge directive format 2. It is significantly faster and smaller than
4226
older formats. It is compatible with Bazaar 0.19 and later. It is the
4227
default. "0.9" uses revision bundle format 0.9 and merge directive
4228
format 1. It is compatible with Bazaar 0.12 - 0.18.
4233
help='Do not include a bundle in the merge directive.'),
4234
Option('no-patch', help='Do not include a preview patch in the merge'
4237
help='Remember submit and public branch.'),
4239
help='Branch to generate the submission from, '
4240
'rather than the one containing the working directory.',
4243
Option('output', short_name='o', help='Write directive to this file.',
4246
RegistryOption.from_kwargs('format',
4247
'Use the specified output format.',
4248
**{'4': 'Bundle format 4, Merge Directive 2 (default)',
4249
'0.9': 'Bundle format 0.9, Merge Directive 1',})
4251
aliases = ['bundle']
4253
_see_also = ['send', 'merge']
4257
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
4258
no_patch=False, revision=None, remember=False, output=None,
4259
format='4', **kwargs):
4262
return self._run(submit_branch, revision, public_branch, remember,
4263
format, no_bundle, no_patch, output,
4264
kwargs.get('from', '.'), None, None)
4267
class cmd_tag(Command):
4268
"""Create, remove or modify a tag naming a revision.
4270
Tags give human-meaningful names to revisions. Commands that take a -r
4271
(--revision) option can be given -rtag:X, where X is any previously
4274
Tags are stored in the branch. Tags are copied from one branch to another
4275
along when you branch, push, pull or merge.
4277
It is an error to give a tag name that already exists unless you pass
4278
--force, in which case the tag is moved to point to the new revision.
4281
_see_also = ['commit', 'tags']
4282
takes_args = ['tag_name']
4285
help='Delete this tag rather than placing it.',
4288
help='Branch in which to place the tag.',
4293
help='Replace existing tags.',
4298
def run(self, tag_name,
4304
branch, relpath = Branch.open_containing(directory)
4308
branch.tags.delete_tag(tag_name)
4309
self.outf.write('Deleted tag %s.\n' % tag_name)
4312
if len(revision) != 1:
4313
raise errors.BzrCommandError(
4314
"Tags can only be placed on a single revision, "
4316
revision_id = revision[0].in_history(branch).rev_id
4318
revision_id = branch.last_revision()
4319
if (not force) and branch.tags.has_tag(tag_name):
4320
raise errors.TagAlreadyExists(tag_name)
4321
branch.tags.set_tag(tag_name, revision_id)
4322
self.outf.write('Created tag %s.\n' % tag_name)
4327
class cmd_tags(Command):
4330
This command shows a table of tag names and the revisions they reference.
4336
help='Branch whose tags should be displayed.',
4340
RegistryOption.from_kwargs('sort',
4341
'Sort tags by different criteria.', title='Sorting',
4342
alpha='Sort tags lexicographically (default).',
4343
time='Sort tags chronologically.',
4354
branch, relpath = Branch.open_containing(directory)
4355
tags = branch.tags.get_tag_dict().items()
4358
elif sort == 'time':
4360
for tag, revid in tags:
4362
revobj = branch.repository.get_revision(revid)
4363
except errors.NoSuchRevision:
4364
timestamp = sys.maxint # place them at the end
4366
timestamp = revobj.timestamp
4367
timestamps[revid] = timestamp
4368
tags.sort(key=lambda x: timestamps[x[1]])
4370
# [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
4371
revno_map = branch.get_revision_id_to_revno_map()
4372
tags = [ (tag, '.'.join(map(str, revno_map.get(revid, ('?',)))))
4373
for tag, revid in tags ]
4374
for tag, revspec in tags:
4375
self.outf.write('%-20s %s\n' % (tag, revspec))
4378
class cmd_reconfigure(Command):
4379
"""Reconfigure the type of a bzr directory.
4381
A target configuration must be specified.
4383
For checkouts, the bind-to location will be auto-detected if not specified.
4384
The order of preference is
4385
1. For a lightweight checkout, the current bound location.
4386
2. For branches that used to be checkouts, the previously-bound location.
4387
3. The push location.
4388
4. The parent location.
4389
If none of these is available, --bind-to must be specified.
4392
takes_args = ['location?']
4393
takes_options = [RegistryOption.from_kwargs('target_type',
4394
title='Target type',
4395
help='The type to reconfigure the directory to.',
4396
value_switches=True, enum_switch=False,
4397
branch='Reconfigure to a branch.',
4398
tree='Reconfigure to a tree.',
4399
checkout='Reconfigure to a checkout.',
4400
lightweight_checkout='Reconfigure to a lightweight'
4402
Option('bind-to', help='Branch to bind checkout to.',
4405
help='Perform reconfiguration even if local changes'
4409
def run(self, location=None, target_type=None, bind_to=None, force=False):
4410
directory = bzrdir.BzrDir.open(location)
4411
if target_type is None:
4412
raise errors.BzrCommandError('No target configuration specified')
4413
elif target_type == 'branch':
4414
reconfiguration = reconfigure.Reconfigure.to_branch(directory)
4415
elif target_type == 'tree':
4416
reconfiguration = reconfigure.Reconfigure.to_tree(directory)
4417
elif target_type == 'checkout':
4418
reconfiguration = reconfigure.Reconfigure.to_checkout(directory,
4420
elif target_type == 'lightweight-checkout':
4421
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
4423
reconfiguration.apply(force)
4426
class cmd_switch(Command):
4427
"""Set the branch of a checkout and update.
4429
For lightweight checkouts, this changes the branch being referenced.
4430
For heavyweight checkouts, this checks that there are no local commits
4431
versus the current bound branch, then it makes the local branch a mirror
4432
of the new location and binds to it.
4434
In both cases, the working tree is updated and uncommitted changes
4435
are merged. The user can commit or revert these as they desire.
4437
Pending merges need to be committed or reverted before using switch.
4440
takes_args = ['to_location']
4441
takes_options = [Option('force',
4442
help='Switch even if local commits will be lost.')
4445
def run(self, to_location, force=False):
4446
from bzrlib import switch
4447
to_branch = Branch.open(to_location)
4449
control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
4450
switch.switch(control_dir, to_branch, force)
4451
note('Switched to branch: %s',
4452
urlutils.unescape_for_display(to_branch.base, 'utf-8'))
4455
class cmd_hooks(Command):
4456
"""Show a branch's currently registered hooks.
4460
takes_args = ['path?']
4462
def run(self, path=None):
4465
branch_hooks = Branch.open(path).hooks
4466
for hook_type in branch_hooks:
4467
hooks = branch_hooks[hook_type]
4468
self.outf.write("%s:\n" % (hook_type,))
4471
self.outf.write(" %s\n" %
4472
(branch_hooks.get_hook_name(hook),))
4474
self.outf.write(" <no hooks installed>\n")
4477
def _create_prefix(cur_transport):
4478
needed = [cur_transport]
4479
# Recurse upwards until we can create a directory successfully
4481
new_transport = cur_transport.clone('..')
4482
if new_transport.base == cur_transport.base:
4483
raise errors.BzrCommandError(
4484
"Failed to create path prefix for %s."
4485
% cur_transport.base)
4487
new_transport.mkdir('.')
4488
except errors.NoSuchFile:
4489
needed.append(new_transport)
4490
cur_transport = new_transport
4493
# Now we only need to create child directories
4495
cur_transport = needed.pop()
4496
cur_transport.ensure_base()
4499
def _get_mergeable_helper(location):
4500
"""Get a merge directive or bundle if 'location' points to one.
4502
Try try to identify a bundle and returns its mergeable form. If it's not,
4503
we return the tried transport anyway so that it can reused to access the
4506
:param location: can point to a bundle or a branch.
4508
:return: mergeable, transport
4511
url = urlutils.normalize_url(location)
4512
url, filename = urlutils.split(url, exclude_trailing_slash=False)
4513
location_transport = transport.get_transport(url)
4516
# There may be redirections but we ignore the intermediate
4517
# and final transports used
4518
read = bundle.read_mergeable_from_transport
4519
mergeable, t = read(location_transport, filename)
4520
except errors.NotABundle:
4521
# Continue on considering this url a Branch but adjust the
4522
# location_transport
4523
location_transport = location_transport.clone(filename)
4524
return mergeable, location_transport
2868
raise errors.BzrCommandError("bzr serve requires one of --inet or --port")
2872
# command-line interpretation helper for merge-related commands
2873
def _merge_helper(other_revision, base_revision,
2874
check_clean=True, ignore_zero=False,
2875
this_dir=None, backup_files=False,
2877
file_list=None, show_base=False, reprocess=False,
2878
pb=DummyProgress()):
2879
"""Merge changes into a tree.
2882
list(path, revno) Base for three-way merge.
2883
If [None, None] then a base will be automatically determined.
2885
list(path, revno) Other revision for three-way merge.
2887
Directory to merge changes into; '.' by default.
2889
If true, this_dir must have no uncommitted changes before the
2891
ignore_zero - If true, suppress the "zero conflicts" message when
2892
there are no conflicts; should be set when doing something we expect
2893
to complete perfectly.
2894
file_list - If supplied, merge only changes to selected files.
2896
All available ancestors of other_revision and base_revision are
2897
automatically pulled into the branch.
2899
The revno may be -1 to indicate the last revision on the branch, which is
2902
This function is intended for use from the command line; programmatic
2903
clients might prefer to call merge.merge_inner(), which has less magic
2906
# Loading it late, so that we don't always have to import bzrlib.merge
2907
if merge_type is None:
2908
merge_type = _mod_merge.Merge3Merger
2909
if this_dir is None:
2911
this_tree = WorkingTree.open_containing(this_dir)[0]
2912
if show_base and not merge_type is _mod_merge.Merge3Merger:
2913
raise errors.BzrCommandError("Show-base is not supported for this merge"
2914
" type. %s" % merge_type)
2915
if reprocess and not merge_type.supports_reprocess:
2916
raise errors.BzrCommandError("Conflict reduction is not supported for merge"
2917
" type %s." % merge_type)
2918
if reprocess and show_base:
2919
raise errors.BzrCommandError("Cannot do conflict reduction and show base.")
2921
merger = _mod_merge.Merger(this_tree.branch, this_tree=this_tree,
2923
merger.pp = ProgressPhase("Merge phase", 5, pb)
2924
merger.pp.next_phase()
2925
merger.check_basis(check_clean)
2926
merger.set_other(other_revision)
2927
merger.pp.next_phase()
2928
merger.set_base(base_revision)
2929
if merger.base_rev_id == merger.other_rev_id:
2930
note('Nothing to do.')
2932
merger.backup_files = backup_files
2933
merger.merge_type = merge_type
2934
merger.set_interesting_files(file_list)
2935
merger.show_base = show_base
2936
merger.reprocess = reprocess
2937
conflicts = merger.do_merge()
2938
if file_list is None:
2939
merger.set_pending()
2946
merge = _merge_helper
4527
2949
# these get imported and then picked up by the scan for cmd_*