~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-10-11 02:52:47 UTC
  • mfrom: (1417.1.13)
  • Revision ID: robertc@robertcollins.net-20051011025247-4b95466bb6509385
merge in revision-history caching, and tuning of fetch to not retrieve more data than needed when nothing needs to be pulled

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
            self._lock_count = 1
359
359
            self._set_transaction(transactions.PassThroughTransaction())
360
360
 
361
 
 
362
361
    def lock_read(self):
363
362
        mutter("lock read: %s (%s)", self, self._lock_count)
364
363
        if self._lock_mode:
371
370
            self._lock_mode = 'r'
372
371
            self._lock_count = 1
373
372
            self._set_transaction(transactions.ReadOnlyTransaction())
 
373
            # 5K may be excessive, but hey, its a knob.
 
374
            self.get_transaction().set_cache_size(5000)
374
375
                        
375
376
    def unlock(self):
376
377
        mutter("unlock: %s (%s)", self, self._lock_count)
876
877
        """Return sequence of revision hashes on to this branch."""
877
878
        self.lock_read()
878
879
        try:
879
 
            return [l.rstrip('\r\n') for l in
 
880
            transaction = self.get_transaction()
 
881
            history = transaction.map.find_revision_history()
 
882
            if history is not None:
 
883
                mutter("cache hit for revision-history in %s", self)
 
884
                return list(history)
 
885
            history = [l.rstrip('\r\n') for l in
880
886
                    self.controlfile('revision-history', 'r').readlines()]
 
887
            transaction.map.add_revision_history(history)
 
888
            # this call is disabled because revision_history is 
 
889
            # not really an object yet, and the transaction is for objects.
 
890
            # transaction.register_clean(history, precious=True)
 
891
            return list(history)
881
892
        finally:
882
893
            self.unlock()
883
894