/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: Ian Clatworthy
  • Date: 2007-07-13 05:36:39 UTC
  • mto: (2647.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2648.
  • Revision ID: ian.clatworthy@internode.on.net-20070713053639-m9c55376prkqzq3w
incorporate feedback from abentley

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
import bzrlib.config
66
66
from bzrlib.errors import (BzrError, PointlessCommit,
67
67
                           ConflictsInTree,
68
 
                           StrictCommitFailed,
69
 
                           NoSuchId
 
68
                           StrictCommitFailed
70
69
                           )
71
70
from bzrlib.osutils import (kind_marker, isdir,isfile, is_inside_any, 
72
71
                            is_inside_or_parent_of_any,
292
291
                raise errors.CannotCommitSelectedFileMerge(self.specific_files)
293
292
            
294
293
            # Collect the changes
295
 
            self._emit_progress_set_stage("Collecting changes",
 
294
            self._set_progress_stage("Collecting changes",
296
295
                    entries_title="Directory")
297
296
            self.builder = self.branch.get_commit_builder(self.parents,
298
297
                self.config, timestamp, timezone, committer, revprops, rev_id)
303
302
            # ADHB 2006-08-08: If this is done, populate_new_inv should not add
304
303
            # weave lines, because nothing should be recorded until it is known
305
304
            # that commit will succeed.
306
 
            self._emit_progress_set_stage("Saving data locally")
 
305
            self._set_progress_stage("Saving data locally")
307
306
            self.builder.finish_inventory()
308
307
 
309
308
            # Prompt the user for a commit message if none provided
318
317
            # Upload revision data to the master.
319
318
            # this will propagate merged revisions too if needed.
320
319
            if self.bound_branch:
321
 
                self._emit_progress_set_stage("Uploading data to master branch")
 
320
                self._set_progress_stage("Uploading data to master branch")
322
321
                self.master_branch.repository.fetch(self.branch.repository,
323
322
                                                    revision_id=self.rev_id)
324
323
                # now the master has the revision data
331
330
            self.branch.set_last_revision_info(new_revno, self.rev_id)
332
331
 
333
332
            # Make the working tree up to date with the branch
334
 
            self._emit_progress_set_stage("Updating the working tree")
 
333
            self._set_progress_stage("Updating the working tree")
335
334
            rev_tree = self.builder.revision_tree()
336
335
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
337
336
            self.reporter.completed(new_revno, self.rev_id)
464
463
    def _process_hooks(self, old_revno, new_revno):
465
464
        """Process any registered commit hooks."""
466
465
        # Process the post commit hooks, if any
467
 
        self._emit_progress_set_stage("Running post commit hooks")
 
466
        self._set_progress_stage("Running post commit hooks")
468
467
        # old style commit hooks - should be deprecated ? (obsoleted in
469
468
        # 0.15)
470
469
        if self.config.post_commit() is not None:
598
597
            self.builder.new_inventory.add(self.basis_inv.root.copy())
599
598
            root_added_already = True
600
599
 
601
 
        # Build the new inventory. _populate_from_tree() is the preferred
602
 
        # direction here but it doesn't support multiple parents yet,
603
 
        # it triggers a unicode normalisation issue in the test suite and
604
 
        # it needs more testing.
605
 
        populator = self._populate_from_inventory
606
 
        #if len(self.parents) == 1:
607
 
        #    populator = self._populate_from_tree
608
 
        populator(specific_files, root_added_already)
 
600
        # Build the new inventory
 
601
        self._populate_from_inventory(specific_files, root_added_already)
609
602
 
610
603
        # If specific files/directories were nominated, it is possible
611
604
        # that some data from outside those needs to be preserved from
651
644
            parent_id = new_ie.parent_id
652
645
            kind = new_ie.kind
653
646
            if kind == 'directory':
654
 
                self._emit_progress_next_entry()
 
647
                self._next_progress_entry()
655
648
 
656
649
            # Skip files that have been deleted from the working tree.
657
650
            # The deleted files/directories are also recorded so they
668
661
                    continue
669
662
            try:
670
663
                kind = self.work_tree.kind(file_id)
671
 
                # TODO: specific_files filtering before nested tree processing?
 
664
                # TODO: specific_files filtering before nested tree processing
672
665
                if kind == 'tree-reference' and self.recursive == 'down':
673
666
                    self._commit_nested_tree(path)
674
667
            except errors.NoSuchFile:
685
678
        # Unversion IDs that were found to be deleted
686
679
        self.work_tree.unversion(deleted_ids)
687
680
 
688
 
    def _populate_from_tree(self, specific_files, root_added_already):
689
 
        """Populate the CommitBuilder by walking the working tree."""
690
 
        # Until trees supports an "iter_commitable" iterator that
691
 
        # understand multiple parents, this assertion is required.
692
 
        assert len(self.parents) == 1
693
 
 
694
 
        deleted_ids = []
695
 
        deleted_paths = set()
696
 
        entries = self.work_tree._iter_changes(self.basis_tree,
697
 
            include_unchanged=True, want_unversioned=True,
698
 
            require_versioned=False)
699
 
        if root_added_already:
700
 
            entries.next()
701
 
        for entry in entries:
702
 
            (file_id, paths, changed_content, versioned_flags, parents, names,
703
 
                kinds, executables) = entry
704
 
            kind = kinds[1]
705
 
            if kind == 'directory':
706
 
                self._emit_progress_next_entry()
707
 
 
708
 
            # Skip unknowns unless strict mode
709
 
            if versioned_flags == (False,False):
710
 
                if self.strict:
711
 
                    raise StrictCommitFailed()
712
 
                else:
713
 
                    continue
714
 
 
715
 
            # Skip missing files (may auto-delete these one day)
716
 
            # Note that when a filter of specific files is given, we must
717
 
            # only skip/record deleted files matching that filter.
718
 
            if kind is None:
719
 
                path = paths[0]
720
 
                if is_inside_any(deleted_paths, path):
721
 
                    continue
722
 
                if not specific_files or is_inside_any(specific_files, path):
723
 
                    deleted_paths.add(path)
724
 
                    self.reporter.missing(path)
725
 
                    deleted_ids.append(file_id)
726
 
                    continue
727
 
                # It's missing but still needs to be recorded
728
 
                index = 0
729
 
            else:
730
 
                index = 1
731
 
            path = paths[index]
732
 
            kind = kinds[index]
733
 
            path = paths[index]
734
 
            parent = parents[index]
735
 
            name = names[index]
736
 
 
737
 
            # TODO: specific_files filtering before nested tree processing?
738
 
            # TODO: keep track of nested trees and don't recurse into them?
739
 
            if kind == 'tree-reference' and self.recursive == 'down':
740
 
                self._commit_nested_tree(path)
741
 
 
742
 
            # Record an entry for this item
743
 
            self._record_entry(path, file_id, specific_files, kind,
744
 
                name, parent, changed_content, None)
745
 
            # Note: If the iterator passed back the sha here we could
746
 
            # set it and the executable info *now* into the inventory entry
747
 
            # saving look ups later
748
 
 
749
 
        # Unversion IDs that were found to be deleted
750
 
        # Note: the logic above collects some IDs already gone so
751
 
        # we walk the list and trap the exception
752
 
        for id in deleted_ids:
753
 
            try:
754
 
                self.work_tree.unversion([id])
755
 
            except NoSuchId:
756
 
                pass
757
 
 
758
681
    def _commit_nested_tree(self, path):
759
682
        "Commit a nested tree."
760
683
        sub_tree = WorkingTree.open(self.work_tree.abspath(path))
824
747
        else:
825
748
            self.reporter.snapshot_change(change, path)
826
749
 
827
 
    def _emit_progress_set_stage(self, name, entries_title=None):
 
750
    def _set_progress_stage(self, name, entries_title=None):
828
751
        """Set the progress stage and emit an update to the progress bar."""
829
752
        self.pb_stage_name = name
830
753
        self.pb_stage_count += 1
834
757
            self.pb_entries_total = '?'
835
758
        self._emit_progress()
836
759
 
837
 
    def _emit_progress_next_entry(self):
838
 
        """Emit an update to the progress bar and increment the file count."""
 
760
    def _next_progress_entry(self):
 
761
        """Emit an update to the progress bar and increment the entry count."""
839
762
        self.pb_entries_count += 1
840
763
        self._emit_progress()
841
764