/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

Implement GitRevisionTree.get_file_sha1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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])
322
321
        rev.git_metadata = None
323
322
        def decode_using_encoding(rev, commit, encoding):
324
323
            rev.committer = str(commit.committer).decode(encoding)
349
348
            rev.properties['commit-timezone-neg-utc'] = ""
350
349
        rev.timestamp = commit.commit_time
351
350
        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])
362
364
        return rev, roundtrip_revid, verifiers
363
365
 
364
366
    def get_fileid_map(self, lookup_object, tree_sha):
546
548
            mode = entry_mode(ie)
547
549
        hexsha = lookup_ie_sha1(ie)
548
550
        if hexsha is not None:
549
 
            tree.add(mode, name.encode("utf-8"), hexsha)
 
551
            tree.add(name.encode("utf-8"), mode, hexsha)
550
552
    if entry.parent_id is not None and len(tree) == 0:
551
553
        # Only the root can be an empty tree
552
554
        if empty_file_name is not None:
553
 
            tree.add(stat.S_IFREG | 0644, empty_file_name, 
554
 
                Blob().id)
 
555
            tree.add(empty_file_name, stat.S_IFREG | 0644, Blob().id)
555
556
        else:
556
557
            return None
557
558
    return tree
580
581
        self.paths = None
581
582
        self.mapping = mapping
582
583
 
 
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
 
583
589
    def lookup_file_id(self, path):
584
590
        assert type(path) is str
585
591
        try:
601
607
        else:
602
608
            assert type(path) is str
603
609
            return path
 
610
 
 
611
    def copy(self):
 
612
        return self.__class__(dict(self.file_ids), self.mapping)