/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2007-10-03 06:15:06 UTC
  • mfrom: (2879 +trunk)
  • mto: (2592.3.161 repository)
  • mto: This revision was merged to the branch mainline in revision 2880.
  • Revision ID: robertc@robertcollins.net-20071003061506-2hbze42e1sokni8j
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
289
289
 
290
290
            # If provided, ensure the specified files are versioned
291
291
            if self.specific_files is not None:
292
 
                # Note: This routine
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
297
 
                # again.
 
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
299
298
                # cheaply?
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.
653
653
                    continue
654
654
                if is_inside_any(specific_files, path):
 
655
                    # was inside the selected path, if not present it has been
 
656
                    # deleted so skip.
655
657
                    continue
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
668
672
 
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):
707
712
                continue
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)
712
 
                continue
713
 
            try:
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:
719
 
                pass
 
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)
 
719
                    continue
 
720
            # TODO: have the builder do the nested commit just-in-time IF and
 
721
            # only if needed.
 
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(
 
733
                        file_id, path)
 
734
                    content_summary = content_summary[:3] + (
 
735
                        nested_revision_id,)
 
736
                else:
 
737
                    content_summary = content_summary[:3] + (
 
738
                        self.work_tree.get_reference_revision(file_id),)
720
739
 
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,
 
747
                content_summary)
728
748
 
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
745
765
        try:
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:
755
 
            pass
 
775
            return self.work_tree.get_reference_revision(file_id)
756
776
 
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,
 
779
        content_summary):
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: