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):
3088
3101
class cmd_plugins(Command):
3102
"""List the installed plugins.
3104
This command displays the list of installed plugins including the
3105
path where each one is located and a short description of each.
3107
A plugin is an external component for Bazaar that extends the
3108
revision control system, by adding or replacing code in Bazaar.
3109
Plugins can do a variety of things, including overriding commands,
3110
adding new commands, providing additional network transports and
3111
customizing log output.
3113
See the Bazaar web site, http://bazaar-vcs.org, for further
3114
information on plugins including where to find them and how to
3115
install them. Instructions are also provided there on how to
3116
write new plugins using the Python programming language.
3091
3119
@display_command
3093
3121
import bzrlib.plugin
3596
3631
public_branch = stored_public_branch
3597
3632
elif stored_public_branch is None:
3598
3633
branch.set_public_branch(public_branch)
3599
if patch_type != "bundle" and public_branch is None:
3634
if not include_bundle and public_branch is None:
3600
3635
raise errors.BzrCommandError('No public branch specified or'
3637
base_revision_id = None
3602
3638
if revision is not None:
3603
if len(revision) != 1:
3639
if len(revision) > 2:
3604
3640
raise errors.BzrCommandError('bzr merge-directive takes '
3605
'exactly one revision identifier')
3607
revision_id = revision[0].in_history(branch).rev_id
3641
'at most two one revision identifiers')
3642
revision_id = revision[-1].in_history(branch).rev_id
3643
if len(revision) == 2:
3644
base_revision_id = revision[0].in_history(branch).rev_id
3645
base_revision_id = ensure_null(base_revision_id)
3609
3647
revision_id = branch.last_revision()
3610
3648
revision_id = ensure_null(revision_id)
3611
3649
if revision_id == NULL_REVISION:
3612
3650
raise errors.BzrCommandError('No revisions to bundle.')
3613
directive = merge_directive.MergeDirective.from_objects(
3651
directive = merge_directive.MergeDirective2.from_objects(
3614
3652
branch.repository, revision_id, time.time(),
3615
3653
osutils.local_time_offset(), submit_branch,
3616
public_branch=public_branch, patch_type=patch_type,
3654
public_branch=public_branch, include_patch=include_patch,
3655
include_bundle=include_bundle, message=message,
3656
base_revision_id=base_revision_id)
3618
3657
if mail_to is None:
3620
3659
self.outf.write(directive.to_signed(branch))
3626
3665
s.send_email(message)
3668
class cmd_submit(Command):
3669
"""Create a merge-directive for submiting changes.
3671
A merge directive provides many things needed for requesting merges:
3672
- A machine-readable description of the merge to perform
3673
- An optional patch that is a preview of the changes requested
3674
- An optional bundle of revision data, so that the changes can be applied
3675
directly from the merge directive, without retrieving data from a
3678
If --no-bundle is specified, then public_branch is needed (and must be
3679
up-to-date), so that the receiver can perform the merge using the
3680
public_branch. The public_branch is always included if known, so that
3681
people can check it later.
3683
The submit branch defaults to the parent, but can be overridden. Both
3684
submit branch and public branch will be remembered if supplied.
3686
If a public_branch is known for the submit_branch, that public submit
3687
branch is used in the merge instructions. This means that a local mirror
3688
can be used as your actual submit branch, once you have set public_branch
3692
encoding_type = 'exact'
3694
aliases = ['bundle', 'bundle-revisions']
3696
_see_also = ['merge']
3698
takes_args = ['submit_branch?', 'public_branch?']
3701
help='Do not include a bundle in the merge directive.'),
3702
Option('no-patch', help='Do not include a preview patch in the merge'
3705
help='Remember submit and public branch.'),
3707
help='Branch to generate the submission from, '
3708
'rather than the one containing the working directory.',
3711
Option('output', short_name='o', help='Write directive to this file.',
3716
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3717
no_patch=False, revision=None, remember=False, output=None,
3719
from bzrlib.revision import ensure_null, NULL_REVISION
3723
outfile = open(output, 'wb')
3725
from_ = kwargs.get('from', '.')
3726
branch = Branch.open_containing(from_)[0]
3727
if remember and submit_branch is None:
3728
raise errors.BzrCommandError(
3729
'--remember requires a branch to be specified.')
3730
stored_submit_branch = branch.get_submit_branch()
3731
remembered_submit_branch = False
3732
if submit_branch is None:
3733
submit_branch = stored_submit_branch
3734
remembered_submit_branch = True
3736
if stored_submit_branch is None or remember:
3737
branch.set_submit_branch(submit_branch)
3738
if submit_branch is None:
3739
submit_branch = branch.get_parent()
3740
remembered_submit_branch = True
3741
if submit_branch is None:
3742
raise errors.BzrCommandError('No submit branch known or'
3744
if remembered_submit_branch:
3745
note('Using saved location: %s', submit_branch)
3747
stored_public_branch = branch.get_public_branch()
3748
if public_branch is None:
3749
public_branch = stored_public_branch
3750
elif stored_public_branch is None or remember:
3751
branch.set_public_branch(public_branch)
3752
if no_bundle and public_branch is None:
3753
raise errors.BzrCommandError('No public branch specified or'
3755
base_revision_id = None
3756
if revision is not None:
3757
if len(revision) > 2:
3758
raise errors.BzrCommandError('bzr submit takes '
3759
'at most two one revision identifiers')
3760
revision_id = revision[-1].in_history(branch).rev_id
3761
if len(revision) == 2:
3762
base_revision_id = revision[0].in_history(branch).rev_id
3763
base_revision_id = ensure_null(base_revision_id)
3765
revision_id = branch.last_revision()
3766
revision_id = ensure_null(revision_id)
3767
if revision_id == NULL_REVISION:
3768
raise errors.BzrCommandError('No revisions to submit.')
3769
directive = merge_directive.MergeDirective2.from_objects(
3770
branch.repository, revision_id, time.time(),
3771
osutils.local_time_offset(), submit_branch,
3772
public_branch=public_branch, include_patch=not no_patch,
3773
include_bundle=not no_bundle, message=None,
3774
base_revision_id=base_revision_id)
3775
outfile.writelines(directive.to_lines())
3777
if output is not None:
3629
3780
class cmd_tag(Command):
3630
3781
"""Create a tag naming a revision.