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

Support non-ascii characters in tag names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
        super(BzrGitMapping, self).__init__(foreign_git)
105
105
 
106
106
    def __eq__(self, other):
107
 
        return (type(self) == type(other) and
 
107
        return (type(self) == type(other) and 
108
108
                self.revid_prefix == other.revid_prefix)
109
109
 
110
110
    @classmethod
185
185
 
186
186
    def _extract_git_svn_metadata(self, rev, message):
187
187
        lines = message.split("\n")
188
 
        if not (lines[-1] == "" and len(lines) >= 2 and lines[-2].startswith("git-svn-id:")):
 
188
        if not (lines[-1] == "" and lines[-2].startswith("git-svn-id:")):
189
189
            return message
190
190
        git_svn_id = lines[-2].split(": ", 1)[1]
191
191
        rev.properties['git-svn-id'] = git_svn_id
227
227
        b.set_raw_chunks(serialize_fileid_map(fileid_map))
228
228
        return b
229
229
 
230
 
    def export_commit(self, rev, tree_sha, parent_lookup, roundtrip,
231
 
                      verifiers):
 
230
    def export_commit(self, rev, tree_sha, parent_lookup, roundtrip):
232
231
        """Turn a Bazaar revision in to a Git commit
233
232
 
234
233
        :param tree_sha: Tree sha for the commit
235
234
        :param parent_lookup: Function for looking up the GIT sha equiv of a
236
235
            bzr revision
237
 
        :param roundtrip: Whether to store roundtripping information.
238
 
        :param verifiers: Verifiers info
239
236
        :return dulwich.objects.Commit represent the revision:
240
237
        """
241
238
        from dulwich.objects import Commit
243
240
        commit.tree = tree_sha
244
241
        if roundtrip:
245
242
            metadata = BzrGitRevisionMetadata()
246
 
            metadata.verifiers = verifiers
247
243
        else:
248
244
            metadata = None
249
245
        parents = []
311
307
    def import_commit(self, commit, lookup_parent_revid):
312
308
        """Convert a git commit to a bzr revision.
313
309
 
314
 
        :return: a `bzrlib.revision.Revision` object, foreign revid and a
315
 
            testament sha1
 
310
        :return: a `bzrlib.revision.Revision` object and a 
 
311
            dictionary of path -> file ids
316
312
        """
317
313
        if commit is None:
318
314
            raise AssertionError("Commit object can't be None")
351
347
        rev.timezone = commit.commit_timezone
352
348
        if rev.git_metadata is not None:
353
349
            md = rev.git_metadata
354
 
            roundtrip_revid = md.revision_id
 
350
            if md.revision_id:
 
351
                rev.revision_id = md.revision_id
355
352
            if md.explicit_parent_ids:
356
353
                rev.parent_ids = md.explicit_parent_ids
357
354
            rev.properties.update(md.properties)
358
 
            verifiers = md.verifiers
359
 
        else:
360
 
            roundtrip_revid = None
361
 
            verifiers = {}
362
 
        return rev, roundtrip_revid, verifiers
 
355
        return rev
363
356
 
364
357
    def get_fileid_map(self, lookup_object, tree_sha):
365
358
        """Obtain a fileid map for a particular tree.
407
400
        return ret
408
401
 
409
402
    def import_commit(self, commit, lookup_parent_revid):
410
 
        rev, roundtrip_revid, verifiers = super(BzrGitMappingExperimental, self).import_commit(commit, lookup_parent_revid)
 
403
        rev, file_ids = super(BzrGitMappingExperimental, self).import_commit(commit, lookup_parent_revid)
411
404
        rev.properties['converted_revision'] = "git %s\n" % commit.id
412
 
        return rev, roundtrip_revid, verifiers
 
405
        return rev, file_ids
413
406
 
414
407
 
415
408
class GitMappingRegistry(VcsMappingRegistry):