2663
2668
if revision is not None:
2664
2669
raise errors.BzrCommandError(
2665
2670
'Cannot use -r with merge directives or bundles')
2666
other_revision_id = mergeable.install_revisions(
2667
tree.branch.repository)
2668
revision = [RevisionSpec.from_string(
2669
'revid:' + other_revision_id)]
2671
if revision is None \
2672
or len(revision) < 1 or revision[0].needs_branch():
2673
branch = self._get_remembered_parent(tree, branch, 'Merging from')
2675
if revision is None or len(revision) < 1:
2678
other = [branch, None]
2671
mergeable.install_revisions(tree.branch.repository)
2672
base_revision_id, other_revision_id, verified =\
2673
mergeable.get_merge_request(tree.branch.repository)
2674
if base_revision_id in tree.branch.repository.get_ancestry(
2675
tree.branch.last_revision(), topo_sorted=False):
2676
base_revision_id = None
2682
if other_revision_id is None:
2683
verified = 'inapplicable'
2684
if revision is None \
2685
or len(revision) < 1 or revision[0].needs_branch():
2686
branch = self._get_remembered_parent(tree, branch,
2689
if revision is None or len(revision) < 1:
2692
other = [branch, None]
2695
other = [branch, -1]
2696
other_branch, path = Branch.open_containing(branch)
2681
other = [branch, -1]
2682
other_branch, path = Branch.open_containing(branch)
2685
raise errors.BzrCommandError('Cannot use --uncommitted and'
2686
' --revision at the same time.')
2687
branch = revision[0].get_branch() or branch
2688
if len(revision) == 1:
2690
if other_revision_id is not None:
2699
raise errors.BzrCommandError('Cannot use --uncommitted and'
2700
' --revision at the same time.')
2701
branch = revision[0].get_branch() or branch
2702
if len(revision) == 1:
2695
2704
other_branch, path = Branch.open_containing(branch)
2696
2705
revno = revision[0].in_history(other_branch).revno
2697
2706
other = [branch, revno]
2699
assert len(revision) == 2
2700
if None in revision:
2701
raise errors.BzrCommandError(
2702
"Merge doesn't permit empty revision specifier.")
2703
base_branch, path = Branch.open_containing(branch)
2704
branch1 = revision[1].get_branch() or branch
2705
other_branch, path1 = Branch.open_containing(branch1)
2706
if revision[0].get_branch() is not None:
2707
# 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(branch)
2713
branch1 = revision[1].get_branch() or branch
2714
other_branch, path1 = Branch.open_containing(branch1)
2715
if revision[0].get_branch() is not None:
2716
# then path was obtained from it, and is None.
2710
base = [branch, revision[0].in_history(base_branch).revno]
2711
other = [branch1, revision[1].in_history(other_branch).revno]
2719
base = [branch, revision[0].in_history(base_branch).revno]
2721
revision[1].in_history(other_branch).revno]
2713
2723
if ((tree.branch.get_parent() is None or remember) and
2714
2724
other_branch is not None):
2844
2857
restore(tree.abspath(filename))
2845
2858
except errors.NotConflicted:
2847
conflicts = _mod_merge.merge_inner(
2848
tree.branch, other_tree, base_tree,
2850
interesting_ids=interesting_ids,
2851
other_rev_id=parents[1],
2852
merge_type=merge_type,
2853
show_base=show_base,
2854
reprocess=reprocess)
2860
# Disable pending merges, because the file texts we are remerging
2861
# have not had those merges performed. If we use the wrong parents
2862
# list, we imply that the working tree text has seen and rejected
2863
# all the changes from the other tree, when in fact those changes
2864
# have not yet been seen.
2865
tree.set_parent_ids(parents[:1])
2867
conflicts = _mod_merge.merge_inner(
2868
tree.branch, other_tree, base_tree,
2870
interesting_ids=interesting_ids,
2871
other_rev_id=parents[1],
2872
merge_type=merge_type,
2873
show_base=show_base,
2874
reprocess=reprocess)
2876
tree.set_parent_ids(parents)
2857
2879
if conflicts > 0:
3088
3110
class cmd_plugins(Command):
3111
"""List the installed plugins.
3113
This command displays the list of installed plugins including the
3114
path where each one is located and a short description of each.
3116
A plugin is an external component for Bazaar that extends the
3117
revision control system, by adding or replacing code in Bazaar.
3118
Plugins can do a variety of things, including overriding commands,
3119
adding new commands, providing additional network transports and
3120
customizing log output.
3122
See the Bazaar web site, http://bazaar-vcs.org, for further
3123
information on plugins including where to find them and how to
3124
install them. Instructions are also provided there on how to
3125
write new plugins using the Python programming language.
3091
3128
@display_command
3093
3130
import bzrlib.plugin
3596
3640
public_branch = stored_public_branch
3597
3641
elif stored_public_branch is None:
3598
3642
branch.set_public_branch(public_branch)
3599
if patch_type != "bundle" and public_branch is None:
3643
if not include_bundle and public_branch is None:
3600
3644
raise errors.BzrCommandError('No public branch specified or'
3646
base_revision_id = None
3602
3647
if revision is not None:
3603
if len(revision) != 1:
3648
if len(revision) > 2:
3604
3649
raise errors.BzrCommandError('bzr merge-directive takes '
3605
'exactly one revision identifier')
3607
revision_id = revision[0].in_history(branch).rev_id
3650
'at most two one revision identifiers')
3651
revision_id = revision[-1].in_history(branch).rev_id
3652
if len(revision) == 2:
3653
base_revision_id = revision[0].in_history(branch).rev_id
3654
base_revision_id = ensure_null(base_revision_id)
3609
3656
revision_id = branch.last_revision()
3610
3657
revision_id = ensure_null(revision_id)
3611
3658
if revision_id == NULL_REVISION:
3612
3659
raise errors.BzrCommandError('No revisions to bundle.')
3613
directive = merge_directive.MergeDirective.from_objects(
3660
directive = merge_directive.MergeDirective2.from_objects(
3614
3661
branch.repository, revision_id, time.time(),
3615
3662
osutils.local_time_offset(), submit_branch,
3616
public_branch=public_branch, patch_type=patch_type,
3663
public_branch=public_branch, include_patch=include_patch,
3664
include_bundle=include_bundle, message=message,
3665
base_revision_id=base_revision_id)
3618
3666
if mail_to is None:
3620
3668
self.outf.write(directive.to_signed(branch))
3626
3674
s.send_email(message)
3677
class cmd_submit(Command):
3678
"""Create a merge-directive for submiting changes.
3680
A merge directive provides many things needed for requesting merges:
3681
- A machine-readable description of the merge to perform
3682
- An optional patch that is a preview of the changes requested
3683
- An optional bundle of revision data, so that the changes can be applied
3684
directly from the merge directive, without retrieving data from a
3687
If --no-bundle is specified, then public_branch is needed (and must be
3688
up-to-date), so that the receiver can perform the merge using the
3689
public_branch. The public_branch is always included if known, so that
3690
people can check it later.
3692
The submit branch defaults to the parent, but can be overridden. Both
3693
submit branch and public branch will be remembered if supplied.
3695
If a public_branch is known for the submit_branch, that public submit
3696
branch is used in the merge instructions. This means that a local mirror
3697
can be used as your actual submit branch, once you have set public_branch
3701
encoding_type = 'exact'
3703
aliases = ['bundle', 'bundle-revisions']
3705
_see_also = ['merge']
3707
takes_args = ['submit_branch?', 'public_branch?']
3710
help='Do not include a bundle in the merge directive.'),
3711
Option('no-patch', help='Do not include a preview patch in the merge'
3714
help='Remember submit and public branch.'),
3716
help='Branch to generate the submission from, '
3717
'rather than the one containing the working directory.',
3720
Option('output', short_name='o', help='Write directive to this file.',
3725
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3726
no_patch=False, revision=None, remember=False, output=None,
3728
from bzrlib.revision import ensure_null, NULL_REVISION
3732
outfile = open(output, 'wb')
3734
from_ = kwargs.get('from', '.')
3735
branch = Branch.open_containing(from_)[0]
3736
if remember and submit_branch is None:
3737
raise errors.BzrCommandError(
3738
'--remember requires a branch to be specified.')
3739
stored_submit_branch = branch.get_submit_branch()
3740
remembered_submit_branch = False
3741
if submit_branch is None:
3742
submit_branch = stored_submit_branch
3743
remembered_submit_branch = True
3745
if stored_submit_branch is None or remember:
3746
branch.set_submit_branch(submit_branch)
3747
if submit_branch is None:
3748
submit_branch = branch.get_parent()
3749
remembered_submit_branch = True
3750
if submit_branch is None:
3751
raise errors.BzrCommandError('No submit branch known or'
3753
if remembered_submit_branch:
3754
note('Using saved location: %s', submit_branch)
3756
stored_public_branch = branch.get_public_branch()
3757
if public_branch is None:
3758
public_branch = stored_public_branch
3759
elif stored_public_branch is None or remember:
3760
branch.set_public_branch(public_branch)
3761
if no_bundle and public_branch is None:
3762
raise errors.BzrCommandError('No public branch specified or'
3764
base_revision_id = None
3765
if revision is not None:
3766
if len(revision) > 2:
3767
raise errors.BzrCommandError('bzr submit takes '
3768
'at most two one revision identifiers')
3769
revision_id = revision[-1].in_history(branch).rev_id
3770
if len(revision) == 2:
3771
base_revision_id = revision[0].in_history(branch).rev_id
3772
base_revision_id = ensure_null(base_revision_id)
3774
revision_id = branch.last_revision()
3775
revision_id = ensure_null(revision_id)
3776
if revision_id == NULL_REVISION:
3777
raise errors.BzrCommandError('No revisions to submit.')
3778
directive = merge_directive.MergeDirective2.from_objects(
3779
branch.repository, revision_id, time.time(),
3780
osutils.local_time_offset(), submit_branch,
3781
public_branch=public_branch, include_patch=not no_patch,
3782
include_bundle=not no_bundle, message=None,
3783
base_revision_id=base_revision_id)
3784
outfile.writelines(directive.to_lines())
3786
if output is not None:
3629
3789
class cmd_tag(Command):
3630
3790
"""Create a tag naming a revision.