66
66
You can apply it to another tree using 'bzr merge'.
68
68
bzr bundle-revisions
69
- Bundle for the last commit
69
- Generate a bundle relative to a remembered location
70
70
bzr bundle-revisions BASE
71
71
- Bundle to apply the current tree into BASE
72
72
bzr bundle-revisions --revision A
73
- Bundle for revision A
73
- Bundle to apply revision A to remembered location
74
74
bzr bundle-revisions --revision A..B
75
75
- Bundle to transform A into B
76
bzr bundle-revisions --revision A..B BASE
77
- Bundle to transform revision A of BASE into revision B
80
77
takes_options = ['verbose', 'revision', 'remember',
81
78
Option("output", help="write bundle to specified file",
88
85
from bzrlib.bundle.serializer import write_bundle
90
87
target_branch = Branch.open_containing(u'.')[0]
91
submit_branch = target_branch.get_submit_branch()
94
90
base_specified = False
97
92
base_specified = True
100
base = target_branch.get_parent()
102
raise errors.BzrCommandError("No base branch known or"
104
elif not base_specified:
105
note('Using saved location: %s' % base)
106
base_branch = Branch.open(base)
108
# We don't want to lock the same branch across
109
# 2 different branches
110
if target_branch.base == base_branch.base:
111
base_branch = target_branch
112
if submit_branch is None or remember:
114
target_branch.set_submit_branch(base_branch.base)
116
raise errors.BzrCommandError('--remember requires a branch to'
120
94
if revision is None:
121
95
target_revision = target_branch.last_revision()
122
elif len(revision) == 1:
123
target_revision = revision[0].in_history(target_branch).rev_id
124
if base_branch is not None:
125
base_revision = base_branch.last_revision()
126
elif len(revision) == 2:
127
target_revision = revision[1].in_history(target_branch).rev_id
128
if base_branch is not None:
129
base_revision = revision[0].in_history(base_branch).rev_id
96
elif len(revision) < 3:
97
target_revision = revision[-1].in_history(target_branch).rev_id
98
if len(revision) == 2:
100
raise errors.BzrCommandError('Cannot specify base as well'
101
' as two revision arguments.')
131
102
base_revision = revision[0].in_history(target_branch).rev_id
133
104
raise errors.BzrCommandError('--revision takes 1 or 2 parameters')
135
if revision is None or len(revision) == 1:
136
if base_branch is not None:
137
target_branch.repository.fetch(base_branch.repository,
138
base_branch.last_revision())
139
base_revision = common_ancestor(base_branch.last_revision(),
141
target_branch.repository)
142
if base_revision is None:
143
base_revision = NULL_REVISION
145
if base_revision is None:
146
rev = target_branch.repository.get_revision(target_revision)
148
base_revision = rev.parent_ids[0]
150
base_revision = NULL_REVISION
152
if base_branch is not None:
106
if revision is None or len(revision) < 2:
107
submit_branch = target_branch.get_submit_branch()
111
base = target_branch.get_parent()
113
raise errors.BzrCommandError("No base branch known or"
115
elif not base_specified:
116
note('Using saved location: %s' % base)
117
base_branch = Branch.open(base)
119
# We don't want to lock the same branch across
120
# 2 different branches
121
if target_branch.base == base_branch.base:
122
base_branch = target_branch
123
if submit_branch is None or remember:
125
target_branch.set_submit_branch(base_branch.base)
127
raise errors.BzrCommandError('--remember requires a branch'
153
129
target_branch.repository.fetch(base_branch.repository,
154
revision_id=base_revision)
130
base_branch.last_revision())
131
base_revision = common_ancestor(base_branch.last_revision(),
133
target_branch.repository)
157
136
if output is not None:
158
137
fileobj = file(output, 'wb')