/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: Martin Pool
  • Date: 2007-10-12 02:50:39 UTC
  • mto: This revision was merged to the branch mainline in revision 2913.
  • Revision ID: mbp@sourcefrog.net-20071012025039-0i3zvyrxvqdr6dw4
Commit now tells the working tree about the new basis by passing the an inventory delta from the previous basis

Show diffs side-by-side

added added

removed removed

Lines of Context:
263
263
        self.committer = committer
264
264
        self.strict = strict
265
265
        self.verbose = verbose
 
266
        # accumulates an inventory delta to the basis entry, so we can make
 
267
        # just the necessary updates to the workingtree's cached basis.
 
268
        self.basis_delta = []
266
269
 
267
270
        self.work_tree.lock_write()
268
271
        self.pb = bzrlib.ui.ui_factory.nested_progress_bar()
338
341
                self.reporter.started(new_revno, self.rev_id, master_location)
339
342
 
340
343
                self._update_builder_with_changes()
 
344
                self._report_and_accumulate_deletes()
341
345
                self._check_pointless()
342
346
 
343
347
                # TODO: Now the new inventory is known, check for conflicts.
380
384
            # Make the working tree up to date with the branch
381
385
            self._set_progress_stage("Updating the working tree")
382
386
            rev_tree = self.builder.revision_tree()
383
 
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
 
387
            # XXX: This will need to be changed if we support doing a
 
388
            # selective commit while a merge is still pending - then we'd
 
389
            # still have multiple parents after the commit.
 
390
            self.work_tree.update_to_one_parent_via_delta(self.rev_id,
 
391
                self.basis_delta)
384
392
            self.reporter.completed(new_revno, self.rev_id)
385
393
            self._process_post_hooks(old_revno, new_revno)
386
394
        finally:
670
678
                if version_recorded:
671
679
                    self.any_entries_changed = True
672
680
 
673
 
        # note that deletes have occurred
674
 
        if set(self.basis_inv._byid.keys()) - set(self.builder.new_inventory._byid.keys()):
 
681
    def _report_and_accumulate_deletes(self):
 
682
        deleted_ids = set(self.basis_inv._byid.keys()) - \
 
683
            set(self.builder.new_inventory._byid.keys())
 
684
        if deleted_ids:
675
685
            self.any_entries_deleted = True
676
 
        # Report what was deleted.
677
 
        if self.any_entries_deleted and self.reporter.is_verbose():
 
686
            # TODO: better to just look up the paths for particular things we
 
687
            # care about?  probably the common case is that most of the tree
 
688
            # is not deleted.
678
689
            for path, ie in self.basis_inv.iter_entries():
679
 
                if ie.file_id not in self.builder.new_inventory:
 
690
                if ie.file_id in deleted_ids:
 
691
                    self.basis_delta.append((path, None, ie.file_id, None))
680
692
                    self.reporter.deleted(path)
681
693
 
682
694
    def _populate_from_inventory(self, specific_files):
716
728
                    deleted_paths.add(path)
717
729
                    self.reporter.missing(path)
718
730
                    deleted_ids.append(file_id)
 
731
                    # Missing entries need to be deleted from the working
 
732
                    # inventory separately from files that were specifically
 
733
                    # removed.  Note: this doesn't include missing files
 
734
                    # within missing directories, but they should be
 
735
                    # implicitly deleted when the delta is applied.
 
736
                    self.basis_delta.append((path, None, file_id, None))
719
737
                    continue
720
738
            # TODO: have the builder do the nested commit just-in-time IF and
721
739
            # only if needed.
787
805
            ie.revision = None
788
806
        delta, version_recorded = self.builder.record_entry_contents(ie,
789
807
            self.parent_invs, path, self.work_tree, content_summary)
 
808
        if delta:
 
809
            self.basis_delta.append(delta)
790
810
        if version_recorded:
791
811
            self.any_entries_changed = True
792
812
        if report_changes: