2653
2657
other_transport = None
2654
2658
other_revision_id = None
2659
base_revision_id = None
2655
2660
possible_transports = []
2657
2662
if branch is not None:
2658
2663
mergeable, other_transport = _get_bundle_helper(branch)
2660
2665
if revision is not None:
2661
raise errors.BzrCommandError('Cannot use -r with merge'
2662
' directives or bundles')
2663
other_revision_id = mergeable.install_revisions(
2664
tree.branch.repository)
2665
revision = [RevisionSpec.from_string('revid:'
2666
+ other_revision_id)]
2666
raise errors.BzrCommandError(
2667
'Cannot use -r with merge directives or bundles')
2668
mergeable.install_revisions(tree.branch.repository)
2669
base_revision_id, other_revision_id, verified =\
2670
mergeable.get_merge_request(tree.branch.repository)
2671
if base_revision_id in tree.branch.repository.get_ancestry(
2672
tree.branch.last_revision(), topo_sorted=False):
2673
base_revision_id = None
2667
2678
possible_transports.append(other_transport)
2669
if revision is None \
2670
or len(revision) < 1 or revision[0].needs_branch():
2671
branch = self._get_remembered_parent(tree, branch, 'Merging from')
2680
if other_revision_id is None:
2681
verified = 'inapplicable'
2682
if revision is None \
2683
or len(revision) < 1 or revision[0].needs_branch():
2684
branch = self._get_remembered_parent(tree, branch,
2673
if revision is None or len(revision) < 1:
2676
other = [branch, None]
2687
if revision is None or len(revision) < 1:
2690
other = [branch, None]
2693
other = [branch, -1]
2694
other_branch, path = Branch.open_containing(branch,
2695
possible_transports)
2679
other = [branch, -1]
2680
other_branch, path = Branch.open_containing(branch,
2681
possible_transports)
2684
raise errors.BzrCommandError('Cannot use --uncommitted and'
2685
' --revision at the same time.')
2686
branch = revision[0].get_branch() or branch
2687
if len(revision) == 1:
2689
if other_revision_id is not None:
2690
# We merge from a bundle
2698
raise errors.BzrCommandError('Cannot use --uncommitted and'
2699
' --revision at the same time.')
2700
branch = revision[0].get_branch() or branch
2701
if len(revision) == 1:
2695
2703
other_branch, path = Branch.open_containing(
2696
2704
branch, possible_transports)
2697
2705
revno = revision[0].in_history(other_branch).revno
2698
2706
other = [branch, revno]
2700
assert len(revision) == 2
2701
if None in revision:
2702
raise errors.BzrCommandError(
2703
"Merge doesn't permit empty revision specifier.")
2704
base_branch, path = Branch.open_containing(branch,
2705
possible_transports)
2706
branch1 = revision[1].get_branch() or branch
2707
other_branch, path1 = Branch.open_containing(
2708
branch1, possible_transports)
2709
if revision[0].get_branch() is not None:
2710
# then path was obtained from it, and is None.
2708
assert len(revision) == 2
2709
if None in revision:
2710
raise errors.BzrCommandError(
2711
"Merge doesn't permit empty revision specifier.")
2712
base_branch, path = Branch.open_containing(
2713
branch, possible_transports)
2714
branch1 = revision[1].get_branch() or branch
2715
other_branch, path1 = Branch.open_containing(
2716
branch1, possible_transports)
2717
if revision[0].get_branch() is not None:
2718
# then path was obtained from it, and is None.
2713
base = [branch, revision[0].in_history(base_branch).revno]
2714
other = [branch1, revision[1].in_history(other_branch).revno]
2721
base = [branch, revision[0].in_history(base_branch).revno]
2723
revision[1].in_history(other_branch).revno]
2716
2725
# Remember where we merge from
2717
2726
if ((tree.branch.get_parent() is None or remember) and
2850
2861
restore(tree.abspath(filename))
2851
2862
except errors.NotConflicted:
2853
conflicts = _mod_merge.merge_inner(
2854
tree.branch, other_tree, base_tree,
2856
interesting_ids=interesting_ids,
2857
other_rev_id=parents[1],
2858
merge_type=merge_type,
2859
show_base=show_base,
2860
reprocess=reprocess)
2864
# Disable pending merges, because the file texts we are remerging
2865
# have not had those merges performed. If we use the wrong parents
2866
# list, we imply that the working tree text has seen and rejected
2867
# all the changes from the other tree, when in fact those changes
2868
# have not yet been seen.
2869
tree.set_parent_ids(parents[:1])
2871
conflicts = _mod_merge.merge_inner(
2872
tree.branch, other_tree, base_tree,
2874
interesting_ids=interesting_ids,
2875
other_rev_id=parents[1],
2876
merge_type=merge_type,
2877
show_base=show_base,
2878
reprocess=reprocess)
2880
tree.set_parent_ids(parents)
2863
2883
if conflicts > 0:
3098
3118
class cmd_plugins(Command):
3119
"""List the installed plugins.
3121
This command displays the list of installed plugins including the
3122
path where each one is located and a short description of each.
3124
A plugin is an external component for Bazaar that extends the
3125
revision control system, by adding or replacing code in Bazaar.
3126
Plugins can do a variety of things, including overriding commands,
3127
adding new commands, providing additional network transports and
3128
customizing log output.
3130
See the Bazaar web site, http://bazaar-vcs.org, for further
3131
information on plugins including where to find them and how to
3132
install them. Instructions are also provided there on how to
3133
write new plugins using the Python programming language.
3101
3136
@display_command
3103
3138
import bzrlib.plugin
3606
3648
public_branch = stored_public_branch
3607
3649
elif stored_public_branch is None:
3608
3650
branch.set_public_branch(public_branch)
3609
if patch_type != "bundle" and public_branch is None:
3651
if not include_bundle and public_branch is None:
3610
3652
raise errors.BzrCommandError('No public branch specified or'
3654
base_revision_id = None
3612
3655
if revision is not None:
3613
if len(revision) != 1:
3656
if len(revision) > 2:
3614
3657
raise errors.BzrCommandError('bzr merge-directive takes '
3615
'exactly one revision identifier')
3617
revision_id = revision[0].in_history(branch).rev_id
3658
'at most two one revision identifiers')
3659
revision_id = revision[-1].in_history(branch).rev_id
3660
if len(revision) == 2:
3661
base_revision_id = revision[0].in_history(branch).rev_id
3662
base_revision_id = ensure_null(base_revision_id)
3619
3664
revision_id = branch.last_revision()
3620
3665
revision_id = ensure_null(revision_id)
3621
3666
if revision_id == NULL_REVISION:
3622
3667
raise errors.BzrCommandError('No revisions to bundle.')
3623
directive = merge_directive.MergeDirective.from_objects(
3668
directive = merge_directive.MergeDirective2.from_objects(
3624
3669
branch.repository, revision_id, time.time(),
3625
3670
osutils.local_time_offset(), submit_branch,
3626
public_branch=public_branch, patch_type=patch_type,
3671
public_branch=public_branch, include_patch=include_patch,
3672
include_bundle=include_bundle, message=message,
3673
base_revision_id=base_revision_id)
3628
3674
if mail_to is None:
3630
3676
self.outf.write(directive.to_signed(branch))
3636
3682
s.send_email(message)
3685
class cmd_submit(Command):
3686
"""Create a merge-directive for submiting changes.
3688
A merge directive provides many things needed for requesting merges:
3689
- A machine-readable description of the merge to perform
3690
- An optional patch that is a preview of the changes requested
3691
- An optional bundle of revision data, so that the changes can be applied
3692
directly from the merge directive, without retrieving data from a
3695
If --no-bundle is specified, then public_branch is needed (and must be
3696
up-to-date), so that the receiver can perform the merge using the
3697
public_branch. The public_branch is always included if known, so that
3698
people can check it later.
3700
The submit branch defaults to the parent, but can be overridden. Both
3701
submit branch and public branch will be remembered if supplied.
3703
If a public_branch is known for the submit_branch, that public submit
3704
branch is used in the merge instructions. This means that a local mirror
3705
can be used as your actual submit branch, once you have set public_branch
3709
encoding_type = 'exact'
3711
aliases = ['bundle', 'bundle-revisions']
3713
_see_also = ['merge']
3715
takes_args = ['submit_branch?', 'public_branch?']
3718
help='Do not include a bundle in the merge directive.'),
3719
Option('no-patch', help='Do not include a preview patch in the merge'
3722
help='Remember submit and public branch.'),
3724
help='Branch to generate the submission from, '
3725
'rather than the one containing the working directory.',
3728
Option('output', short_name='o', help='Write directive to this file.',
3733
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3734
no_patch=False, revision=None, remember=False, output=None,
3736
from bzrlib.revision import ensure_null, NULL_REVISION
3740
outfile = open(output, 'wb')
3742
from_ = kwargs.get('from', '.')
3743
branch = Branch.open_containing(from_)[0]
3744
if remember and submit_branch is None:
3745
raise errors.BzrCommandError(
3746
'--remember requires a branch to be specified.')
3747
stored_submit_branch = branch.get_submit_branch()
3748
remembered_submit_branch = False
3749
if submit_branch is None:
3750
submit_branch = stored_submit_branch
3751
remembered_submit_branch = True
3753
if stored_submit_branch is None or remember:
3754
branch.set_submit_branch(submit_branch)
3755
if submit_branch is None:
3756
submit_branch = branch.get_parent()
3757
remembered_submit_branch = True
3758
if submit_branch is None:
3759
raise errors.BzrCommandError('No submit branch known or'
3761
if remembered_submit_branch:
3762
note('Using saved location: %s', submit_branch)
3764
stored_public_branch = branch.get_public_branch()
3765
if public_branch is None:
3766
public_branch = stored_public_branch
3767
elif stored_public_branch is None or remember:
3768
branch.set_public_branch(public_branch)
3769
if no_bundle and public_branch is None:
3770
raise errors.BzrCommandError('No public branch specified or'
3772
base_revision_id = None
3773
if revision is not None:
3774
if len(revision) > 2:
3775
raise errors.BzrCommandError('bzr submit takes '
3776
'at most two one revision identifiers')
3777
revision_id = revision[-1].in_history(branch).rev_id
3778
if len(revision) == 2:
3779
base_revision_id = revision[0].in_history(branch).rev_id
3780
base_revision_id = ensure_null(base_revision_id)
3782
revision_id = branch.last_revision()
3783
revision_id = ensure_null(revision_id)
3784
if revision_id == NULL_REVISION:
3785
raise errors.BzrCommandError('No revisions to submit.')
3786
directive = merge_directive.MergeDirective2.from_objects(
3787
branch.repository, revision_id, time.time(),
3788
osutils.local_time_offset(), submit_branch,
3789
public_branch=public_branch, include_patch=not no_patch,
3790
include_bundle=not no_bundle, message=None,
3791
base_revision_id=base_revision_id)
3792
outfile.writelines(directive.to_lines())
3794
if output is not None:
3639
3797
class cmd_tag(Command):
3640
3798
"""Create a tag naming a revision.