~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-26 23:30:56 UTC
  • mfrom: (2044.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060926233056-203e713964b2cd51
(Robert Collins) Forward merge from 0.11rc2 NEWS and performance-regression fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
            self._cleanup()
351
351
        return self.rev_id
352
352
 
 
353
    def _any_real_changes(self):
 
354
        """Are there real changes between new_inventory and basis?
 
355
 
 
356
        For trees without rich roots, inv.root.revision changes every commit.
 
357
        But if that is the only change, we want to treat it as though there
 
358
        are *no* changes.
 
359
        """
 
360
        new_entries = self.builder.new_inventory.iter_entries()
 
361
        basis_entries = self.basis_inv.iter_entries()
 
362
        new_path, new_root_ie = new_entries.next()
 
363
        basis_path, basis_root_ie = basis_entries.next()
 
364
 
 
365
        # This is a copy of InventoryEntry.__eq__ only leaving out .revision
 
366
        def ie_equal_no_revision(this, other):
 
367
            return ((this.file_id == other.file_id)
 
368
                    and (this.name == other.name)
 
369
                    and (this.symlink_target == other.symlink_target)
 
370
                    and (this.text_sha1 == other.text_sha1)
 
371
                    and (this.text_size == other.text_size)
 
372
                    and (this.text_id == other.text_id)
 
373
                    and (this.parent_id == other.parent_id)
 
374
                    and (this.kind == other.kind)
 
375
                    and (this.executable == other.executable)
 
376
                    )
 
377
        if not ie_equal_no_revision(new_root_ie, basis_root_ie):
 
378
            return True
 
379
 
 
380
        for new_ie, basis_ie in zip(new_entries, basis_entries):
 
381
            if new_ie != basis_ie:
 
382
                return True
 
383
 
 
384
        # No actual changes present
 
385
        return False
 
386
 
353
387
    def _check_pointless(self):
354
388
        if self.allow_pointless:
355
389
            return
356
390
        # A merge with no effect on files
357
391
        if len(self.parents) > 1:
358
392
            return
359
 
        # work around the fact that a newly-initted tree does differ from its
360
 
        # basis
 
393
        # Shortcut, if the number of entries changes, then we obviously have
 
394
        # a change
361
395
        if len(self.builder.new_inventory) != len(self.basis_inv):
362
396
            return
363
 
        if (len(self.builder.new_inventory) != 1 and
364
 
            self.builder.new_inventory != self.basis_inv):
 
397
        # If length == 1, then we only have the root entry. Which means
 
398
        # that there is no real difference (only the root could be different)
 
399
        if (len(self.builder.new_inventory) != 1 and self._any_real_changes()):
365
400
            return
366
401
        raise PointlessCommit()
367
402