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
9
from bzrlib.trace import note
12
def install_bundle(repository, bundle_reader):
13
pb = bzrlib.ui.ui_factory.nested_progress_bar()
14
repository.lock_write()
16
real_revisions = bundle_reader.info.real_revisions
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):
21
cset_tree = bundle_reader.revision_tree(repository,
23
install_revision(repository, revision, cset_tree)
29
def merge_bundle(reader, tree, check_clean, merge_type,
30
reprocess, show_base):
31
"""Merge a revision bundle into the current tree."""
32
pb = bzrlib.ui.ui_factory.nested_progress_bar()
34
pp = ProgressPhase("Merge phase", 6, pb)
36
install_bundle(tree.branch.repository, reader)
37
merger = Merger(tree.branch, this_tree=tree, pb=pb)
39
merger.pp.next_phase()
40
merger.check_basis(check_clean, require_commits=False)
41
merger.other_rev_id = reader.info.target
42
merger.other_tree = merger.revision_tree(reader.info.target)
43
merger.other_basis = reader.info.target
44
merger.pp.next_phase()
46
if merger.base_rev_id == merger.other_rev_id:
47
note("Nothing to do.")
49
merger.merge_type = merge_type
50
merger.show_base = show_base
51
merger.reprocess = reprocess
52
conflicts = merger.do_merge()