/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

  • Committer: Jelmer Vernooij
  • Date: 2009-09-10 13:13:15 UTC
  • mto: (0.200.602 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20090910131315-6890xg58pl2jseml
Allow serving remote URLs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
    _git_class = Blob
68
68
 
69
69
    def __init__(self, inv, parent_id, hexsha, path, basename, executable):
70
 
        super(GitInventoryFile, self).__init__(inv, parent_id, hexsha, path,
71
 
            basename, executable)
 
70
        super(GitInventoryFile, self).__init__(inv, parent_id, hexsha, path, basename, executable)
72
71
        self.kind = 'file'
73
72
        self.text_id = None
74
73
        self.symlink_target = None
96
95
        return ''
97
96
 
98
97
    def copy(self):
99
 
        other = inventory.InventoryFile(self.file_id, self.name,
100
 
            self.parent_id)
 
98
        other = inventory.InventoryFile(self.file_id, self.name, self.parent_id)
101
99
        other.executable = self.executable
102
100
        other.text_id = self.text_id
103
101
        other.text_sha1 = self.text_sha1
126
124
 
127
125
    def copy(self):
128
126
        other = inventory.InventoryLink(self.file_id, self.name, self.parent_id)
129
 
        other.executable = self.executable
130
127
        other.symlink_target = self.symlink_target
131
128
        other.revision = self.revision
132
129
        return other
138
135
 
139
136
    def __init__(self, inv, parent_id, hexsha, path, basename, executable):
140
137
        super(GitInventoryTreeReference, self).__init__(inv, parent_id, hexsha, path, basename, executable)
141
 
        self.hexsha = hexsha
142
 
        self.reference_revision = inv.mapping.revision_id_foreign_to_bzr(hexsha)
143
138
        self.text_sha1 = None
144
139
        self.text_size = None
145
140
        self.symlink_target = None
186
181
            self._children[basename] = kind_class(self._inventory, self.file_id, hexsha, child_path, basename, executable)
187
182
 
188
183
    def copy(self):
189
 
        other = inventory.InventoryDirectory(self.file_id, self.name,
 
184
        other = inventory.InventoryDirectory(self.file_id, self.name, 
190
185
                                             self.parent_id)
191
186
        other.revision = self.revision
192
187
        # note that children are *not* copied; they're pulled across when
208
203
        parts = path.split("/")
209
204
        ie = self.root
210
205
        for name in parts:
211
 
            ie = ie.children[name]
 
206
            ie = ie.children[name] 
212
207
        return ie
213
208
 
214
209
    def has_filename(self, path):
257
252
        self.basis_inv = basis_inventory
258
253
        self.mapping = mapping
259
254
        self.index = index
260
 
        self._contents_read = False
261
 
        self.root = self.add_path("", 'directory',
262
 
            self.mapping.generate_file_id(""), None)
263
 
 
264
 
    def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
265
 
        self._read_contents()
266
 
        return super(GitIndexInventory, self).iter_entries_by_dir(specific_file_ids=specific_file_ids, yield_parents=yield_parents)
267
 
 
268
 
    def has_id(self, file_id):
269
 
        try:
270
 
            self.id2path(file_id)
271
 
            return True
272
 
        except errors.NoSuchId:
273
 
            return False
274
 
 
275
 
    def has_filename(self, path):
276
 
        if path in self.index:
277
 
            return True
278
 
        self._read_contents()
279
 
        return super(GitIndexInventory, self).has_filename(path)
280
 
 
281
 
    def id2path(self, file_id):
282
 
        path = self.mapping.parse_file_id(file_id)
283
 
        if path in self.index:
284
 
            return path
285
 
        self._read_contents()
286
 
        return super(GitIndexInventory, self).id2path(file_id)
287
 
 
288
 
    def path2id(self, path):
289
 
        if path in self.index:
290
 
            return self.mapping.generate_file_id(path)
291
 
        self._read_contents()
292
 
        return super(GitIndexInventory, self).path2id(path)
293
 
 
294
 
    def __getitem__(self, file_id):
295
 
        self._read_contents()
296
 
        return super(GitIndexInventory, self).__getitem__(file_id)
297
 
 
298
 
    def _read_contents(self):
299
 
        if self._contents_read:
300
 
            return
301
 
        self._contents_read = True
 
255
 
302
256
        pb = ui.ui_factory.nested_progress_bar()
303
257
        try:
304
258
            for i, (path, value) in enumerate(self.index.iteritems()):
305
 
                pb.update("creating working inventory from index",
 
259
                pb.update("creating working inventory from index", 
306
260
                        i, len(self.index))
307
261
                assert isinstance(path, str)
308
262
                assert isinstance(value, tuple) and len(value) == 10
321
275
                    self.add_parents(path)
322
276
                    self.add(old_ie)
323
277
                else:
324
 
                    ie = self.add_path(path, kind, file_id,
325
 
                        self.add_parents(path))
 
278
                    ie = self.add_path(path, kind, file_id, self.add_parents(path))
326
279
                    data = store[sha].data
327
280
                    if kind == "symlink":
328
281
                        ie.symlink_target = data
335
288
 
336
289
    def add_parents(self, path):
337
290
        dirname, _ = osutils.split(path)
338
 
        file_id = super(GitIndexInventory, self).path2id(dirname)
 
291
        file_id = self.path2id(dirname)
339
292
        if file_id is None:
340
293
            if dirname == "":
341
294
                parent_fid = None
342
295
            else:
343
296
                parent_fid = self.add_parents(dirname)
344
 
            ie = self.add_path(dirname, 'directory',
 
297
            ie = self.add_path(dirname, 'directory', 
345
298
                    self.mapping.generate_file_id(dirname), parent_fid)
346
299
            if ie.file_id in self.basis_inv:
347
300
                ie.revision = self.basis_inv[ie.file_id].revision