~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Naoki INADA
  • Date: 2009-10-29 10:01:19 UTC
  • mto: (4634.97.3 2.0)
  • mto: This revision was merged to the branch mainline in revision 4798.
  • Revision ID: inada-n@klab.jp-20091029100119-uckv9t7ej2qrghw3
import doc-ja rev90

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
 
66
66
def transform_tree(from_tree, to_tree, interesting_ids=None):
67
 
    merge_inner(from_tree.branch, to_tree, from_tree, ignore_zero=True,
68
 
                interesting_ids=interesting_ids, this_tree=from_tree)
 
67
    from_tree.lock_tree_write()
 
68
    try:
 
69
        merge_inner(from_tree.branch, to_tree, from_tree, ignore_zero=True,
 
70
                    interesting_ids=interesting_ids, this_tree=from_tree)
 
71
    finally:
 
72
        from_tree.unlock()
69
73
 
70
74
 
71
75
class Merger(object):
102
106
        self._is_criss_cross = None
103
107
        self._lca_trees = None
104
108
 
 
109
    def cache_trees_with_revision_ids(self, trees):
 
110
        """Cache any tree in trees if it has a revision_id."""
 
111
        for maybe_tree in trees:
 
112
            if maybe_tree is None:
 
113
                continue
 
114
            try:
 
115
                rev_id = maybe_tree.get_revision_id()
 
116
            except AttributeError:
 
117
                continue
 
118
            self._cached_trees[rev_id] = maybe_tree
 
119
 
105
120
    @property
106
121
    def revision_graph(self):
107
122
        if self._revision_graph is None:
598
613
        self.this_tree.lock_tree_write()
599
614
        self.base_tree.lock_read()
600
615
        self.other_tree.lock_read()
601
 
        self.tt = TreeTransform(self.this_tree, self.pb)
602
616
        try:
603
 
            self.pp.next_phase()
604
 
            self._compute_transform()
605
 
            self.pp.next_phase()
606
 
            results = self.tt.apply(no_conflicts=True)
607
 
            self.write_modified(results)
 
617
            self.tt = TreeTransform(self.this_tree, self.pb)
608
618
            try:
609
 
                self.this_tree.add_conflicts(self.cooked_conflicts)
610
 
            except UnsupportedOperation:
611
 
                pass
 
619
                self.pp.next_phase()
 
620
                self._compute_transform()
 
621
                self.pp.next_phase()
 
622
                results = self.tt.apply(no_conflicts=True)
 
623
                self.write_modified(results)
 
624
                try:
 
625
                    self.this_tree.add_conflicts(self.cooked_conflicts)
 
626
                except UnsupportedOperation:
 
627
                    pass
 
628
            finally:
 
629
                self.tt.finalize()
612
630
        finally:
613
 
            self.tt.finalize()
614
631
            self.other_tree.unlock()
615
632
            self.base_tree.unlock()
616
633
            self.this_tree.unlock()
1516
1533
    get_revision_id = getattr(base_tree, 'get_revision_id', None)
1517
1534
    if get_revision_id is None:
1518
1535
        get_revision_id = base_tree.last_revision
 
1536
    merger.cache_trees_with_revision_ids([other_tree, base_tree, this_tree])
1519
1537
    merger.set_base_revision(get_revision_id(), this_branch)
1520
1538
    return merger.do_merge()
1521
1539