3895
3895
self.outf.write('%-20s %s\n' % (tag_name, target))
3898
# command-line interpretation helper for merge-related commands
3899
def _merge_helper(other_revision, base_revision,
3900
check_clean=True, ignore_zero=False,
3901
this_dir=None, backup_files=False,
3903
file_list=None, show_base=False, reprocess=False,
3906
change_reporter=None,
3907
other_rev_id=None, base_rev_id=None,
3908
possible_transports=None,
3910
"""Merge changes into a tree.
3913
list(path, revno) Base for three-way merge.
3914
If [None, None] then a base will be automatically determined.
3916
list(path, revno) Other revision for three-way merge.
3918
Directory to merge changes into; '.' by default.
3920
If true, this_dir must have no uncommitted changes before the
3922
ignore_zero - If true, suppress the "zero conflicts" message when
3923
there are no conflicts; should be set when doing something we expect
3924
to complete perfectly.
3925
file_list - If supplied, merge only changes to selected files.
3927
All available ancestors of other_revision and base_revision are
3928
automatically pulled into the branch.
3930
The revno may be -1 to indicate the last revision on the branch, which is
3933
This function is intended for use from the command line; programmatic
3934
clients might prefer to call merge.merge_inner(), which has less magic
3937
# Loading it late, so that we don't always have to import bzrlib.merge
3938
if merge_type is None:
3939
merge_type = _mod_merge.Merge3Merger
3940
if this_dir is None:
3942
this_tree = WorkingTree.open_containing(this_dir)[0]
3943
if other_branch is None:
3944
other_branch = this_tree.branch
3946
if show_base and not merge_type is _mod_merge.Merge3Merger:
3947
raise errors.BzrCommandError("Show-base is not supported for this merge"
3948
" type. %s" % merge_type)
3949
if reprocess and not merge_type.supports_reprocess:
3950
raise errors.BzrCommandError("Conflict reduction is not supported for merge"
3951
" type %s." % merge_type)
3952
if reprocess and show_base:
3953
raise errors.BzrCommandError("Cannot do conflict reduction and show base.")
3954
# TODO: jam 20070226 We should really lock these trees earlier. However, we
3955
# only want to take out a lock_tree_write() if we don't have to pull
3956
# any ancestry. But merge might fetch ancestry in the middle, in
3957
# which case we would need a lock_write().
3958
# Because we cannot upgrade locks, for now we live with the fact that
3959
# the tree will be locked multiple times during a merge. (Maybe
3960
# read-only some of the time, but it means things will get read
3963
merger = _mod_merge.Merger(this_tree.branch, this_tree=this_tree,
3964
pb=pb, change_reporter=change_reporter)
3965
merger.pp = ProgressPhase("Merge phase", 5, pb)
3966
merger.pp.next_phase()
3967
merger.check_basis(check_clean)
3968
if other_rev_id is not None:
3969
merger.set_other_revision(other_rev_id, other_branch)
3971
merger.set_other(other_revision, possible_transports)
3972
merger.pp.next_phase()
3973
if base_rev_id is not None:
3974
merger.set_base_revision(base_rev_id, this_tree.branch)
3975
elif base_revision is not None:
3976
merger.set_base(base_revision)
3979
if merger.base_rev_id == merger.other_rev_id:
3980
note('Nothing to do.')
3982
if file_list is None:
3983
if pull and merger.base_rev_id == merger.this_rev_id:
3984
# FIXME: deduplicate with pull
3985
result = merger.this_tree.pull(merger.this_branch,
3986
False, merger.other_rev_id)
3987
if result.old_revid == result.new_revid:
3988
note('No revisions to pull.')
3990
note('Now on revision %d.' % result.new_revno)
3992
merger.backup_files = backup_files
3993
merger.merge_type = merge_type
3994
merger.set_interesting_files(file_list)
3995
merger.show_base = show_base
3996
merger.reprocess = reprocess
3997
conflicts = merger.do_merge()
3998
if file_list is None:
3999
merger.set_pending()
4005
3898
def _create_prefix(cur_transport):
4006
3899
needed = [cur_transport]
4007
3900
# Recurse upwards until we can create a directory successfully