~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_memorytree.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-16 01:50:48 UTC
  • mfrom: (2078 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: john@arbash-meinel.com-20061016015048-0f22df07e38093da
[merge] bzr.dev 2078

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        branch = self.make_branch('branch')
87
87
        tree = MemoryTree.create_on_branch(branch)
88
88
        tree.lock_write()
89
 
        tree.add(['afile', 'adir'], None, ['file', 'directory'])
 
89
        tree.add(['', 'afile', 'adir'], None, 
 
90
                 ['directory', 'file', 'directory'])
90
91
        self.assertEqual('afile', tree.id2path(tree.path2id('afile')))
91
92
        self.assertEqual('adir', tree.id2path(tree.path2id('adir')))
92
93
        self.assertFalse(tree.has_filename('afile'))
97
98
        branch = self.make_branch('branch')
98
99
        tree = MemoryTree.create_on_branch(branch)
99
100
        tree.lock_write()
100
 
        tree.add(['foo'], ids=['foo-id'], kinds=['file'])
 
101
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
102
                  kinds=['directory', 'file'])
101
103
        tree.put_file_bytes_non_atomic('foo-id', 'barshoom')
102
104
        self.assertEqual('barshoom', tree.get_file('foo-id').read())
103
105
        tree.unlock()
106
108
        branch = self.make_branch('branch')
107
109
        tree = MemoryTree.create_on_branch(branch)
108
110
        tree.lock_write()
109
 
        tree.add(['foo'], ids=['foo-id'], kinds=['file'])
 
111
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
112
                 kinds=['directory', 'file'])
110
113
        tree.put_file_bytes_non_atomic('foo-id', 'first-content')
111
114
        tree.put_file_bytes_non_atomic('foo-id', 'barshoom')
112
115
        self.assertEqual('barshoom', tree.get_file('foo-id').read())
121
124
        branch = self.make_branch('branch')
122
125
        tree = MemoryTree.create_on_branch(branch)
123
126
        tree.lock_write()
124
 
        tree.add(['foo'], ids=['foo-id'], kinds=['file'])
 
127
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
128
                 kinds=['directory', 'file'])
125
129
        tree.put_file_bytes_non_atomic('foo-id', 'barshoom')
126
130
        revision_id = tree.commit('message baby')
127
131
        # the parents list for the tree should have changed.
136
140
        branch = self.make_branch('branch')
137
141
        tree = MemoryTree.create_on_branch(branch)
138
142
        tree.lock_write()
139
 
        tree.add(['foo'], ids=['foo-id'], kinds=['file'])
 
143
        tree.add(['', 'foo'], ids=['root-id', 'foo-id'], 
 
144
                 kinds=['directory', 'file'])
140
145
        tree.unversion(['foo-id'])
141
146
        self.assertFalse(tree.has_id('foo-id'))
142
147
        tree.unlock()
144
149
    def test_last_revision(self):
145
150
        """There should be a last revision method we can call."""
146
151
        tree = self.make_branch_and_memory_tree('branch')
 
152
        tree.lock_write()
 
153
        tree.add('')
147
154
        rev_id = tree.commit('first post')
 
155
        tree.unlock()
148
156
        self.assertEqual(rev_id, tree.last_revision())