177
177
self.basis_inv = self.basis_tree.inventory
179
179
self.pending_merges = self.branch.pending_merges()
180
if self.pending_merges:
181
raise NotImplementedError("sorry, can't commit merges to the weave format yet")
181
183
if self.rev_id is None:
182
184
self.rev_id = _gen_revision_id(self.branch, time.time())
273
275
def _store_file_text(self, file_id):
274
276
"""Store updated text for one modified or added file."""
275
note('store new text for {%s} in revision {%s}', id, self.rev_id)
277
note('store new text for {%s} in revision {%s}',
278
file_id, self.rev_id)
276
279
new_lines = self.work_tree.get_file(file_id).readlines()
277
self._add_text_to_weave(file_id, new_lines)
278
# update or add an entry
279
if file_id in self.new_inv:
280
if file_id in self.new_inv: # was in basis inventory
280
281
ie = self.new_inv[file_id]
281
282
assert ie.file_id == file_id
283
assert file_id in self.basis_inv
284
assert self.basis_inv[file_id].kind == 'file'
285
old_version = self.basis_inv[file_id].text_version
286
file_parents = [old_version]
287
else: # new in this revision
283
288
ie = self.work_inv[file_id].copy()
284
289
self.new_inv.add(ie)
290
assert file_id not in self.basis_inv
285
292
assert ie.kind == 'file'
293
self._add_text_to_weave(file_id, new_lines, file_parents)
286
294
# make a new inventory entry for this file, using whatever
287
295
# it had in the working copy, plus details on the new text
288
296
ie.text_sha1 = _sha_strings(new_lines)
291
299
ie.entry_version = self.rev_id
294
def _add_text_to_weave(self, file_id, new_lines):
302
def _add_text_to_weave(self, file_id, new_lines, parents):
295
303
weave_fn = self.branch.controlfilename(['weaves', file_id+'.weave'])
296
304
if os.path.exists(weave_fn):
297
305
w = read_weave(file(weave_fn, 'rb'))
300
308
# XXX: Should set the appropriate parents by looking for this file_id
301
309
# in all revision parents
302
w.add(self.rev_id, [], new_lines)
310
parent_idxs = map(w.lookup, parents)
311
w.add(self.rev_id, parent_idxs, new_lines)
303
312
af = AtomicFile(weave_fn)
305
314
write_weave_v5(w, af)