/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

set version to 0.6.3.

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