2
2
This contains functionality for installing changesets into repositories
5
from bzrlib.errors import RevisionAlreadyPresent
6
from bzrlib.tree import EmptyTree
6
from bzrlib.progress import ProgressPhase
7
from bzrlib.merge import Merger
8
from bzrlib.repository import install_revision
10
11
def install_changeset(repository, changeset_reader):
27
def install_revision(repository, rev, cset_tree):
30
for p_id in rev.parent_ids:
31
if repository.has_revision(p_id):
32
present_parents.append(p_id)
33
parent_trees[p_id] = repository.revision_tree(p_id)
35
parent_trees[p_id] = EmptyTree()
37
inv = cset_tree.inventory
39
# Add the texts that are not already present
40
for path, ie in inv.iter_entries():
41
w = repository.weave_store.get_weave_or_empty(ie.file_id,
42
repository.get_transaction())
43
if ie.revision not in w:
45
for revision, tree in parent_trees.iteritems():
46
if ie.file_id not in tree:
48
parent_id = tree.inventory[ie.file_id].revision
49
if parent_id in text_parents:
51
text_parents.append(parent_id)
53
vfile = repository.weave_store.get_weave_or_empty(ie.file_id,
54
repository.get_transaction())
55
lines = cset_tree.get_file(ie.file_id).readlines()
56
vfile.add_lines(rev.revision_id, text_parents, lines)
28
def merge_changeset(reader, tree, check_clean, merge_type,
29
reprocess, show_base):
30
"""Merge a changeset's revision into the current tree."""
31
pb = bzrlib.ui.ui_factory.nested_progress_bar()
58
# install the inventory
59
repository.add_inventory(rev.revision_id, inv, present_parents)
60
except RevisionAlreadyPresent:
62
repository.add_revision(rev.revision_id, rev, inv)
33
pp = ProgressPhase("Merge phase", 6, pb)
35
install_changeset(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()