0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
1 |
"""\
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
2 |
This contains functionality for installing bundles into repositories
|
0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
3 |
"""
|
4 |
||
1185.82.78
by Aaron Bentley
Cleanups |
5 |
import bzrlib.ui |
1185.82.84
by Aaron Bentley
Moved stuff around |
6 |
from bzrlib.progress import ProgressPhase |
7 |
from bzrlib.merge import Merger |
|
8 |
from bzrlib.repository import install_revision |
|
1185.82.141
by Aaron Bentley
Ensure bzr works when you merge an already-merged bundle |
9 |
from bzrlib.trace import note |
1185.82.81
by Aaron Bentley
Remove unused functionality |
10 |
|
0.5.67
by John Arbash Meinel
Working on apply_changeset |
11 |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
12 |
def install_bundle(repository, bundle_reader): |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
13 |
pb = bzrlib.ui.ui_factory.nested_progress_bar() |
1185.82.64
by Aaron Bentley
Lock repository while installing revisions |
14 |
repository.lock_write() |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
15 |
try: |
1793.2.2
by Aaron Bentley
Move BundleReader into v07 serializer |
16 |
real_revisions = bundle_reader.real_revisions |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
17 |
for i, revision in enumerate(reversed(real_revisions)): |
18 |
pb.update("Install revisions",i, len(real_revisions)) |
|
19 |
if repository.has_revision(revision.revision_id): |
|
20 |
continue
|
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
21 |
cset_tree = bundle_reader.revision_tree(repository, |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
22 |
revision.revision_id) |
23 |
install_revision(repository, revision, cset_tree) |
|
24 |
finally: |
|
1185.82.64
by Aaron Bentley
Lock repository while installing revisions |
25 |
repository.unlock() |
1185.82.63
by Aaron Bentley
Added install revision progress bar |
26 |
pb.finished() |
1185.82.40
by Aaron Bentley
Started work on testing install_revisions/handling empty changesets |
27 |
|
1185.82.81
by Aaron Bentley
Remove unused functionality |
28 |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
29 |
def merge_bundle(reader, tree, check_clean, merge_type, |
1185.82.84
by Aaron Bentley
Moved stuff around |
30 |
reprocess, show_base): |
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
31 |
"""Merge a revision bundle into the current tree."""
|
1185.82.84
by Aaron Bentley
Moved stuff around |
32 |
pb = bzrlib.ui.ui_factory.nested_progress_bar() |
1185.82.62
by Aaron Bentley
Don't fail if some data is already installed |
33 |
try: |
1185.82.84
by Aaron Bentley
Moved stuff around |
34 |
pp = ProgressPhase("Merge phase", 6, pb) |
35 |
pp.next_phase() |
|
1185.82.130
by Aaron Bentley
Rename changesets to revision bundles |
36 |
install_bundle(tree.branch.repository, reader) |
1185.82.84
by Aaron Bentley
Moved stuff around |
37 |
merger = Merger(tree.branch, this_tree=tree, pb=pb) |
38 |
merger.pp = pp |
|
39 |
merger.pp.next_phase() |
|
40 |
merger.check_basis(check_clean, require_commits=False) |
|
1793.2.2
by Aaron Bentley
Move BundleReader into v07 serializer |
41 |
merger.other_rev_id = reader.target |
42 |
merger.other_tree = merger.revision_tree(reader.target) |
|
43 |
merger.other_basis = reader.target |
|
1185.82.84
by Aaron Bentley
Moved stuff around |
44 |
merger.pp.next_phase() |
45 |
merger.find_base() |
|
46 |
if merger.base_rev_id == merger.other_rev_id: |
|
47 |
note("Nothing to do.") |
|
48 |
return 0 |
|
49 |
merger.merge_type = merge_type |
|
50 |
merger.show_base = show_base |
|
51 |
merger.reprocess = reprocess |
|
52 |
conflicts = merger.do_merge() |
|
53 |
merger.set_pending() |
|
54 |
finally: |
|
55 |
pb.clear() |
|
56 |
return conflicts |