/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/per_inventory/basics.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:33:45 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7389.
  • Revision ID: jelmer@jelmer.uk-20190811133345-dp9j3c569vxj4l9y
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
        self.assertEqual(inv.path2id('src'), b'src-id')
158
158
        self.assertEqual(inv.path2id('src/bye.c'), b'bye-id')
159
159
 
 
160
    def test_get_entry_by_path_partial(self):
 
161
        inv = inventory.Inventory(b'TREE_ROOT')
 
162
        inv.root.revision = b'revision'
 
163
        for args in [('src', 'directory', b'src-id'),
 
164
                     ('doc', 'directory', b'doc-id'),
 
165
                     ('src/hello.c', 'file'),
 
166
                     ('src/bye.c', 'file', b'bye-id'),
 
167
                     ('Makefile', 'file'),
 
168
                     ('external', 'tree-reference', b'other-root')]:
 
169
            ie = inv.add_path(*args)
 
170
            ie.revision = b'revision'
 
171
            if args[1] == 'file':
 
172
                ie.text_sha1 = osutils.sha_string(b'content\n')
 
173
                ie.text_size = len(b'content\n')
 
174
            if args[1] == 'tree-reference':
 
175
                ie.reference_revision = b'reference'
 
176
        inv = self.inv_to_test_inv(inv)
 
177
 
 
178
        # Standard lookups
 
179
        ie, resolved, remaining = inv.get_entry_by_path_partial('')
 
180
        self.assertEqual((ie.file_id, resolved, remaining), (b'TREE_ROOT', [], []))
 
181
        ie, resolved, remaining = inv.get_entry_by_path_partial('src')
 
182
        self.assertEqual((ie.file_id, resolved, remaining), (b'src-id', ['src'], []))
 
183
        ie, resolved, remaining = inv.get_entry_by_path_partial('src/bye.c')
 
184
        self.assertEqual((ie.file_id, resolved, remaining), (b'bye-id', ['src', 'bye.c'], []))
 
185
 
 
186
        # Paths in the external tree
 
187
        ie, resolved, remaining = inv.get_entry_by_path_partial('external')
 
188
        self.assertEqual((ie.file_id, resolved, remaining), (b'other-root', ['external'], []))
 
189
        ie, resolved, remaining = inv.get_entry_by_path_partial('external/blah')
 
190
        self.assertEqual((ie.file_id, resolved, remaining), (b'other-root', ['external'], ['blah']))
 
191
 
 
192
        # Nonexistant paths
 
193
        ie, resolved, remaining = inv.get_entry_by_path_partial('foo.c')
 
194
        self.assertEqual((ie, resolved, remaining), (None, None, None))
 
195
 
160
196
    def test_non_directory_children(self):
161
197
        """Test path2id when a parent directory has no children"""
162
198
        inv = inventory.Inventory(b'tree-root')