88
75
def record_iter_changes(self, workingtree, basis_revid, iter_changes):
90
for (file_id, path, changed_content, versioned, parent, name, kind,
91
executable) in iter_changes:
92
if kind[1] in ("directory",):
77
for change in iter_changes:
78
if change.kind == (None, None):
81
if change.versioned[0] and not change.copied:
82
file_id = self._mapping.generate_file_id(change.path[0])
83
elif change.versioned[1]:
84
file_id = self._mapping.generate_file_id(change.path[1])
88
parent_id_new = self._mapping.generate_file_id(osutils.dirname(change.path[1]))
91
if change.kind[1] in ("directory",):
93
92
self._inv_delta.append(
94
(path[0], path[1], file_id, entry_factory[kind[1]](
95
file_id, name[1], parent[1])))
96
if kind[0] in ("file", "symlink"):
97
self._blobs[path[0].encode("utf-8")] = None
93
(change.path[0], change.path[1], file_id,
94
entry_factory[change.kind[1]](
95
file_id, change.name[1], parent_id_new)))
96
if change.kind[0] in ("file", "symlink"):
97
self._blobs[encode_git_path(change.path[0])] = None
98
98
self._any_changes = True
99
if change.path[1] == "":
102
102
self._any_changes = True
104
self._inv_delta.append((path[0], path[1], file_id, None))
105
self._blobs[path[0].encode("utf-8")] = None
103
if change.path[1] is None:
104
self._inv_delta.append((change.path[0], change.path[1], file_id, None))
105
self._deleted_paths.add(encode_git_path(change.path[0]))
108
entry_kls = entry_factory[kind[1]]
108
entry_kls = entry_factory[change.kind[1]]
110
raise KeyError("unknown kind %s" % kind[1])
111
entry = entry_kls(file_id, name[1], parent[1])
112
if kind[1] == "file":
113
entry.executable = executable[1]
110
raise KeyError("unknown kind %s" % change.kind[1])
111
entry = entry_kls(file_id, change.name[1], parent_id_new)
112
if change.kind[1] == "file":
113
entry.executable = change.executable[1]
115
f, st = workingtree.get_file_with_stat(path[1])
115
f, st = workingtree.get_file_with_stat(change.path[1])
117
117
blob.data = f.read()
120
entry.text_size = len(blob.data)
121
entry.text_sha1 = osutils.sha_string(blob.data)
122
entry.text_size = st.st_size
124
entry.text_size = len(blob.data)
122
126
self.store.add_object(blob)
124
elif kind[1] == "symlink":
125
symlink_target = workingtree.get_symlink_target(path[1])
127
elif change.kind[1] == "symlink":
128
symlink_target = workingtree.get_symlink_target(change.path[1])
127
blob.data = symlink_target.encode("utf-8")
130
blob.data = encode_git_path(symlink_target)
128
131
self.store.add_object(blob)
130
133
entry.symlink_target = symlink_target
132
elif kind[1] == "tree-reference":
133
sha = read_submodule_head(workingtree.abspath(path[1]))
134
reference_revision = workingtree.get_reference_revision(path[1])
135
elif change.kind[1] == "tree-reference":
136
sha = read_submodule_head(workingtree.abspath(change.path[1]))
137
reference_revision = workingtree.get_reference_revision(change.path[1])
135
138
entry.reference_revision = reference_revision
138
raise AssertionError("Unknown kind %r" % kind[1])
139
mode = object_mode(kind[1], executable[1])
140
self._inv_delta.append((path[0], path[1], file_id, entry))
141
encoded_new_path = path[1].encode("utf-8")
142
self._blobs[encoded_new_path] = (mode, sha)
141
raise AssertionError("Unknown kind %r" % change.kind[1])
142
mode = object_mode(change.kind[1], change.executable[1])
143
self._inv_delta.append((change.path[0], change.path[1], file_id, entry))
144
if change.path[0] is not None:
145
self._deleted_paths.add(encode_git_path(change.path[0]))
146
self._blobs[encode_git_path(change.path[1])] = (mode, sha)
143
147
if st is not None:
144
yield file_id, path[1], (entry.text_sha1, st)
145
if self._mapping.generate_file_id(encoded_new_path) != file_id:
146
self._override_fileids[encoded_new_path] = file_id
148
self._override_fileids[encoded_new_path] = None
148
yield change.path[1], (entry.git_sha1, st)
149
149
if not seen_root and len(self.parents) == 0:
150
150
raise RootMissing()
151
151
if getattr(workingtree, "basis_tree", False):
160
160
for entry in basis_tree._iter_tree_contents(include_trees=False):
161
161
if entry.path in self._blobs:
163
if entry.path in self._deleted_paths:
163
165
self._blobs[entry.path] = (entry.mode, entry.sha)
166
fileid_map = dict(basis_tree._fileid_map.file_ids)
167
except AttributeError:
169
for path, file_id in viewitems(self._override_fileids):
170
if not isinstance(path, bytes):
171
raise TypeError(path)
173
if path in fileid_map:
176
if not isinstance(file_id, bytes):
177
raise TypeError(file_id)
178
fileid_map[path] = file_id
180
fileid_blob = self._mapping.export_fileid_map(fileid_map)
183
if fileid_blob is not None:
184
if self._mapping.BZR_FILE_IDS_FILE is None:
185
raise SettingCustomFileIdsUnsupported(fileid_map)
186
self.store.add_object(fileid_blob)
187
self._blobs[self._mapping.BZR_FILE_IDS_FILE] = (
188
stat.S_IFREG | 0o644, fileid_blob.id)
190
self._blobs[self._mapping.BZR_FILE_IDS_FILE] = None
191
166
self.new_inventory = None
193
168
def update_basis(self, tree):