~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2007-07-12 19:27:54 UTC
  • mto: This revision was merged to the branch mainline in revision 2617.
  • Revision ID: abentley@panoramicfeedback.com-20070712192754-30qegoe02w0uosra
Fix handling of ghost base trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
                raise BzrCommandError("Working tree has uncommitted changes.")
152
152
 
153
153
    def compare_basis(self):
154
 
        changes = self.this_tree.changes_from(self.revision_tree(
155
 
            self.this_tree.last_revision()))
 
154
        try:
 
155
            basis_tree = self.revision_tree(self.this_tree.last_revision())
 
156
        except errors.RevisionNotPresent:
 
157
            basis_tree = self.this_tree.basis_tree()
 
158
        changes = self.this_tree.changes_from(basis_tree)
156
159
        if not changes.has_changed():
157
160
            self.this_rev_id = self.this_basis
158
161
 
166
169
 
167
170
    def _add_parent(self):
168
171
        new_parents = self.this_tree.get_parent_ids() + [self.other_rev_id]
169
 
        new_parent_trees = [(r, self.revision_tree(r)) for r in new_parents]
170
 
        for _revision_id, tree in new_parent_trees:
171
 
            tree.lock_read()
 
172
        new_parent_trees = []
 
173
        for revision_id in new_parents:
 
174
            try:
 
175
                tree = self.revision_tree(revision_id)
 
176
            except errors.RevisionNotPresent:
 
177
                tree = None
 
178
            else:
 
179
                tree.lock_read()
 
180
            new_parent_trees.append((revision_id, tree))
172
181
        try:
173
 
            self.this_tree.set_parent_trees(new_parent_trees)
 
182
            self.this_tree.set_parent_trees(new_parent_trees,
 
183
                                            allow_leftmost_as_ghost=True)
174
184
        finally:
175
185
            for _revision_id, tree in new_parent_trees:
176
 
                tree.unlock()
 
186
                if tree is not None:
 
187
                    tree.unlock()
177
188
 
178
189
    def set_other(self, other_revision):
179
190
        """Set the revision and tree to merge from.