/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:
101
101
    BZR_DUMMY_FILE = None
102
102
 
103
103
    def __init__(self):
104
 
        super(BzrGitMapping, self).__init__(foreign_vcs_git)
 
104
        super(BzrGitMapping, self).__init__(foreign_git)
105
105
 
106
106
    def __eq__(self, other):
107
107
        return (type(self) == type(other) and
318
318
            raise AssertionError("Commit object can't be None")
319
319
        rev = ForeignRevision(commit.id, self,
320
320
                self.revision_id_foreign_to_bzr(commit.id))
 
321
        rev.parent_ids = tuple([lookup_parent_revid(p) for p in commit.parents])
321
322
        rev.git_metadata = None
322
323
        def decode_using_encoding(rev, commit, encoding):
323
324
            rev.committer = str(commit.committer).decode(encoding)
348
349
            rev.properties['commit-timezone-neg-utc'] = ""
349
350
        rev.timestamp = commit.commit_time
350
351
        rev.timezone = commit.commit_timezone
351
 
        rev.parent_ids = None
352
352
        if rev.git_metadata is not None:
353
353
            md = rev.git_metadata
354
354
            roundtrip_revid = md.revision_id
359
359
        else:
360
360
            roundtrip_revid = None
361
361
            verifiers = {}
362
 
        if rev.parent_ids is None:
363
 
            rev.parent_ids = tuple([lookup_parent_revid(p) for p in commit.parents])
364
362
        return rev, roundtrip_revid, verifiers
365
363
 
366
364
    def get_fileid_map(self, lookup_object, tree_sha):
464
462
        return { "git commit": foreign_revid }
465
463
 
466
464
 
467
 
foreign_vcs_git = ForeignGit()
 
465
foreign_git = ForeignGit()
468
466
default_mapping = mapping_registry.get_default()()
469
467
 
470
468
 
548
546
            mode = entry_mode(ie)
549
547
        hexsha = lookup_ie_sha1(ie)
550
548
        if hexsha is not None:
551
 
            tree.add(name.encode("utf-8"), mode, hexsha)
 
549
            tree.add(mode, name.encode("utf-8"), hexsha)
552
550
    if entry.parent_id is not None and len(tree) == 0:
553
551
        # Only the root can be an empty tree
554
552
        if empty_file_name is not None:
555
 
            tree.add(empty_file_name, stat.S_IFREG | 0644, Blob().id)
 
553
            tree.add(stat.S_IFREG | 0644, empty_file_name, 
 
554
                Blob().id)
556
555
        else:
557
556
            return None
558
557
    return tree
581
580
        self.paths = None
582
581
        self.mapping = mapping
583
582
 
584
 
    def set_file_id(self, path, file_id):
585
 
        assert type(path) is str
586
 
        assert type(file_id) is str
587
 
        self.file_ids[path] = file_id
588
 
 
589
583
    def lookup_file_id(self, path):
590
584
        assert type(path) is str
591
585
        try:
607
601
        else:
608
602
            assert type(path) is str
609
603
            return path
610
 
 
611
 
    def copy(self):
612
 
        return self.__class__(dict(self.file_ids), self.mapping)