/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

Don't claim control directories can be accessed directly, always open the
branch itself.

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.fileid_map.lookup_file_id(
 
53
        self.file_id = self._inventory.mapping.generate_file_id(
54
54
            path.encode('utf-8'))
55
55
 
56
56
    @property
76
76
 
77
77
    @property
78
78
    def text_sha1(self):
79
 
        return osutils.sha_strings(self.object.chunked)
 
79
        return osutils.sha_string(self.object.data)
80
80
 
81
81
    @property
82
82
    def text_size(self):
179
179
        for mode, name, hexsha in self.object.entries():
180
180
            basename = name.decode("utf-8")
181
181
            child_path = osutils.pathjoin(self.path, basename)
182
 
            if self._inventory.mapping.is_control_file(child_path):
183
 
                continue
184
182
            executable = mode_is_executable(mode)
185
183
            kind_class = {'directory': GitInventoryDirectory,
186
184
                          'file': GitInventoryFile,
200
198
 
201
199
class GitInventory(inventory.Inventory):
202
200
 
203
 
    def __init__(self, tree_id, mapping, fileid_map, store, revision_id):
 
201
    def __init__(self, tree_id, mapping, store, revision_id):
204
202
        super(GitInventory, self).__init__(revision_id=revision_id)
205
203
        self.store = store
206
 
        self.fileid_map = fileid_map
207
204
        self.mapping = mapping
208
205
        self.root = GitInventoryDirectory(self, None, tree_id, u"", u"", False)
209
206
 
231
228
            return False
232
229
 
233
230
    def id2path(self, file_id):
234
 
        path = self.fileid_map.lookup_path(file_id)
 
231
        path = self.mapping.parse_file_id(file_id)
235
232
        try:
236
233
            ie = self._get_ie(path)
237
234
            assert ie.path == path
247
244
    def __getitem__(self, file_id):
248
245
        if file_id == inventory.ROOT_ID:
249
246
            return self.root
250
 
        path = self.fileid_map.lookup_path(file_id)
 
247
        path = self.mapping.parse_file_id(file_id)
251
248
        try:
252
249
            return self._get_ie(path)
253
250
        except KeyError:
257
254
class GitIndexInventory(inventory.Inventory):
258
255
    """Inventory that retrieves its contents from an index file."""
259
256
 
260
 
    def __init__(self, basis_inventory, fileid_map, index, store):
 
257
    def __init__(self, basis_inventory, mapping, index, store):
261
258
        super(GitIndexInventory, self).__init__(revision_id=None, root_id=basis_inventory.root.file_id)
262
259
        self.basis_inv = basis_inventory
263
 
        self.fileid_map = fileid_map
 
260
        self.mapping = mapping
264
261
        self.index = index
265
262
        self._contents_read = False
266
263
        self.store = store
267
264
        self.root = self.add_path("", 'directory',
268
 
            self.fileid_map.lookup_file_id(""), None)
 
265
            self.mapping.generate_file_id(""), None)
269
266
 
270
267
    def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
271
268
        self._read_contents()
290
287
    def id2path(self, file_id):
291
288
        if type(file_id) != str:
292
289
            raise AssertionError
293
 
        path = self.fileid_map.lookup_path(file_id)
 
290
        path = self.mapping.parse_file_id(file_id)
294
291
        if path in self.index:
295
292
            return path
296
293
        self._read_contents()
298
295
 
299
296
    def path2id(self, path):
300
297
        if path in self.index:
301
 
            return self.fileid_map.lookup_file_id(path)
 
298
            return self.mapping.generate_file_id(path)
302
299
        self._read_contents()
303
300
        return super(GitIndexInventory, self).path2id(path)
304
301
 
323
320
                except KeyError:
324
321
                    old_ie = None
325
322
                if old_ie is None:
326
 
                    file_id = self.fileid_map.lookup_file_id(path)
 
323
                    file_id = self.mapping.generate_file_id(path)
327
324
                else:
328
325
                    file_id = old_ie.file_id
329
326
                if type(file_id) != str:
355
352
            else:
356
353
                parent_fid = self.add_parents(dirname)
357
354
            ie = self.add_path(dirname, 'directory',
358
 
                    self.fileid_map.lookup_file_id(dirname), parent_fid)
 
355
                    self.mapping.generate_file_id(dirname), parent_fid)
359
356
            if ie.file_id in self.basis_inv:
360
357
                ie.revision = self.basis_inv[ie.file_id].revision
361
358
            file_id = ie.file_id