241
241
" parameter is required for commit().")
243
243
self.bound_branch = None
244
self.entries_changed = False
245
self.entries_deleted = False
244
246
self.local = local
245
247
self.master_branch = None
246
248
self.master_locked = False
383
385
return NullCommitReporter()
384
386
return ReportCommitToLog()
386
def _any_real_changes(self):
387
"""Are there real changes between new_inventory and basis?
389
For trees without rich roots, inv.root.revision changes every commit.
390
But if that is the only change, we want to treat it as though there
393
new_entries = self.builder.new_inventory.iter_entries()
394
basis_entries = self.basis_inv.iter_entries()
395
new_path, new_root_ie = new_entries.next()
396
basis_path, basis_root_ie = basis_entries.next()
398
# This is a copy of InventoryEntry.__eq__ only leaving out .revision
399
def ie_equal_no_revision(this, other):
400
return ((this.file_id == other.file_id)
401
and (this.name == other.name)
402
and (this.symlink_target == other.symlink_target)
403
and (this.text_sha1 == other.text_sha1)
404
and (this.text_size == other.text_size)
405
and (this.text_id == other.text_id)
406
and (this.parent_id == other.parent_id)
407
and (this.kind == other.kind)
408
and (this.executable == other.executable)
409
and (this.reference_revision == other.reference_revision)
411
if not ie_equal_no_revision(new_root_ie, basis_root_ie):
414
for new_ie, basis_ie in zip(new_entries, basis_entries):
415
if new_ie != basis_ie:
418
# No actual changes present
421
388
def _check_pointless(self):
422
389
if self.allow_pointless:
435
402
# If length == 1, then we only have the root entry. Which means
436
403
# that there is no real difference (only the root could be different)
437
if (len(self.builder.new_inventory) != 1 and self._any_real_changes()):
404
if len(self.builder.new_inventory) != 1 and (self.entries_changed or
405
self.entries_deleted):
439
407
raise PointlessCommit()
679
647
ie = new_ie.copy()
680
648
ie.revision = None
681
self.builder.record_entry_contents(ie, self.parent_invs, path,
649
if self.builder.record_entry_contents(ie, self.parent_invs, path,
651
self.entries_changed = True
653
# note that deletes have occured
654
if set(self.basis_inv._byid.keys()) - set(self.builder.new_inventory._byid.keys()):
655
self.entries_deleted = True
684
656
# Report what was deleted.
685
if self.reporter.is_verbose():
657
if self.entries_deleted and self.reporter.is_verbose():
686
658
for path, ie in self.basis_inv.iter_entries():
687
659
if ie.file_id not in self.builder.new_inventory:
688
660
self.reporter.deleted(path)
735
707
# Note: I don't particularly want to have the existing_ie
736
708
# parameter but the test suite currently (28-Jun-07) breaks
737
709
# without it thanks to a unicode normalisation issue. :-(
738
definitely_changed = kind != existing_ie.kind
710
definitely_changed = kind != existing_ie.kind
739
711
self._record_entry(path, file_id, specific_files, kind, name,
740
712
parent_id, definitely_changed, existing_ie, report_changes)
766
738
local=self.local, reporter=self.reporter)
767
739
except errors.PointlessCommit:
742
self.entries_changed = True
770
744
def _record_entry(self, path, file_id, specific_files, kind, name,
771
745
parent_id, definitely_changed, existing_ie=None,
788
762
# this entry is new and not being committed
790
764
if ie is not None:
791
self.builder.record_entry_contents(ie, self.parent_invs,
792
path, self.work_tree)
765
if self.builder.record_entry_contents(ie, self.parent_invs,
766
path, self.work_tree):
767
self.entries_changed = True
793
768
if report_changes:
794
769
self._report_change(ie, path)