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

Make most tree inspection tests succeed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
    def has_revision(self, revision_id):
152
152
        try:
153
153
            self.get_revision(revision_id)
154
 
        except NoSuchRevision:
 
154
        except errors.NoSuchRevision:
155
155
            return False
156
156
        else:
157
157
            return True
223
223
    def get_file_text(self, file_id):
224
224
        entry = self._inventory[file_id]
225
225
        if entry.kind == 'directory': return ""
226
 
        return self._repository._git.blob(entry.text_id).data
 
226
        return self._repository._git.get_blob(entry.text_id).data
227
227
 
228
228
    def _build_inventory(self, tree_id, ie, path):
229
229
        assert isinstance(path, str)
235
235
            else:
236
236
                child_path = urlutils.join(path, name)
237
237
            file_id = escape_file_id(child_path.encode('utf-8'))
238
 
            if mode[0] == '0':
 
238
            entry_kind = (mode & 0700000) / 0100000
 
239
            if entry_kind == 0:
239
240
                child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
240
 
            elif mode[0] == '1':
241
 
                if mode[1] == '0':
 
241
            elif entry_kind == 1:
 
242
                file_kind = (mode & 070000) / 010000
 
243
                b = self._repository._git.get_blob(hexsha)
 
244
                if file_kind == 0:
242
245
                    child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
243
246
                    child_ie.text_sha1 = osutils.sha_string(b.data)
244
 
                elif mode[1] == '2':
 
247
                elif file_kind == 2:
245
248
                    child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
246
249
                    child_ie.text_sha1 = osutils.sha_string("")
247
250
                else:
248
251
                    raise AssertionError(
249
 
                        "Unknown file kind, perms=%r." % (mode,))
 
252
                        "Unknown file kind, perms=%o." % (mode,))
250
253
                child_ie.text_id = b.id
251
 
                child_ie.text_size = b.size
 
254
                child_ie.text_size = len(b.data)
252
255
            else:
253
256
                raise AssertionError(
254
257
                    "Unknown blob kind, perms=%r." % (mode,))
255
 
            child_ie.executable = bool(int(mode[3:], 8) & 0111)
 
258
            fs_mode = mode & 0777
 
259
            child_ie.executable = bool(fs_mode & 0111)
256
260
            child_ie.revision = self.revision_id
257
261
            self._inventory.add(child_ie)
258
 
            if mode[0] == '0':
259
 
                self._build_inventory(b, child_ie, child_path)
 
262
            if entry_kind == 0:
 
263
                self._build_inventory(hexsha, child_ie, child_path)
260
264
 
261
265
 
262
266
class GitFormat(object):