/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

Merge new dulwich.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
        while cms != []:
82
82
            cms = self._git.commits("--all", max_count=max_count, skip=skip)
83
83
            skip += max_count
84
 
            ret.update([default_mapping.revision_id_foreign_to_bzr(cm.id) for cm in cms])
 
84
            ret.update([self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms])
85
85
        return ret
86
86
 
87
87
    def is_shared(self):
103
103
            max_count = 1000
104
104
            cms = None
105
105
            while cms != []:
106
 
                cms = self._git.commits(self.lookup_git_revid(revision_id, default_mapping), max_count=max_count, skip=skip)
 
106
                cms = self._git.commits(self.lookup_git_revid(revision_id, self.get_mapping()), max_count=max_count, skip=skip)
107
107
                skip += max_count
108
 
                ret += [default_mapping.revision_id_foreign_to_bzr(cm.id) for cm in cms]
 
108
                ret += [self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms]
109
109
        return [None] + ret
110
110
 
111
111
    def get_signature_text(self, revision_id):
123
123
    def has_signature_for_revision_id(self, revision_id):
124
124
        return False
125
125
 
 
126
    def get_mapping(self):
 
127
        return default_mapping
 
128
 
126
129
    def get_parent_map(self, revision_ids):
127
130
        ret = {}
128
131
        for revid in revision_ids:
129
132
            if revid == revision.NULL_REVISION:
130
133
                ret[revid] = ()
131
134
            else:
 
135
                git_commit_id = self.lookup_git_revid(revid, self.get_mapping())
 
136
                commit = self._git.commit(git_commit_id)
132
137
                ret[revid] = tuple([self.get_mapping().revision_id_foreign_to_bzr(p.id) for p in commit.parents])
133
138
        return ret
134
139
 
139
144
            raise errors.NoSuchRevision(bzr_revid, self)
140
145
 
141
146
    def get_revision(self, revision_id):
142
 
        git_commit_id = self.lookup_git_revid(revision_id, default_mapping)
 
147
        git_commit_id = self.lookup_git_revid(revision_id, self.get_mapping())
143
148
        commit = self._git.commit(git_commit_id)
144
149
        # print "fetched revision:", git_commit_id
145
 
        revision = self._parse_rev(commit, default_mapping)
 
150
        revision = self._parse_rev(commit, self.get_mapping())
146
151
        return revision
147
152
 
148
153
    def has_revision(self, revision_id):
208
213
    def __init__(self, repository, revision_id):
209
214
        self._repository = repository
210
215
        self.revision_id = revision_id
211
 
        git_id = repository.lookup_git_revid(revision_id, default_mapping)
 
216
        git_id = repository.lookup_git_revid(revision_id, repository.get_mapping())
212
217
        self.tree = repository._git.commit(git_id).tree
213
218
        self._inventory = inventory.Inventory(revision_id=revision_id)
214
219
        self._inventory.root.revision = revision_id
224
229
 
225
230
    def _build_inventory(self, tree, ie, path):
226
231
        assert isinstance(path, str)
227
 
        for b in tree.contents:
228
 
            basename = b.name.decode("utf-8")
 
232
        for name, mode, hexsha in tree.entries():
 
233
            basename = name.decode("utf-8")
229
234
            if path == "":
230
 
                child_path = b.name
 
235
                child_path = name
231
236
            else:
232
 
                child_path = urlutils.join(path, b.name)
 
237
                child_path = urlutils.join(path, name)
233
238
            file_id = escape_file_id(child_path.encode('utf-8'))
234
 
            if b.mode[0] == '0':
 
239
            if mode[0] == '0':
235
240
                child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
236
 
            elif b.mode[0] == '1':
237
 
                if b.mode[1] == '0':
 
241
            elif mode[0] == '1':
 
242
                if mode[1] == '0':
238
243
                    child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
239
244
                    child_ie.text_sha1 = osutils.sha_string(b.data)
240
 
                elif b.mode[1] == '2':
 
245
                elif mode[1] == '2':
241
246
                    child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
242
247
                    child_ie.text_sha1 = osutils.sha_string("")
243
248
                else:
244
249
                    raise AssertionError(
245
 
                        "Unknown file kind, perms=%r." % (b.mode,))
 
250
                        "Unknown file kind, perms=%r." % (mode,))
246
251
                child_ie.text_id = b.id
247
252
                child_ie.text_size = b.size
248
253
            else:
249
254
                raise AssertionError(
250
 
                    "Unknown blob kind, perms=%r." % (b.mode,))
251
 
            child_ie.executable = bool(int(b.mode[3:], 8) & 0111)
 
255
                    "Unknown blob kind, perms=%r." % (mode,))
 
256
            child_ie.executable = bool(int(mode[3:], 8) & 0111)
252
257
            child_ie.revision = self.revision_id
253
258
            self._inventory.add(child_ie)
254
 
            if b.mode[0] == '0':
 
259
            if mode[0] == '0':
255
260
                self._build_inventory(b, child_ie, child_path)
256
261
 
257
262