279
282
self.work_inv = self.work_tree.inventory
280
283
self.basis_tree = self.work_tree.basis_tree()
281
284
self.basis_inv = self.basis_tree.inventory
285
if specific_files is not None:
286
# Ensure specified files are versioned
287
# (We don't actually need the ids here)
288
tree.find_ids_across_trees(specific_files,
289
[self.basis_tree, self.work_tree])
282
290
# one to finish, one for rev and inventory, and one for each
283
291
# inventory entry, and the same for the new inventory.
284
292
# note that this estimate is too long when we do a partial tree
326
334
# and now do the commit locally.
327
335
self.branch.append_revision(self.rev_id)
329
# if the builder gave us the revisiontree it created back, we
330
# could use it straight away here.
331
# TODO: implement this.
332
self.work_tree.set_parent_trees([(self.rev_id,
333
self.branch.repository.revision_tree(self.rev_id))])
337
rev_tree = self.builder.revision_tree()
338
self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
334
339
# now the work tree is up to date with the branch
336
341
self.reporter.completed(self.branch.revno(), self.rev_id)
348
353
return self.rev_id
355
def _any_real_changes(self):
356
"""Are there real changes between new_inventory and basis?
358
For trees without rich roots, inv.root.revision changes every commit.
359
But if that is the only change, we want to treat it as though there
362
new_entries = self.builder.new_inventory.iter_entries()
363
basis_entries = self.basis_inv.iter_entries()
364
new_path, new_root_ie = new_entries.next()
365
basis_path, basis_root_ie = basis_entries.next()
367
# This is a copy of InventoryEntry.__eq__ only leaving out .revision
368
def ie_equal_no_revision(this, other):
369
return ((this.file_id == other.file_id)
370
and (this.name == other.name)
371
and (this.symlink_target == other.symlink_target)
372
and (this.text_sha1 == other.text_sha1)
373
and (this.text_size == other.text_size)
374
and (this.text_id == other.text_id)
375
and (this.parent_id == other.parent_id)
376
and (this.kind == other.kind)
377
and (this.executable == other.executable)
379
if not ie_equal_no_revision(new_root_ie, basis_root_ie):
382
for new_ie, basis_ie in zip(new_entries, basis_entries):
383
if new_ie != basis_ie:
386
# No actual changes present
350
389
def _check_pointless(self):
351
390
if self.allow_pointless:
358
397
if len(self.basis_inv) == 0 and len(self.builder.new_inventory) == 1:
359
398
raise PointlessCommit()
399
# Shortcut, if the number of entries changes, then we obviously have
360
401
if len(self.builder.new_inventory) != len(self.basis_inv):
362
if (len(self.builder.new_inventory) != 1 and
363
self.builder.new_inventory != self.basis_inv):
403
# If length == 1, then we only have the root entry. Which means
404
# that there is no real difference (only the root could be different)
405
if (len(self.builder.new_inventory) != 1 and self._any_real_changes()):
365
407
raise PointlessCommit()