39
39
def __init__(self, *args, **kwargs):
40
40
super(GitCommitBuilder, self).__init__(*args, **kwargs)
41
self.store = self.repository._git.object_store
44
def record_entry_contents(self, ie, parent_invs, path, tree,
46
raise NotImplementedError(self.record_entry_contents)
43
48
def record_delete(self, path, file_id):
44
49
self._blobs[path] = None
50
self._any_changes = True
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)
71
77
mode = stat.S_IFREG
72
78
sha = text_sha1(path[1], file_id)
79
elif kind[1] == "symlink":
74
80
mode = stat.S_IFLNK
75
81
sha = link_sha1(path[1], file_id)
83
raise AssertionError("Unknown kind %r" % kind[1])
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
91
def finish_inventory(self):
82
94
def commit(self, message):
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)