/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:
45
45
from bzrlib.plugins.git.roundtrip import (
46
46
    extract_bzr_metadata,
47
47
    inject_bzr_metadata,
48
 
    CommitSupplement,
 
48
    BzrGitRevisionMetadata,
49
49
    deserialize_fileid_map,
50
50
    serialize_fileid_map,
51
51
    )
100
100
 
101
101
    BZR_DUMMY_FILE = None
102
102
 
103
 
    def is_special_file(self, filename):
104
 
        return (filename in (self.BZR_FILE_IDS_FILE, self.BZR_DUMMY_FILE))
105
 
 
106
103
    def __init__(self):
107
 
        super(BzrGitMapping, self).__init__(foreign_vcs_git)
 
104
        super(BzrGitMapping, self).__init__(foreign_git)
108
105
 
109
106
    def __eq__(self, other):
110
107
        return (type(self) == type(other) and
214
211
        return message, metadata
215
212
 
216
213
    def _decode_commit_message(self, rev, message, encoding):
217
 
        return message.decode(encoding), CommitSupplement()
 
214
        return message.decode(encoding), BzrGitRevisionMetadata()
218
215
 
219
216
    def _encode_commit_message(self, rev, message, encoding):
220
217
        return message.encode(encoding)
245
242
        commit = Commit()
246
243
        commit.tree = tree_sha
247
244
        if roundtrip:
248
 
            metadata = CommitSupplement()
 
245
            metadata = BzrGitRevisionMetadata()
249
246
            metadata.verifiers = verifiers
250
247
        else:
251
248
            metadata = None
321
318
            raise AssertionError("Commit object can't be None")
322
319
        rev = ForeignRevision(commit.id, self,
323
320
                self.revision_id_foreign_to_bzr(commit.id))
 
321
        rev.parent_ids = tuple([lookup_parent_revid(p) for p in commit.parents])
324
322
        rev.git_metadata = None
325
323
        def decode_using_encoding(rev, commit, encoding):
326
324
            rev.committer = str(commit.committer).decode(encoding)
351
349
            rev.properties['commit-timezone-neg-utc'] = ""
352
350
        rev.timestamp = commit.commit_time
353
351
        rev.timezone = commit.commit_timezone
354
 
        rev.parent_ids = None
355
352
        if rev.git_metadata is not None:
356
353
            md = rev.git_metadata
357
354
            roundtrip_revid = md.revision_id
362
359
        else:
363
360
            roundtrip_revid = None
364
361
            verifiers = {}
365
 
        if rev.parent_ids is None:
366
 
            rev.parent_ids = tuple([lookup_parent_revid(p) for p in commit.parents])
367
362
        return rev, roundtrip_revid, verifiers
368
363
 
369
364
    def get_fileid_map(self, lookup_object, tree_sha):
438
433
    "BzrGitMappingv1")
439
434
mapping_registry.register_lazy('git-experimental',
440
435
    "bzrlib.plugins.git.mapping", "BzrGitMappingExperimental")
441
 
# mapping_registry.set_default('git-experimental')
442
436
mapping_registry.set_default('git-v1')
443
437
 
444
438
 
468
462
        return { "git commit": foreign_revid }
469
463
 
470
464
 
471
 
foreign_vcs_git = ForeignGit()
 
465
foreign_git = ForeignGit()
472
466
default_mapping = mapping_registry.get_default()()
473
467
 
474
468
 
552
546
            mode = entry_mode(ie)
553
547
        hexsha = lookup_ie_sha1(ie)
554
548
        if hexsha is not None:
555
 
            tree.add(name.encode("utf-8"), mode, hexsha)
 
549
            tree.add(mode, name.encode("utf-8"), hexsha)
556
550
    if entry.parent_id is not None and len(tree) == 0:
557
551
        # Only the root can be an empty tree
558
552
        if empty_file_name is not None:
559
 
            tree.add(empty_file_name, stat.S_IFREG | 0644, Blob().id)
 
553
            tree.add(stat.S_IFREG | 0644, empty_file_name, 
 
554
                Blob().id)
560
555
        else:
561
556
            return None
562
557
    return tree
585
580
        self.paths = None
586
581
        self.mapping = mapping
587
582
 
588
 
    def set_file_id(self, path, file_id):
589
 
        assert type(path) is str
590
 
        assert type(file_id) is str
591
 
        self.file_ids[path] = file_id
592
 
 
593
583
    def lookup_file_id(self, path):
594
584
        assert type(path) is str
595
585
        try:
611
601
        else:
612
602
            assert type(path) is str
613
603
            return path
614
 
 
615
 
    def copy(self):
616
 
        return self.__class__(dict(self.file_ids), self.mapping)