/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 commit.py

Fix a bunch of bugs in commit, partially works now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
    def __init__(self, *args, **kwargs):
40
40
        super(GitCommitBuilder, self).__init__(*args, **kwargs)
 
41
        self.store = self.repository._git.object_store
41
42
        self._blobs = {}
42
43
 
 
44
    def record_entry_contents(self, ie, parent_invs, path, tree,
 
45
        content_summary):
 
46
        raise NotImplementedError(self.record_entry_contents)        
 
47
 
43
48
    def record_delete(self, path, file_id):
44
49
        self._blobs[path] = None
 
50
        self._any_changes = True
45
51
 
46
52
    def record_iter_changes(self, workingtree, basis_revid, iter_changes):
47
53
        index = getattr(workingtree, "index", None)
67
73
            if path[1] is None:
68
74
                self.record_delete(path[0], file_id)
69
75
                continue
70
 
            if kind == "file":
 
76
            if kind[1] == "file":
71
77
                mode = stat.S_IFREG
72
78
                sha = text_sha1(path[1], file_id)
73
 
            else:
 
79
            elif kind[1] == "symlink":
74
80
                mode = stat.S_IFLNK
75
81
                sha = link_sha1(path[1], file_id)
 
82
            else:
 
83
                raise AssertionError("Unknown kind %r" % kind[1])
76
84
            if executable:
77
85
                mode |= 0111
 
86
            self._any_changes = True
78
87
            self._blobs[path[1].encode("utf-8")] = (mode, sha)
79
88
            yield file_id, path, (None, None)
80
89
        # FIXME: Import all blobs not set yet, and eliminate blobs set to None
81
90
 
 
91
    def finish_inventory(self):
 
92
        pass
 
93
 
82
94
    def commit(self, message):
83
95
        c = Commit()
84
 
        c.tree = commit_tree(self.repository._git.object_store, self._blobs)
 
96
        c.parents = [self.repository.lookup_git_revid(revid)[0] for revid in self.parents]
 
97
        c.tree = commit_tree(self.store, 
 
98
                [(path, sha, mode) for (path, (mode, sha)) in self._blobs.iteritems()])
85
99
        c.committer = self._committer
86
100
        c.author = self._revprops.get('author', self._committer)
87
 
        c.commit_timestamp = self._timestamp
88
 
        c.author_timestamp = self._timestamp
 
101
        c.commit_time = int(self._timestamp)
 
102
        c.author_time = int(self._timestamp)
89
103
        c.commit_timezone = self._timezone
90
104
        c.author_timezone = self._timezone
91
105
        c.message = message.encode("utf-8")
92
 
        self.repository._git.object_store.add_object(c)
93
 
        return self.repository.mapping.revision_id_foreign_to_bzr(c.id)
 
106
        self.store.add_object(c)
 
107
        return self.repository.get_mapping().revision_id_foreign_to_bzr(c.id)