~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Vincent Ladeuil
  • Date: 2007-11-04 15:29:17 UTC
  • mfrom: (2961 +trunk)
  • mto: (2961.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2962.
  • Revision ID: v.ladeuil+lp@free.fr-20071104152917-nrsumxpk3dikso2c
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
# The newly committed revision is going to have a shape corresponding
19
 
# to that of the working inventory.  Files that are not in the
 
19
# to that of the working tree.  Files that are not in the
20
20
# working tree and that were in the predecessor are reported as
21
21
# removed --- this can include files that were either removed from the
22
22
# inventory or deleted in the working tree.  If they were only
25
25
# We then consider the remaining entries, which will be in the new
26
26
# version.  Directory entries are simply copied across.  File entries
27
27
# must be checked to see if a new version of the file should be
28
 
# recorded.  For each parent revision inventory, we check to see what
 
28
# recorded.  For each parent revision tree, we check to see what
29
29
# version of the file was present.  If the file was present in at
30
30
# least one tree, and if it was the same version in all the trees,
31
31
# then we can just refer to that version.  Otherwise, a new version
59
59
from bzrlib import (
60
60
    debug,
61
61
    errors,
62
 
    inventory,
 
62
    revision,
63
63
    tree,
64
64
    )
65
65
from bzrlib.branch import Branch
75
75
from bzrlib.testament import Testament
76
76
from bzrlib.trace import mutter, note, warning, is_quiet
77
77
from bzrlib.xml5 import serializer_v5
78
 
from bzrlib.inventory import Inventory, InventoryEntry
 
78
from bzrlib.inventory import InventoryEntry, make_entry
79
79
from bzrlib import symbol_versioning
80
80
from bzrlib.symbol_versioning import (deprecated_passed,
81
81
        deprecated_function,
269
269
 
270
270
        self.work_tree.lock_write()
271
271
        self.pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
272
        self.basis_revid = self.work_tree.last_revision()
272
273
        self.basis_tree = self.work_tree.basis_tree()
273
274
        self.basis_tree.lock_read()
274
275
        try:
414
415
            return
415
416
        # TODO: we could simplify this by using self._basis_delta.
416
417
 
417
 
        # The inital commit adds a root directory, but this in itself is not
418
 
        # a worthwhile commit.  
419
 
        if len(self.basis_inv) == 0 and len(self.builder.new_inventory) == 1:
 
418
        # The initial commit adds a root directory, but this in itself is not
 
419
        # a worthwhile commit.
 
420
        if (self.basis_revid == revision.NULL_REVISION and
 
421
            len(self.builder.new_inventory) == 1):
420
422
            raise PointlessCommit()
421
 
        # Shortcut, if the number of entries changes, then we obviously have
422
 
        # a change
423
 
        if len(self.builder.new_inventory) != len(self.basis_inv):
424
 
            return
425
423
        # If length == 1, then we only have the root entry. Which means
426
424
        # that there is no real difference (only the root could be different)
427
 
        if len(self.builder.new_inventory) != 1 and (self.any_entries_changed
428
 
            or self.any_entries_deleted):
 
425
        # unless deletes occured, in which case the length is irrelevant.
 
426
        if (self.any_entries_deleted or 
 
427
            (len(self.builder.new_inventory) != 1 and
 
428
             self.any_entries_changed)):
429
429
            return
430
430
        raise PointlessCommit()
431
431
 
686
686
            set(self.builder.new_inventory._byid.keys())
687
687
        if deleted_ids:
688
688
            self.any_entries_deleted = True
689
 
            deleted = [(self.basis_inv.id2path(file_id), file_id)
 
689
            deleted = [(self.basis_tree.id2path(file_id), file_id)
690
690
                for file_id in deleted_ids]
691
691
            deleted.sort()
692
692
            # XXX: this is not quite directory-order sorting
704
704
        report_changes = self.reporter.is_verbose()
705
705
        deleted_ids = []
706
706
        deleted_paths = set()
 
707
        # XXX: Note that entries may have the wrong kind because the entry does
 
708
        # not reflect the status on disk.
707
709
        work_inv = self.work_tree.inventory
708
 
        assert work_inv.root is not None
709
 
        # XXX: Note that entries may have the wrong kind.
710
710
        entries = work_inv.iter_entries_by_dir(
711
711
            specific_file_ids=self.specific_file_ids, yield_parents=True)
712
712
        for path, existing_ie in entries:
794
794
        # mutter('check %s {%s}', path, file_id)
795
795
        # mutter('%s selected for commit', path)
796
796
        if definitely_changed or existing_ie is None:
797
 
            ie = inventory.make_entry(kind, name, parent_id, file_id)
 
797
            ie = make_entry(kind, name, parent_id, file_id)
798
798
        else:
799
799
            ie = existing_ie.copy()
800
800
            ie.revision = None