bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.436.25
by Jelmer Vernooij
Add setup.py. |
1 |
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
|
0.436.81
by Jelmer Vernooij
Change license to GPLv3+ |
5 |
# the Free Software Foundation; either version 3 of the License, or
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
6 |
# (at your option) any later version.
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
0.436.25
by Jelmer Vernooij
Add setup.py. |
16 |
"""Rebase support.
|
17 |
||
18 |
The Bazaar rebase plugin adds support for rebasing branches to Bazaar.
|
|
19 |
It adds the command 'rebase' to Bazaar. When conflicts occur when replaying
|
|
20 |
patches, the user can resolve the conflict and continue the rebase using the
|
|
21 |
'rebase-continue' command or abort using the 'rebase-abort' command.
|
|
22 |
"""
|
|
|
0.436.1
by Jelmer Vernooij
Add framework for git-rebase plugin. |
23 |
|
|
0.436.4
by Jelmer Vernooij
Add some tests. |
24 |
from bzrlib.commands import Command, Option, display_command, register_command |
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
25 |
from bzrlib.errors import (BzrCommandError, ConflictsInTree, NoSuchFile, |
|
0.436.58
by Jelmer Vernooij
Raise exception about pending changes /before/ writing plan. |
26 |
UnrelatedBranches, NoSuchRevision, |
27 |
UncommittedChanges) |
|
|
0.436.49
by Jelmer Vernooij
Fix locking. |
28 |
from bzrlib.trace import info, warning |
|
0.436.1
by Jelmer Vernooij
Add framework for git-rebase plugin. |
29 |
|
|
0.436.70
by Jelmer Vernooij
Release 0.3. |
30 |
version_info = (0, 3, 0, 'final', 0) |
|
0.436.49
by Jelmer Vernooij
Fix locking. |
31 |
if version_info[3] == 'final': |
32 |
version_string = '%d.%d.%d' % version_info[:3] |
|
33 |
else: |
|
34 |
version_string = '%d.%d.%d%s%d' % version_info |
|
35 |
__version__ = version_string |
|
|
0.436.25
by Jelmer Vernooij
Add setup.py. |
36 |
__author__ = 'Jelmer Vernooij <jelmer@samba.org>' |
37 |
||
|
0.436.49
by Jelmer Vernooij
Fix locking. |
38 |
min_compatible_bzr_version = (0, 92) |
39 |
||
40 |
def check_bzrlib_version(desired): |
|
41 |
"""Check that bzrlib is compatible. |
|
42 |
||
|
0.436.74
by Jelmer Vernooij
Add pydoctor file, more docstrings. |
43 |
:param desired: Desired version.
|
44 |
||
|
0.436.49
by Jelmer Vernooij
Fix locking. |
45 |
If version is < all compatible version, assume incompatible.
|
46 |
"""
|
|
47 |
import bzrlib |
|
48 |
bzrlib_version = bzrlib.version_info[:2] |
|
49 |
if bzrlib.version_info[3] == 'dev': |
|
50 |
return
|
|
51 |
if bzrlib_version < desired: |
|
52 |
warning('Installed bzr version %s is too old to be used with bzr-rebase' |
|
53 |
' %s.' % (bzrlib.__version__, __version__)) |
|
54 |
# Not using BzrNewError, because it may not exist.
|
|
55 |
raise Exception, ('Version mismatch', desired) |
|
56 |
||
57 |
||
58 |
check_bzrlib_version(min_compatible_bzr_version) |
|
59 |
||
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
60 |
def find_last_common_revid(revhistory1, revhistory2): |
|
0.436.74
by Jelmer Vernooij
Add pydoctor file, more docstrings. |
61 |
"""Find the last revision two revision histories have in common. |
62 |
||
63 |
:param revhistory1: First revision history (list of revids)
|
|
64 |
:param revhistory2: First revision history (list of revids)
|
|
65 |
:return: The last common revision id
|
|
66 |
"""
|
|
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
67 |
for revid in reversed(revhistory1): |
68 |
if revid in revhistory2: |
|
69 |
return revid |
|
70 |
||
71 |
raise UnrelatedBranches() |
|
72 |
||
73 |
||
|
0.436.1
by Jelmer Vernooij
Add framework for git-rebase plugin. |
74 |
class cmd_rebase(Command): |
75 |
"""Re-base a branch. |
|
76 |
||
|
0.437.5
by James Westby
Add some help text to the rebase command. |
77 |
Rebasing is the process of taking a branch and modifying the history so
|
78 |
that it appears to start from a different point. This can be useful
|
|
79 |
to clean up the history before submitting your changes. The tree at the
|
|
80 |
end of the process will be the same as if you had merged the other branch,
|
|
81 |
but the history will be different.
|
|
82 |
||
83 |
The command takes the location of another branch on to which the branch in
|
|
84 |
the current working directory will be rebased. If a branch is not specified
|
|
85 |
then the parent branch is used, and this is usually the desired result.
|
|
86 |
||
87 |
The first step identifies the revisions that are in the current branch that
|
|
88 |
are not in the parent branch. The current branch is then set to be at the
|
|
89 |
same revision as the target branch, and each revision is replayed on top
|
|
90 |
of the branch. At the end of the process it will appear as though your
|
|
91 |
current branch was branched off the current last revision of the target.
|
|
92 |
||
93 |
Each revision that is replayed may cause conflicts in the tree. If this
|
|
94 |
happens the command will stop and allow you to fix them up. Resolve the
|
|
95 |
commits as you would for a merge, and then run 'bzr resolve' to marked
|
|
96 |
them as resolved. Once you have resolved all the conflicts you should
|
|
97 |
run 'bzr rebase-continue' to continue the rebase operation.
|
|
98 |
||
99 |
If conflicts are encountered and you decide that you do not wish to continue
|
|
100 |
you can run 'bzr rebase-abort'.
|
|
101 |
||
102 |
The '--onto' option allows you to specify a different revision in the
|
|
103 |
target branch to start at when replaying the revisions. This means that
|
|
104 |
you can change the point at which the current branch will appear to be
|
|
105 |
branched from when the operation completes.
|
|
|
0.436.1
by Jelmer Vernooij
Add framework for git-rebase plugin. |
106 |
"""
|
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
107 |
takes_args = ['upstream_location?'] |
|
0.436.19
by Jelmer Vernooij
- Add blackbox tests |
108 |
takes_options = ['revision', 'merge-type', 'verbose', |
|
0.436.29
by Jelmer Vernooij
Add --dry-run option to rebase command. |
109 |
Option('dry-run', |
|
0.436.57
by Jelmer Vernooij
Allow overridding whether merges of already merged revisions should be replayed. |
110 |
help="Show what would be done, but don't actually do anything."), |
111 |
Option('always-rebase-merges', |
|
112 |
help="Don't skip revisions that merge already present revisions."), |
|
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
113 |
Option('pending-merges', |
114 |
help="Rebase pending merges onto local branch"), |
|
|
0.436.29
by Jelmer Vernooij
Add --dry-run option to rebase command. |
115 |
Option('onto', help='Different revision to replay onto.', |
|
0.436.57
by Jelmer Vernooij
Allow overridding whether merges of already merged revisions should be replayed. |
116 |
type=str)] |
|
0.436.1
by Jelmer Vernooij
Add framework for git-rebase plugin. |
117 |
|
118 |
@display_command
|
|
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
119 |
def run(self, upstream_location=None, onto=None, revision=None, |
|
0.436.57
by Jelmer Vernooij
Allow overridding whether merges of already merged revisions should be replayed. |
120 |
merge_type=None, verbose=False, dry_run=False, |
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
121 |
always_rebase_merges=False, pending_merges=False): |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
122 |
from bzrlib.branch import Branch |
123 |
from bzrlib.revisionspec import RevisionSpec |
|
124 |
from bzrlib.workingtree import WorkingTree |
|
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
125 |
from rebase import (generate_simple_plan, rebase, rebase_plan_exists, |
126 |
read_rebase_plan, remove_rebase_plan, |
|
|
0.437.4
by James Westby
Import rebase_todo as it is needed for --verbose. |
127 |
workingtree_replay, write_rebase_plan, |
|
0.436.39
by Jelmer Vernooij
Some more refactoring, add test that demonstrates #126743. |
128 |
regenerate_default_revid, |
|
0.437.4
by James Westby
Import rebase_todo as it is needed for --verbose. |
129 |
rebase_todo) |
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
130 |
if revision is not None and pending_merges: |
131 |
raise BzrCommandError("--revision and --pending-merges are mutually exclusive") |
|
132 |
||
|
0.436.66
by Jelmer Vernooij
Don't require use of the rebase command in root of the branch. |
133 |
wt = WorkingTree.open_containing(".")[0] |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
134 |
wt.lock_write() |
135 |
if upstream_location is None: |
|
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
136 |
if pending_merges: |
137 |
upstream_location = "." |
|
138 |
else: |
|
139 |
upstream_location = wt.branch.get_push_location() |
|
140 |
if upstream_location is None: |
|
141 |
upstream_location = wt.branch.get_parent() |
|
142 |
info("Rebasing on %s" % upstream_location) |
|
|
0.436.65
by Jelmer Vernooij
Don't require running in the branch root. |
143 |
upstream = Branch.open_containing(upstream_location)[0] |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
144 |
upstream_repository = upstream.repository |
145 |
upstream_revision = upstream.last_revision() |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
146 |
try: |
147 |
# Abort if there already is a plan file
|
|
148 |
if rebase_plan_exists(wt): |
|
149 |
raise BzrCommandError("A rebase operation was interrupted. Continue using 'bzr rebase-continue' or abort using 'bzr rebase-abort'") |
|
150 |
||
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
151 |
start_revid = None |
152 |
stop_revid = None |
|
153 |
if revision is not None: |
|
154 |
if len(revision) == 1: |
|
155 |
if revision[0] is not None: |
|
|
0.436.85
by Jelmer Vernooij
use cheaper as_revision_id. |
156 |
stop_revid = revision[0].as_revision_id(wt.branch) |
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
157 |
elif len(revision) == 2: |
158 |
if revision[0] is not None: |
|
|
0.436.85
by Jelmer Vernooij
use cheaper as_revision_id. |
159 |
start_revid = revision[0].as_revision_id(wt.branch) |
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
160 |
if revision[1] is not None: |
|
0.436.85
by Jelmer Vernooij
use cheaper as_revision_id. |
161 |
stop_revid = revision[1].as_revision_id(wt.branch) |
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
162 |
else: |
163 |
raise BzrCommandError( |
|
164 |
"--revision takes only one or two arguments") |
|
165 |
||
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
166 |
if pending_merges: |
167 |
wt_parents = wt.get_parent_ids() |
|
168 |
if len(wt_parents) in (0, 1): |
|
169 |
raise BzrCommandError("No pending merges present.") |
|
170 |
elif len(wt_parents) > 2: |
|
171 |
raise BzrCommandError("Rebasing more than one pending merge not supported") |
|
172 |
stop_revid = wt_parents[1] |
|
173 |
assert stop_revid is not None, "stop revid invalid" |
|
174 |
||
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
175 |
# Pull required revisions
|
|
0.436.29
by Jelmer Vernooij
Add --dry-run option to rebase command. |
176 |
wt.branch.repository.fetch(upstream_repository, upstream_revision) |
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
177 |
if onto is None: |
178 |
onto = upstream.last_revision() |
|
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
179 |
else: |
|
0.437.2
by James Westby
Lookup the onto revision in the upstream branch. |
180 |
rev_spec = RevisionSpec.from_string(onto) |
|
0.436.85
by Jelmer Vernooij
use cheaper as_revision_id. |
181 |
onto = rev_spec.as_revision_id(upstream) |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
182 |
|
183 |
wt.branch.repository.fetch(upstream_repository, onto) |
|
184 |
||
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
185 |
if stop_revid is not None: |
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
186 |
revhistory = list(wt.branch.repository.iter_reverse_revision_history(stop_revid)) |
187 |
revhistory.reverse() |
|
188 |
else: |
|
189 |
revhistory = wt.branch.revision_history() |
|
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
190 |
|
191 |
if start_revid is None: |
|
192 |
common_revid = find_last_common_revid(revhistory, |
|
193 |
upstream.revision_history()) |
|
194 |
if common_revid == upstream.last_revision(): |
|
|
0.436.75
by Jelmer Vernooij
Fix missing newline character. |
195 |
self.outf.write("No revisions to rebase.\n") |
|
0.436.67
by Jelmer Vernooij
Inform user about already being rebased rather than erroring. |
196 |
return
|
|
0.436.51
by Jelmer Vernooij
Give proper warning when there is no common base. |
197 |
try: |
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
198 |
start_revid = revhistory[revhistory.index(common_revid)+1] |
|
0.436.51
by Jelmer Vernooij
Give proper warning when there is no common base. |
199 |
except NoSuchRevision: |
200 |
raise BzrCommandError("No common revision, please specify --revision") |
|
|
0.436.12
by Jelmer Vernooij
Give sane error when branch is already rebased. |
201 |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
202 |
# Create plan
|
|
0.436.4
by Jelmer Vernooij
Add some tests. |
203 |
replace_map = generate_simple_plan( |
|
0.436.43
by Jelmer Vernooij
Factor out common revid code - maybe some of this can use aaron's common ancestor code instead? |
204 |
revhistory, start_revid, stop_revid, onto, |
|
0.438.1
by Jelmer Vernooij
Split out function for determining rebase base. |
205 |
wt.branch.repository.get_ancestry(onto), |
|
0.436.39
by Jelmer Vernooij
Some more refactoring, add test that demonstrates #126743. |
206 |
wt.branch.repository.revision_parents, |
|
0.436.57
by Jelmer Vernooij
Allow overridding whether merges of already merged revisions should be replayed. |
207 |
lambda revid: regenerate_default_revid(wt.branch.repository, revid), |
208 |
not always_rebase_merges |
|
|
0.436.39
by Jelmer Vernooij
Some more refactoring, add test that demonstrates #126743. |
209 |
)
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
210 |
|
|
0.436.19
by Jelmer Vernooij
- Add blackbox tests |
211 |
if verbose: |
|
0.436.29
by Jelmer Vernooij
Add --dry-run option to rebase command. |
212 |
todo = list(rebase_todo(wt.branch.repository, replace_map)) |
213 |
info('%d revisions will be rebased:' % len(todo)) |
|
214 |
for revid in todo: |
|
215 |
info("%s" % revid) |
|
216 |
||
|
0.436.58
by Jelmer Vernooij
Raise exception about pending changes /before/ writing plan. |
217 |
# Check for changes in the working tree.
|
|
0.436.84
by Jelmer Vernooij
Support rebasing pending merges. |
218 |
if (not pending_merges and |
219 |
wt.basis_tree().changes_from(wt).has_changed()): |
|
|
0.436.58
by Jelmer Vernooij
Raise exception about pending changes /before/ writing plan. |
220 |
raise UncommittedChanges(wt) |
221 |
||
|
0.436.29
by Jelmer Vernooij
Add --dry-run option to rebase command. |
222 |
if not dry_run: |
223 |
# Write plan file
|
|
224 |
write_rebase_plan(wt, replace_map) |
|
225 |
||
226 |
# Start executing plan
|
|
227 |
try: |
|
228 |
rebase(wt.branch.repository, replace_map, |
|
229 |
workingtree_replay(wt, merge_type=merge_type)) |
|
230 |
except ConflictsInTree: |
|
231 |
raise BzrCommandError("A conflict occurred replaying a commit. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.") |
|
232 |
# Remove plan file
|
|
233 |
remove_rebase_plan(wt) |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
234 |
finally: |
235 |
wt.unlock() |
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
236 |
|
|
0.436.12
by Jelmer Vernooij
Give sane error when branch is already rebased. |
237 |
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
238 |
class cmd_rebase_abort(Command): |
239 |
"""Abort an interrupted rebase |
|
240 |
||
241 |
"""
|
|
242 |
||
243 |
@display_command
|
|
244 |
def run(self): |
|
|
0.436.10
by Jelmer Vernooij
Add more agressive version of revert. |
245 |
from rebase import read_rebase_plan, remove_rebase_plan, complete_revert |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
246 |
from bzrlib.workingtree import WorkingTree |
|
0.439.1
by Jelmer Vernooij
Allow use in non-root directories for rebase-continue, rebase-todo and rebase-abort. |
247 |
wt = WorkingTree.open_containing('.')[0] |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
248 |
wt.lock_write() |
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
249 |
try: |
250 |
# Read plan file and set last revision
|
|
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
251 |
try: |
252 |
last_rev_info = read_rebase_plan(wt)[0] |
|
253 |
except NoSuchFile: |
|
254 |
raise BzrCommandError("No rebase to abort") |
|
|
0.436.10
by Jelmer Vernooij
Add more agressive version of revert. |
255 |
complete_revert(wt, [last_rev_info[1]]) |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
256 |
remove_rebase_plan(wt) |
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
257 |
finally: |
258 |
wt.unlock() |
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
259 |
|
260 |
||
261 |
class cmd_rebase_continue(Command): |
|
262 |
"""Continue an interrupted rebase after resolving conflicts |
|
263 |
||
264 |
"""
|
|
|
0.436.13
by Jelmer Vernooij
Add progress bar, some optimizations. Make merge type configurable. |
265 |
takes_options = ['merge-type'] |
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
266 |
|
267 |
@display_command
|
|
|
0.436.13
by Jelmer Vernooij
Add progress bar, some optimizations. Make merge type configurable. |
268 |
def run(self, merge_type=None): |
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
269 |
from rebase import (commit_rebase, rebase, rebase_plan_exists, |
270 |
read_rebase_plan, read_active_rebase_revid, |
|
271 |
remove_rebase_plan, workingtree_replay) |
|
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
272 |
from bzrlib.workingtree import WorkingTree |
|
0.439.1
by Jelmer Vernooij
Allow use in non-root directories for rebase-continue, rebase-todo and rebase-abort. |
273 |
wt = WorkingTree.open_containing('.')[0] |
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
274 |
wt.lock_write() |
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
275 |
try: |
276 |
# Abort if there are any conflicts
|
|
277 |
if len(wt.conflicts()) != 0: |
|
|
0.437.3
by James Westby
Provide a hint in the conflicts present message to rebase-continue. |
278 |
raise BzrCommandError("There are still conflicts present. " |
279 |
"Resolve the conflicts and then run "
|
|
280 |
"'bzr resolve' and try again.") |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
281 |
# Read plan file
|
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
282 |
try: |
283 |
replace_map = read_rebase_plan(wt)[1] |
|
284 |
except NoSuchFile: |
|
285 |
raise BzrCommandError("No rebase to continue") |
|
286 |
oldrevid = read_active_rebase_revid(wt) |
|
287 |
if oldrevid is not None: |
|
288 |
oldrev = wt.branch.repository.get_revision(oldrevid) |
|
289 |
commit_rebase(wt, oldrev, replace_map[oldrevid][0]) |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
290 |
try: |
291 |
# Start executing plan from current Branch.last_revision()
|
|
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
292 |
rebase(wt.branch.repository, replace_map, |
293 |
workingtree_replay(wt, merge_type=merge_type)) |
|
|
0.436.8
by Jelmer Vernooij
Couple more minor fixes. |
294 |
except ConflictsInTree: |
295 |
raise BzrCommandError("A conflict occurred replaying a commit. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.") |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
296 |
# Remove plan file
|
297 |
remove_rebase_plan(wt) |
|
298 |
finally: |
|
299 |
wt.unlock() |
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
300 |
|
301 |
||
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
302 |
class cmd_rebase_todo(Command): |
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
303 |
"""Print list of revisions that still need to be replayed as part of the |
304 |
current rebase operation.
|
|
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
305 |
|
306 |
"""
|
|
307 |
||
308 |
def run(self): |
|
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
309 |
from rebase import (rebase_todo, read_rebase_plan, |
310 |
read_active_rebase_revid) |
|
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
311 |
from bzrlib.workingtree import WorkingTree |
|
0.439.1
by Jelmer Vernooij
Allow use in non-root directories for rebase-continue, rebase-todo and rebase-abort. |
312 |
wt = WorkingTree.open_containing('.')[0] |
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
313 |
wt.lock_read() |
314 |
try: |
|
315 |
try: |
|
316 |
replace_map = read_rebase_plan(wt)[1] |
|
317 |
except NoSuchFile: |
|
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
318 |
raise BzrCommandError("No rebase in progress") |
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
319 |
currentrevid = read_active_rebase_revid(wt) |
320 |
if currentrevid is not None: |
|
321 |
info("Currently replaying: %s" % currentrevid) |
|
322 |
for revid in rebase_todo(wt.branch.repository, replace_map): |
|
323 |
info("%s -> %s" % (revid, replace_map[revid][0])) |
|
324 |
finally: |
|
325 |
wt.unlock() |
|
326 |
||
|
0.439.1
by Jelmer Vernooij
Allow use in non-root directories for rebase-continue, rebase-todo and rebase-abort. |
327 |
|
|
0.436.48
by Jelmer Vernooij
Add replay command. |
328 |
class cmd_replay(Command): |
|
0.436.65
by Jelmer Vernooij
Don't require running in the branch root. |
329 |
"""Replay commits from another branch on top of this one. |
|
0.436.48
by Jelmer Vernooij
Add replay command. |
330 |
|
331 |
"""
|
|
332 |
||
333 |
takes_options = ['revision', 'merge-type'] |
|
334 |
takes_args = ['location'] |
|
335 |
||
336 |
def run(self, location, revision=None, merge_type=None): |
|
337 |
from bzrlib.branch import Branch |
|
338 |
from bzrlib.workingtree import WorkingTree |
|
|
0.436.64
by Jelmer Vernooij
Support revision ranges to replay. |
339 |
from bzrlib import ui |
|
0.436.63
by Jelmer Vernooij
Fix replay command, add test. |
340 |
from rebase import regenerate_default_revid, replay_delta_workingtree |
|
0.436.48
by Jelmer Vernooij
Add replay command. |
341 |
|
|
0.436.65
by Jelmer Vernooij
Don't require running in the branch root. |
342 |
from_branch = Branch.open_containing(location)[0] |
|
0.436.48
by Jelmer Vernooij
Add replay command. |
343 |
|
344 |
if revision is not None: |
|
345 |
if len(revision) == 1: |
|
346 |
if revision[0] is not None: |
|
|
0.436.85
by Jelmer Vernooij
use cheaper as_revision_id. |
347 |
todo = [revision[0].as_revision_id(from_branch)] |
|
0.436.64
by Jelmer Vernooij
Support revision ranges to replay. |
348 |
elif len(revision) == 2: |
349 |
from_revno, from_revid = revision[0].in_history(from_branch) |
|
350 |
to_revno, to_revid = revision[1].in_history(from_branch) |
|
351 |
if to_revid is None: |
|
352 |
to_revno = from_branch.revno() |
|
353 |
todo = [] |
|
354 |
for revno in range(from_revno, to_revno + 1): |
|
355 |
todo.append(from_branch.get_rev_id(revno)) |
|
356 |
else: |
|
357 |
raise BzrCommandError( |
|
358 |
"--revision takes only one or two arguments") |
|
|
0.436.48
by Jelmer Vernooij
Add replay command. |
359 |
else: |
360 |
raise BzrCommandError("--revision is mandatory") |
|
361 |
||
362 |
wt = WorkingTree.open(".") |
|
363 |
wt.lock_write() |
|
|
0.436.64
by Jelmer Vernooij
Support revision ranges to replay. |
364 |
pb = ui.ui_factory.nested_progress_bar() |
|
0.436.48
by Jelmer Vernooij
Add replay command. |
365 |
try: |
|
0.436.64
by Jelmer Vernooij
Support revision ranges to replay. |
366 |
for revid in todo: |
367 |
pb.update("replaying commits", todo.index(revid), len(todo)) |
|
368 |
wt.branch.repository.fetch(from_branch.repository, revid) |
|
369 |
newrevid = regenerate_default_revid(wt.branch.repository, revid) |
|
370 |
replay_delta_workingtree(wt, revid, newrevid, |
|
371 |
[wt.last_revision()], |
|
372 |
merge_type=merge_type) |
|
|
0.436.48
by Jelmer Vernooij
Add replay command. |
373 |
finally: |
|
0.436.64
by Jelmer Vernooij
Support revision ranges to replay. |
374 |
pb.finished() |
|
0.436.48
by Jelmer Vernooij
Add replay command. |
375 |
wt.unlock() |
376 |
||
377 |
||
378 |
for cmd in [cmd_replay, cmd_rebase, cmd_rebase_abort, cmd_rebase_continue, |
|
379 |
cmd_rebase_todo]: |
|
380 |
register_command(cmd) |
|
381 |
||
|
0.436.4
by Jelmer Vernooij
Add some tests. |
382 |
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
383 |
def test_suite(): |
|
0.436.74
by Jelmer Vernooij
Add pydoctor file, more docstrings. |
384 |
"""Determine the testsuite for bzr-rebase.""" |
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
385 |
from unittest import TestSuite |
386 |
from bzrlib.tests import TestUtil |
|
387 |
||
388 |
loader = TestUtil.TestLoader() |
|
389 |
suite = TestSuite() |
|
|
0.436.19
by Jelmer Vernooij
- Add blackbox tests |
390 |
testmod_names = ['test_blackbox', 'test_rebase', 'test_maptree'] |
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
391 |
suite.addTest(loader.loadTestsFromModuleNames( |
392 |
["%s.%s" % (__name__, i) for i in testmod_names])) |
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
393 |
|
394 |
return suite |
|
|
0.436.1
by Jelmer Vernooij
Add framework for git-rebase plugin. |
395 |