/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 inventory.py

Check types of file ids.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        self.path = path
51
51
        self.revision = self._inventory.revision_id
52
52
        self.executable = executable
53
 
        self.file_id = self._inventory.mapping.generate_file_id(path.encode('utf-8'))
 
53
        self.file_id = self._inventory.mapping.generate_file_id(
 
54
            path.encode('utf-8'))
54
55
 
55
56
    @property
56
57
    def object(self):
183
184
                          'file': GitInventoryFile,
184
185
                          'symlink': GitInventoryLink,
185
186
                          'tree-reference': GitInventoryTreeReference}[mode_kind(mode)]
186
 
            self._children[basename] = kind_class(self._inventory, self.file_id, hexsha, child_path, basename, executable)
 
187
            self._children[basename] = kind_class(self._inventory,
 
188
                self.file_id, hexsha, child_path, basename, executable)
187
189
 
188
190
    def copy(self):
189
191
        other = inventory.InventoryDirectory(self.file_id, self.name,
258
260
        self.mapping = mapping
259
261
        self.index = index
260
262
        self._contents_read = False
 
263
        self.store = store
261
264
        self.root = self.add_path("", 'directory',
262
265
            self.mapping.generate_file_id(""), None)
263
266
 
264
267
    def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
265
268
        self._read_contents()
266
 
        return super(GitIndexInventory, self).iter_entries_by_dir(specific_file_ids=specific_file_ids, yield_parents=yield_parents)
 
269
        return super(GitIndexInventory, self).iter_entries_by_dir(
 
270
            specific_file_ids=specific_file_ids, yield_parents=yield_parents)
267
271
 
268
272
    def has_id(self, file_id):
 
273
        if type(file_id) != str:
 
274
            raise AssertionError
269
275
        try:
270
276
            self.id2path(file_id)
271
277
            return True
279
285
        return super(GitIndexInventory, self).has_filename(path)
280
286
 
281
287
    def id2path(self, file_id):
 
288
        if type(file_id) != str:
 
289
            raise AssertionError
282
290
        path = self.mapping.parse_file_id(file_id)
283
291
        if path in self.index:
284
292
            return path
315
323
                    file_id = self.mapping.generate_file_id(path)
316
324
                else:
317
325
                    file_id = old_ie.file_id
 
326
                if type(file_id) != str:
 
327
                    raise AssertionError
318
328
                kind = mode_kind(mode)
319
329
                if old_ie is not None and old_ie.hexsha == sha:
320
330
                    # Hasn't changed since basis inv
323
333
                else:
324
334
                    ie = self.add_path(path, kind, file_id,
325
335
                        self.add_parents(path))
326
 
                    data = store[sha].data
 
336
                    data = self.store[sha].data
327
337
                    if kind == "symlink":
328
338
                        ie.symlink_target = data
329
339
                    else:
346
356
            if ie.file_id in self.basis_inv:
347
357
                ie.revision = self.basis_inv[ie.file_id].revision
348
358
            file_id = ie.file_id
 
359
        if type(file_id) != str:
 
360
            raise AssertionError
349
361
        return file_id
350
362