71
from bzrlib.osutils import (kind_marker, isdir,isfile, is_inside_any,
71
from bzrlib.osutils import (kind_marker, isdir,isfile, is_inside_any,
72
72
is_inside_or_parent_of_any,
73
minimum_path_selection,
73
74
quotefn, sha_file, split_lines)
74
75
from bzrlib.testament import Testament
75
76
from bzrlib.trace import mutter, note, warning, is_quiet
245
246
self.master_branch = None
246
247
self.master_locked = False
247
248
self.rev_id = None
248
self.specific_files = specific_files
249
self.specific_files = sorted(
250
minimum_path_selection(specific_files or ()))
251
self.specific_file_ids = None
249
252
self.allow_pointless = allow_pointless
250
253
self.recursive = recursive
251
254
self.revprops = revprops
280
283
self.config = self.branch.get_config()
282
285
# If provided, ensure the specified files are versioned
283
if specific_files is not None:
284
# Note: We don't actually need the IDs here. This routine
286
if self.specific_files:
285
288
# is being called because it raises PathNotVerisonedError
286
# as a side effect of finding the IDs.
289
# as a side effect of finding the IDs. We later use the ids we
290
# found as input to the workng tree inventory iterator, so we
291
# only consider those ids rather than examining the whole tree
287
293
# XXX: Dont we have filter_unversioned to do this more
289
tree.find_ids_across_trees(specific_files,
290
[self.basis_tree, self.work_tree])
295
self.specific_file_ids = tree.find_ids_across_trees(
296
specific_files, [self.basis_tree, self.work_tree])
292
298
# Setup the progress bar. As the number of files that need to be
293
299
# committed in unknown, progress is reported as stages.
671
677
# recorded in their previous state. For more details, see
672
678
# https://lists.ubuntu.com/archives/bazaar/2007q3/028476.html.
673
679
if specific_files:
674
for path, new_ie in self.basis_inv.iter_entries():
675
if new_ie.file_id in self.builder.new_inventory:
680
for path, old_ie in self.basis_inv.iter_entries():
681
if old_ie.file_id in self.builder.new_inventory:
677
683
if is_inside_any(specific_files, path):
685
if old_ie.kind == 'directory':
686
self._next_progress_entry()
681
688
self.builder.record_entry_contents(ie, self.parent_invs, path,
699
706
deleted_paths = set()
700
707
work_inv = self.work_tree.inventory
701
708
assert work_inv.root is not None
702
entries = work_inv.iter_entries()
709
entries = work_inv.iter_entries_by_dir(
710
specific_file_ids=self.specific_file_ids, yield_parents=True)
703
711
if not self.builder.record_root_entry:
705
713
for path, existing_ie in entries:
717
724
# deleted files matching that filter.
718
725
if is_inside_any(deleted_paths, path):
720
if not specific_files or is_inside_any(specific_files, path):
721
if not self.work_tree.has_filename(path):
722
deleted_paths.add(path)
723
self.reporter.missing(path)
724
deleted_ids.append(file_id)
727
if not self.work_tree.has_filename(path):
728
deleted_paths.add(path)
729
self.reporter.missing(path)
730
deleted_ids.append(file_id)
727
733
kind = self.work_tree.kind(file_id)
728
734
# TODO: specific_files filtering before nested tree processing
772
778
report_changes=True):
773
779
"Record the new inventory entry for a path if any."
774
780
# mutter('check %s {%s}', path, file_id)
775
if (not specific_files or
776
is_inside_or_parent_of_any(specific_files, path)):
777
# mutter('%s selected for commit', path)
778
if definitely_changed or existing_ie is None:
779
ie = inventory.make_entry(kind, name, parent_id, file_id)
781
ie = existing_ie.copy()
781
# mutter('%s selected for commit', path)
782
if definitely_changed or existing_ie is None:
783
ie = inventory.make_entry(kind, name, parent_id, file_id)
784
# mutter('%s not selected for commit', path)
785
if self.basis_inv.has_id(file_id):
786
ie = self.basis_inv[file_id].copy()
788
# this entry is new and not being committed
791
self.builder.record_entry_contents(ie, self.parent_invs,
792
path, self.work_tree)
794
self._report_change(ie, path)
785
ie = existing_ie.copy()
787
self.builder.record_entry_contents(ie, self.parent_invs,
788
path, self.work_tree)
790
self._report_change(ie, path)
797
793
def _report_change(self, ie, path):