65
67
You can apply it to another tree using 'bzr merge'.
67
69
bzr bundle-revisions
68
- Bundle for the last commit
70
- Generate a bundle relative to a remembered location
69
71
bzr bundle-revisions BASE
70
72
- Bundle to apply the current tree into BASE
71
73
bzr bundle-revisions --revision A
72
- Bundle for revision A
74
- Bundle to apply revision A to remembered location
73
75
bzr bundle-revisions --revision A..B
74
76
- Bundle to transform A into B
75
bzr bundle-revisions --revision A..B BASE
76
- Bundle to transform revision A of BASE into revision B
79
takes_options = ['verbose', 'revision',
78
takes_options = ['verbose', 'revision', 'remember',
80
79
Option("output", help="write bundle to specified file",
82
81
takes_args = ['base?']
83
82
aliases = ['bundle']
85
def run(self, base=None, revision=None, output=None):
84
def run(self, base=None, revision=None, output=None, remember=False):
86
85
from bzrlib import user_encoding
87
86
from bzrlib.bundle.serializer import write_bundle
88
target_branch = Branch.open_containing(u'.')[0]
91
base_specified = False
92
base_branch = Branch.open(base)
94
# We don't want to lock the same branch across
95
# 2 different branches
96
target_branch = Branch.open_containing(u'.')[0]
97
if base_branch is not None and target_branch.base == base_branch.base:
101
95
if revision is None:
102
96
target_revision = target_branch.last_revision()
103
elif len(revision) == 1:
104
target_revision = revision[0].in_history(target_branch).rev_id
105
if base_branch is not None:
106
base_revision = base_branch.last_revision()
107
elif len(revision) == 2:
108
target_revision = revision[1].in_history(target_branch).rev_id
109
if base_branch is not None:
110
base_revision = revision[0].in_history(base_branch).rev_id
97
elif len(revision) < 3:
98
target_revision = revision[-1].in_history(target_branch).rev_id
99
if len(revision) == 2:
101
raise errors.BzrCommandError('Cannot specify base as well'
102
' as two revision arguments.')
112
103
base_revision = revision[0].in_history(target_branch).rev_id
114
105
raise errors.BzrCommandError('--revision takes 1 or 2 parameters')
116
if revision is None or len(revision) == 1:
117
if base_branch is not None:
118
target_branch.repository.fetch(base_branch.repository,
119
base_branch.last_revision())
120
base_revision = common_ancestor(base_branch.last_revision(),
122
target_branch.repository)
123
if base_revision is None:
124
base_revision = NULL_REVISION
126
if base_revision is None:
127
rev = target_branch.repository.get_revision(target_revision)
129
base_revision = rev.parent_ids[0]
131
base_revision = NULL_REVISION
133
if base_branch is not None:
107
if revision is None or len(revision) < 2:
108
submit_branch = target_branch.get_submit_branch()
112
base = target_branch.get_parent()
114
raise errors.BzrCommandError("No base branch known or"
116
elif not base_specified:
118
# note() doesn't pay attention to terminal_encoding() so
119
# we must format with 'ascii' to be safe
120
note('Using saved location: %s',
121
urlutils.unescape_for_display(base, 'ascii'))
122
base_branch = Branch.open(base)
124
# We don't want to lock the same branch across
125
# 2 different branches
126
if target_branch.base == base_branch.base:
127
base_branch = target_branch
128
if submit_branch is None or remember:
130
target_branch.set_submit_branch(base_branch.base)
132
raise errors.BzrCommandError('--remember requires a branch'
134
134
target_branch.repository.fetch(base_branch.repository,
135
revision_id=base_revision)
135
base_branch.last_revision())
136
base_revision = common_ancestor(base_branch.last_revision(),
138
target_branch.repository)
138
141
if output is not None:
139
142
fileobj = file(output, 'wb')