~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Andrew Bennetts
  • Date: 2007-11-10 15:09:09 UTC
  • mfrom: (2916.2.17 streamable-containers)
  • mto: This revision was merged to the branch mainline in revision 3174.
  • Revision ID: andrew.bennetts@canonical.com-20071110150909-ik5254kgn930th10
Merge streamable-containers.

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:
383
384
 
384
385
            # Make the working tree up to date with the branch
385
386
            self._set_progress_stage("Updating the working tree")
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)
396
 
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
 
387
            self.work_tree.update_basis_by_delta(self.rev_id,
 
388
                 self._basis_delta)
397
389
            self.reporter.completed(new_revno, self.rev_id)
398
390
            self._process_post_hooks(old_revno, new_revno)
399
391
        finally:
414
406
            return
415
407
        # TODO: we could simplify this by using self._basis_delta.
416
408
 
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:
 
409
        # The initial commit adds a root directory, but this in itself is not
 
410
        # a worthwhile commit.
 
411
        if (self.basis_revid == revision.NULL_REVISION and
 
412
            len(self.builder.new_inventory) == 1):
420
413
            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
414
        # If length == 1, then we only have the root entry. Which means
426
415
        # 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):
 
416
        # unless deletes occured, in which case the length is irrelevant.
 
417
        if (self.any_entries_deleted or 
 
418
            (len(self.builder.new_inventory) != 1 and
 
419
             self.any_entries_changed)):
429
420
            return
430
421
        raise PointlessCommit()
431
422
 
686
677
            set(self.builder.new_inventory._byid.keys())
687
678
        if deleted_ids:
688
679
            self.any_entries_deleted = True
689
 
            deleted = [(self.basis_inv.id2path(file_id), file_id)
 
680
            deleted = [(self.basis_tree.id2path(file_id), file_id)
690
681
                for file_id in deleted_ids]
691
682
            deleted.sort()
692
683
            # XXX: this is not quite directory-order sorting
704
695
        report_changes = self.reporter.is_verbose()
705
696
        deleted_ids = []
706
697
        deleted_paths = set()
 
698
        # XXX: Note that entries may have the wrong kind because the entry does
 
699
        # not reflect the status on disk.
707
700
        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
701
        entries = work_inv.iter_entries_by_dir(
711
702
            specific_file_ids=self.specific_file_ids, yield_parents=True)
712
703
        for path, existing_ie in entries:
794
785
        # mutter('check %s {%s}', path, file_id)
795
786
        # mutter('%s selected for commit', path)
796
787
        if definitely_changed or existing_ie is None:
797
 
            ie = inventory.make_entry(kind, name, parent_id, file_id)
 
788
            ie = make_entry(kind, name, parent_id, file_id)
798
789
        else:
799
790
            ie = existing_ie.copy()
800
791
            ie.revision = None