74
75
def record_iter_changes(self, workingtree, basis_revid, iter_changes):
76
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]))
77
91
if change.kind[1] in ("directory",):
78
92
self._inv_delta.append(
79
(change.path[0], change.path[1], change.file_id,
93
(change.path[0], change.path[1], file_id,
80
94
entry_factory[change.kind[1]](
81
change.file_id, change.name[1], change.parent_id[1])))
95
file_id, change.name[1], parent_id_new)))
82
96
if change.kind[0] in ("file", "symlink"):
83
self._blobs[change.path[0].encode("utf-8")] = None
97
self._blobs[encode_git_path(change.path[0])] = None
84
98
self._any_changes = True
85
99
if change.path[1] == "":
88
102
self._any_changes = True
89
103
if change.path[1] is None:
90
self._inv_delta.append((change.path[0], change.path[1], change.file_id, None))
91
self._deleted_paths.add(change.path[0].encode("utf-8"))
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]))
94
108
entry_kls = entry_factory[change.kind[1]]
96
110
raise KeyError("unknown kind %s" % change.kind[1])
97
entry = entry_kls(change.file_id, change.name[1], change.parent_id[1])
111
entry = entry_kls(file_id, change.name[1], parent_id_new)
98
112
if change.kind[1] == "file":
99
113
entry.executable = change.executable[1]
103
117
blob.data = f.read()
106
entry.text_size = len(blob.data)
107
entry.text_sha1 = osutils.sha_string(blob.data)
122
entry.text_size = st.st_size
124
entry.text_size = len(blob.data)
108
126
self.store.add_object(blob)
110
127
elif change.kind[1] == "symlink":
111
128
symlink_target = workingtree.get_symlink_target(change.path[1])
113
blob.data = symlink_target.encode("utf-8")
130
blob.data = encode_git_path(symlink_target)
114
131
self.store.add_object(blob)
116
133
entry.symlink_target = symlink_target
124
141
raise AssertionError("Unknown kind %r" % change.kind[1])
125
142
mode = object_mode(change.kind[1], change.executable[1])
126
self._inv_delta.append((change.path[0], change.path[1], change.file_id, entry))
143
self._inv_delta.append((change.path[0], change.path[1], file_id, entry))
127
144
if change.path[0] is not None:
128
self._deleted_paths.add(change.path[0].encode("utf-8"))
129
self._blobs[change.path[1].encode("utf-8")] = (mode, sha)
145
self._deleted_paths.add(encode_git_path(change.path[0]))
146
self._blobs[encode_git_path(change.path[1])] = (mode, sha)
130
147
if st is not None:
131
yield change.path[1], (entry.text_sha1, st)
148
yield change.path[1], (entry.git_sha1, st)
132
149
if not seen_root and len(self.parents) == 0:
133
150
raise RootMissing()
134
151
if getattr(workingtree, "basis_tree", False):