247
247
self.local = local
248
248
self.master_branch = None
249
249
self.master_locked = False
250
self.recursive = recursive
250
251
self.rev_id = None
251
252
if specific_files is not None:
252
253
self.specific_files = sorted(
255
256
self.specific_files = None
256
257
self.specific_file_ids = None
257
258
self.allow_pointless = allow_pointless
258
self.recursive = recursive
259
259
self.revprops = revprops
260
260
self.message_callback = message_callback
261
261
self.timestamp = timestamp
290
290
# If provided, ensure the specified files are versioned
291
291
if self.specific_files is not None:
293
# is being called because it raises PathNotVerisonedError
294
# as a side effect of finding the IDs. We later use the ids we
295
# found as input to the working tree inventory iterator, so we
296
# only consider those ids rather than examining the whole tree
292
# Note: This routine is being called because it raises
293
# PathNotVersionedError as a side effect of finding the IDs. We
294
# later use the ids we found as input to the working tree
295
# inventory iterator, so we only consider those ids rather than
296
# examining the whole tree again.
298
297
# XXX: Dont we have filter_unversioned to do this more
300
299
self.specific_file_ids = tree.find_ids_across_trees(
650
649
if specific_files:
651
650
for path, old_ie in self.basis_inv.iter_entries():
652
651
if old_ie.file_id in self.builder.new_inventory:
652
# already added - skip.
654
654
if is_inside_any(specific_files, path):
655
# was inside the selected path, if not present it has been
656
658
if old_ie.kind == 'directory':
657
659
self._next_progress_entry()
660
# not in final inv yet, was not in the selected files, so is an
661
# entry to be preserved unaltered.
658
662
ie = old_ie.copy()
659
663
# Note: specific file commits after a merge are currently
660
664
# prohibited. This test is for sanity/safety in case it's
662
666
if len(self.parents) > 1:
663
667
ie.revision = None
664
668
delta, version_recorded = self.builder.record_entry_contents(
665
ie, self.parent_invs, path, self.basis_tree)
669
ie, self.parent_invs, path, self.basis_tree, None)
666
670
if version_recorded:
667
671
self.any_entries_changed = True
687
691
deleted_paths = set()
688
692
work_inv = self.work_tree.inventory
689
693
assert work_inv.root is not None
694
# XXX: Note that entries may have the wrong kind.
690
695
entries = work_inv.iter_entries_by_dir(
691
696
specific_file_ids=self.specific_file_ids, yield_parents=True)
692
697
if not self.builder.record_root_entry:
705
710
# deleted files matching that filter.
706
711
if is_inside_any(deleted_paths, path):
708
if not self.work_tree.has_filename(path):
709
deleted_paths.add(path)
710
self.reporter.missing(path)
711
deleted_ids.append(file_id)
714
kind = self.work_tree.kind(file_id)
715
# TODO: specific_files filtering before nested tree processing
716
if kind == 'tree-reference' and self.recursive == 'down':
717
self._commit_nested_tree(file_id, path)
718
except errors.NoSuchFile:
713
content_summary = self.work_tree.path_content_summary(path)
714
if not specific_files or is_inside_any(specific_files, path):
715
if content_summary[0] == 'missing':
716
deleted_paths.add(path)
717
self.reporter.missing(path)
718
deleted_ids.append(file_id)
720
# TODO: have the builder do the nested commit just-in-time IF and
722
if content_summary[0] == 'tree-reference':
723
# enforce repository nested tree policy.
724
if (not self.work_tree.supports_tree_reference() or
725
# repository does not support it either.
726
not self.branch.repository._format.supports_tree_reference):
727
content_summary = ('directory',) + content_summary[1:]
728
kind = content_summary[0]
729
# TODO: specific_files filtering before nested tree processing
730
if kind == 'tree-reference':
731
if self.recursive == 'down':
732
nested_revision_id = self._commit_nested_tree(
734
content_summary = content_summary[:3] + (
737
content_summary = content_summary[:3] + (
738
self.work_tree.get_reference_revision(file_id),)
721
740
# Record an entry for this item
722
741
# Note: I don't particularly want to have the existing_ie
724
743
# without it thanks to a unicode normalisation issue. :-(
725
744
definitely_changed = kind != existing_ie.kind
726
745
self._record_entry(path, file_id, specific_files, kind, name,
727
parent_id, definitely_changed, existing_ie, report_changes)
746
parent_id, definitely_changed, existing_ie, report_changes,
729
749
# Unversion IDs that were found to be deleted
730
750
self.work_tree.unversion(deleted_ids)
743
763
sub_tree.branch.repository = \
744
764
self.work_tree.branch.repository
746
sub_tree.commit(message=None, revprops=self.revprops,
766
return sub_tree.commit(message=None, revprops=self.revprops,
747
767
recursive=self.recursive,
748
768
message_callback=self.message_callback,
749
769
timestamp=self.timestamp, timezone=self.timezone,
752
772
strict=self.strict, verbose=self.verbose,
753
773
local=self.local, reporter=self.reporter)
754
774
except errors.PointlessCommit:
775
return self.work_tree.get_reference_revision(file_id)
757
777
def _record_entry(self, path, file_id, specific_files, kind, name,
758
parent_id, definitely_changed, existing_ie=None,
759
report_changes=True):
778
parent_id, definitely_changed, existing_ie, report_changes,
760
780
"Record the new inventory entry for a path if any."
761
781
# mutter('check %s {%s}', path, file_id)
762
782
# mutter('%s selected for commit', path)
766
786
ie = existing_ie.copy()
767
787
ie.revision = None
768
788
delta, version_recorded = self.builder.record_entry_contents(ie,
769
self.parent_invs, path, self.work_tree)
789
self.parent_invs, path, self.work_tree, content_summary)
770
790
if version_recorded:
771
791
self.any_entries_changed = True
772
792
if report_changes: