/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

Use central git module.

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([self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms])
 
84
            ret.update([default_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, self.get_mapping()), max_count=max_count, skip=skip)
 
106
                cms = self._git.commits(self.lookup_git_revid(revision_id, default_mapping), max_count=max_count, skip=skip)
107
107
                skip += max_count
108
 
                ret += [self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms]
 
108
                ret += [default_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):
112
112
        raise errors.NoSuchRevision(self, revision_id)
113
113
 
114
 
    def lookup_revision_id(self, revid):
115
 
        """Lookup a revision id.
116
 
        
117
 
        :param revid: Bazaar revision id.
118
 
        :return: Tuple with git revisionid and mapping.
119
 
        """
120
 
        # Yes, this doesn't really work, but good enough as a stub
121
 
        return osutils.sha(rev_id).hexdigest(), self.get_mapping()
122
 
 
123
114
    def has_signature_for_revision_id(self, revision_id):
124
115
        return False
125
116
 
126
 
    def get_mapping(self):
127
 
        return default_mapping
128
 
 
129
117
    def get_parent_map(self, revision_ids):
130
118
        ret = {}
131
119
        for revid in revision_ids:
132
120
            if revid == revision.NULL_REVISION:
133
121
                ret[revid] = ()
134
122
            else:
135
 
                git_commit_id = self.lookup_git_revid(revid, self.get_mapping())
136
 
                commit = self._git.commit(git_commit_id)
137
 
                ret[revid] = tuple([self.get_mapping().revision_id_foreign_to_bzr(p.id) for p in commit.parents])
 
123
                commit = self._git.commit(self.lookup_git_revid(revid, default_mapping))
 
124
                ret[revid] = tuple([default_mapping.revision_id_foreign_to_bzr(p.id) for p in commit.parents])
138
125
        return ret
139
126
 
140
127
    def lookup_git_revid(self, bzr_revid, mapping):
144
131
            raise errors.NoSuchRevision(bzr_revid, self)
145
132
 
146
133
    def get_revision(self, revision_id):
147
 
        git_commit_id = self.lookup_git_revid(revision_id, self.get_mapping())
 
134
        git_commit_id = self.lookup_git_revid(revision_id, default_mapping)
148
135
        commit = self._git.commit(git_commit_id)
149
136
        # print "fetched revision:", git_commit_id
150
 
        revision = self._parse_rev(commit, self.get_mapping())
 
137
        revision = self._parse_rev(commit, default_mapping)
151
138
        return revision
152
139
 
153
140
    def has_revision(self, revision_id):
213
200
    def __init__(self, repository, revision_id):
214
201
        self._repository = repository
215
202
        self.revision_id = revision_id
216
 
        git_id = repository.lookup_git_revid(revision_id, repository.get_mapping())
 
203
        git_id = repository.lookup_git_revid(revision_id, default_mapping)
217
204
        self.tree = repository._git.commit(git_id).tree
218
205
        self._inventory = inventory.Inventory(revision_id=revision_id)
219
206
        self._inventory.root.revision = revision_id
229
216
 
230
217
    def _build_inventory(self, tree, ie, path):
231
218
        assert isinstance(path, str)
232
 
        for name, mode, hexsha in tree.entries():
233
 
            basename = name.decode("utf-8")
 
219
        for b in tree.contents:
 
220
            basename = b.name.decode("utf-8")
234
221
            if path == "":
235
 
                child_path = name
 
222
                child_path = b.name
236
223
            else:
237
 
                child_path = urlutils.join(path, name)
 
224
                child_path = urlutils.join(path, b.name)
238
225
            file_id = escape_file_id(child_path.encode('utf-8'))
239
 
            if mode[0] == '0':
 
226
            if b.mode[0] == '0':
240
227
                child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
241
 
            elif mode[0] == '1':
242
 
                if mode[1] == '0':
 
228
            elif b.mode[0] == '1':
 
229
                if b.mode[1] == '0':
243
230
                    child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
244
231
                    child_ie.text_sha1 = osutils.sha_string(b.data)
245
 
                elif mode[1] == '2':
 
232
                elif b.mode[1] == '2':
246
233
                    child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
247
234
                    child_ie.text_sha1 = osutils.sha_string("")
248
235
                else:
249
236
                    raise AssertionError(
250
 
                        "Unknown file kind, perms=%r." % (mode,))
 
237
                        "Unknown file kind, perms=%r." % (b.mode,))
251
238
                child_ie.text_id = b.id
252
239
                child_ie.text_size = b.size
253
240
            else:
254
241
                raise AssertionError(
255
 
                    "Unknown blob kind, perms=%r." % (mode,))
256
 
            child_ie.executable = bool(int(mode[3:], 8) & 0111)
 
242
                    "Unknown blob kind, perms=%r." % (b.mode,))
 
243
            child_ie.executable = bool(int(b.mode[3:], 8) & 0111)
257
244
            child_ie.revision = self.revision_id
258
245
            self._inventory.add(child_ie)
259
 
            if mode[0] == '0':
 
246
            if b.mode[0] == '0':
260
247
                self._build_inventory(b, child_ie, child_path)
261
248
 
262
249