/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

More work on roundtrip push support.

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