~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/memorytree.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-17 20:10:04 UTC
  • mto: This revision was merged to the branch mainline in revision 2452.
  • Revision ID: john@arbash-meinel.com-20070417201004-1v7sim0tlt19l8o4
Make a Branch helper which can create a very basic MemoryTree with history.
This updates MutableTree to include 'set_parent_ids' which is helpful
when setting up simple tests.
It also creates a helper function in branch_implementations..TestCaseWithBranch
so that we can create a Branch which has a simple merge in it.
It also adds a test for revision_id_to_revno which previously did not have any
direct tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
            else:
223
223
                raise errors.NoSuchId(self, file_id)
224
224
 
 
225
    def set_parent_ids(self, revision_ids, allow_leftmost_as_ghost=False):
 
226
        """See MutableTree.set_parent_trees()."""
 
227
        if len(revision_ids) == 0:
 
228
            self._parent_ids = []
 
229
            self._basis_tree = self.branch.repository.revision_tree(None)
 
230
        else:
 
231
            self._parent_ids = revision_ids
 
232
            self._basis_tree = self.branch.repository.revision_tree(
 
233
                                    revision_ids[0])
 
234
            self._branch_revision_id = revision_ids[0]
 
235
 
225
236
    def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
226
237
        """See MutableTree.set_parent_trees()."""
227
238
        if len(parents_list) == 0:
228
239
            self._parent_ids = []
229
 
            self._basis_tree = self.branch.repository.revisiontree(None)
 
240
            self._basis_tree = self.branch.repository.revision_tree(None)
230
241
        else:
231
242
            if parents_list[0][1] is None and not allow_leftmost_as_ghost:
232
243
                # a ghost in the left most parent
233
244
                raise errors.GhostRevisionUnusableHere(parents_list[0][0])
234
245
            self._parent_ids = [parent_id for parent_id, tree in parents_list]
235
246
            if parents_list[0][1] is None:
236
 
                self._basis_tree = self.branch.repository.revisiontree(None)
 
247
                self._basis_tree = self.branch.repository.revision_tree(None)
237
248
            else:
238
249
                self._basis_tree = parents_list[0][1]
239
250
            self._branch_revision_id = parents_list[0][0]