~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2007-10-22 01:23:51 UTC
  • mfrom: (2921.3.1 graph)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071022012351-16lm27an2lbzk038
Merge graph history-access bugfix.

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()
 
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
            #
 
391
            # XXX: update_basis_by_delta is slower at present because it works
 
392
            # on inventories, so this is not active until there's a native
 
393
            # dirstate implementation.
 
394
            ## self.work_tree.update_basis_by_delta(self.rev_id,
 
395
            ##      self._basis_delta)
383
396
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
384
397
            self.reporter.completed(new_revno, self.rev_id)
385
398
            self._process_post_hooks(old_revno, new_revno)
399
412
        # A merge with no effect on files
400
413
        if len(self.parents) > 1:
401
414
            return
402
 
        # work around the fact that a newly-initted tree does differ from its
403
 
        # basis
 
415
        # TODO: we could simplify this by using self._basis_delta.
 
416
 
 
417
        # The inital commit adds a root directory, but this in itself is not
 
418
        # a worthwhile commit.  
404
419
        if len(self.basis_inv) == 0 and len(self.builder.new_inventory) == 1:
405
420
            raise PointlessCommit()
406
421
        # Shortcut, if the number of entries changes, then we obviously have
633
648
        specific_files = self.specific_files
634
649
        mutter("Selecting files for commit with filter %s", specific_files)
635
650
 
636
 
        # Check and warn about old CommitBuilders
637
 
        if not self.builder.record_root_entry:
638
 
            symbol_versioning.warn('CommitBuilders should support recording'
639
 
                ' the root entry as of bzr 0.10.', DeprecationWarning, 
640
 
                stacklevel=1)
641
 
            self.builder.new_inventory.add(self.basis_inv.root.copy())
642
 
 
643
651
        # Build the new inventory
644
652
        self._populate_from_inventory(specific_files)
645
653
 
669
677
                    ie, self.parent_invs, path, self.basis_tree, None)
670
678
                if version_recorded:
671
679
                    self.any_entries_changed = True
 
680
                if delta: self._basis_delta.append(delta)
672
681
 
673
 
        # note that deletes have occurred
674
 
        if set(self.basis_inv._byid.keys()) - set(self.builder.new_inventory._byid.keys()):
 
682
    def _report_and_accumulate_deletes(self):
 
683
        # XXX: Could the list of deleted paths and ids be instead taken from
 
684
        # _populate_from_inventory?
 
685
        deleted_ids = set(self.basis_inv._byid.keys()) - \
 
686
            set(self.builder.new_inventory._byid.keys())
 
687
        if deleted_ids:
675
688
            self.any_entries_deleted = True
676
 
        # Report what was deleted.
677
 
        if self.any_entries_deleted and self.reporter.is_verbose():
678
 
            for path, ie in self.basis_inv.iter_entries():
679
 
                if ie.file_id not in self.builder.new_inventory:
680
 
                    self.reporter.deleted(path)
 
689
            deleted = [(self.basis_inv.id2path(file_id), file_id)
 
690
                for file_id in deleted_ids]
 
691
            deleted.sort()
 
692
            # XXX: this is not quite directory-order sorting
 
693
            for path, file_id in deleted:
 
694
                self._basis_delta.append((path, None, file_id, None))
 
695
                self.reporter.deleted(path)
681
696
 
682
697
    def _populate_from_inventory(self, specific_files):
683
698
        """Populate the CommitBuilder by walking the working tree inventory."""
694
709
        # XXX: Note that entries may have the wrong kind.
695
710
        entries = work_inv.iter_entries_by_dir(
696
711
            specific_file_ids=self.specific_file_ids, yield_parents=True)
697
 
        if not self.builder.record_root_entry:
698
 
            entries.next()
699
712
        for path, existing_ie in entries:
700
713
            file_id = existing_ie.file_id
701
714
            name = existing_ie.name
787
800
            ie.revision = None
788
801
        delta, version_recorded = self.builder.record_entry_contents(ie,
789
802
            self.parent_invs, path, self.work_tree, content_summary)
 
803
        if delta:
 
804
            self._basis_delta.append(delta)
790
805
        if version_recorded:
791
806
            self.any_entries_changed = True
792
807
        if report_changes: