2
This contains functionality for installing bundles into repositories
6
from bzrlib.progress import ProgressPhase
7
from bzrlib.merge import Merger
8
from bzrlib.repository import install_revision
11
def install_bundle(repository, bundle_reader):
12
pb = bzrlib.ui.ui_factory.nested_progress_bar()
13
repository.lock_write()
15
real_revisions = bundle_reader.info.real_revisions
16
for i, revision in enumerate(reversed(real_revisions)):
17
pb.update("Install revisions",i, len(real_revisions))
18
if repository.has_revision(revision.revision_id):
20
cset_tree = bundle_reader.revision_tree(repository,
22
install_revision(repository, revision, cset_tree)
28
def merge_bundle(reader, tree, check_clean, merge_type,
29
reprocess, show_base):
30
"""Merge a revision bundle into the current tree."""
31
pb = bzrlib.ui.ui_factory.nested_progress_bar()
33
pp = ProgressPhase("Merge phase", 6, pb)
35
install_bundle(tree.branch.repository, reader)
36
merger = Merger(tree.branch, this_tree=tree, pb=pb)
38
merger.pp.next_phase()
39
merger.check_basis(check_clean, require_commits=False)
40
merger.other_rev_id = reader.info.target
41
merger.other_tree = merger.revision_tree(reader.info.target)
42
merger.other_basis = reader.info.target
43
merger.pp.next_phase()
45
if merger.base_rev_id == merger.other_rev_id:
46
note("Nothing to do.")
48
merger.merge_type = merge_type
49
merger.show_base = show_base
50
merger.reprocess = reprocess
51
conflicts = merger.do_merge()