109
108
# TODO: Rather than come up with something here, use the old index
110
109
file = StringIO()
111
110
stat_val = (0, 0, 0, 0, stat.S_IFREG | 0644, 0, 0, 0, 0, 0)
112
blob.set_raw_string(file.read())
111
blob._text = file.read()
113
112
elif entry.kind == "symlink":
116
stat_val = os.lstat(self.abspath(path))
117
except (errors.NoSuchFile, OSError):
118
# TODO: Rather than come up with something here, use the
120
stat_val = (0, 0, 0, 0, stat.S_IFLNK, 0, 0, 0, 0, 0)
121
blob.set_raw_string(entry.symlink_target)
114
stat_val = os.stat(self.abspath(path))
115
blob._text = entry.symlink_target
122
116
# Add object to the repository if it didn't exist yet
123
117
if not blob.id in self.repository._git.object_store:
124
118
self.repository._git.object_store.add_object(blob)
125
119
# Add an entry to the index or update the existing entry
127
self.index[path.encode("utf-8")] = (stat_val.st_ctime, stat_val.st_mtime, stat_val.st_dev, stat_val.st_ino, stat_val.st_mode, stat_val.st_uid, stat_val.st_gid, stat_val.st_size, blob.id, flags)
120
(mode, ino, dev, links, uid, gid, size, atime, mtime, ctime) = stat_val
122
self.index[path.encode("utf-8")] = (ctime, mtime, ino, dev, mode, uid, gid, size, blob.id, flags)
130
125
# TODO: Maybe this should only write on dirty ?
151
146
self._ignoreset = ignore_globs
152
147
return ignore_globs
154
def set_last_revision(self, revid):
155
self._change_last_revision(revid)
157
149
def _reset_data(self):
158
150
self._inventory_is_modified = False
159
151
basis_inv = self.repository.get_inventory(self.mapping.revision_id_foreign_to_bzr(self.repository._git.head()))
160
result = GitIndexInventory(basis_inv, self.mapping, self.index,
161
self.repository._git.object_store)
152
result = GitIndexInventory(basis_inv, self.mapping, self.index)
162
153
self._set_inventory(result, dirty=False)
167
158
path = self._inventory.id2path(file_id)
168
159
return osutils.sha_file_by_name(self.abspath(path).encode(osutils._fs_enc))
170
def iter_changes(self, from_tree, include_unchanged=False,
171
specific_files=None, pb=None, extra_trees=None,
172
require_versioned=True, want_unversioned=False):
174
intertree = tree.InterTree.get(from_tree, self)
175
return intertree.iter_changes(include_unchanged, specific_files, pb,
176
extra_trees, require_versioned, want_unversioned=want_unversioned)
179
162
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):