~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-26 06:24:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2376.
  • Revision ID: andrew.bennetts@canonical.com-20070326062401-k3nbefzje5332jaf
Deal with review comments from Robert:

  * Add my name to the NEWS file
  * Move the test case to a new module in branch_implementations
  * Remove revision_history cruft from identitymap and test_identitymap
  * Improve some docstrings

Also, this fixes a bug where revision_history was not returning a copy of the
cached data, allowing the cache to be corrupted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
322
322
        """
323
323
        self._revision_history_cache = rev_history
324
324
 
325
 
    def _clear_revision_history_cache(self):
326
 
        """Clear the cached revision history to rev_history.
 
325
    def _clear_cached_data(self):
 
326
        """Clear any cached data on this branch, e.g. cached revision history.
327
327
 
328
328
        This means the next call to revision_history will need to call
329
329
        _gen_revision_history.
340
340
        revision history, i.e. it does not cache the result, so repeated calls
341
341
        may be expensive.
342
342
 
343
 
        This is intended to be overridden by concrete subclasses, rather than
344
 
        overriding revision_history, so that subclasses do not need to deal with
345
 
        caching logic.
 
343
        Concrete subclasses should override this instead of revision_history so
 
344
        that subclasses do not need to deal with caching logic.
346
345
        
347
346
        This API is semi-public; it only for use by subclasses, all other code
348
347
        should consider it to be private.
357
356
        do so.
358
357
        """
359
358
        if self._revision_history_cache is not None:
360
 
            return self._revision_history_cache
361
 
        history = self._gen_revision_history()
362
 
        self._cache_revision_history(history)
 
359
            history = self._revision_history_cache
 
360
        else:
 
361
            history = self._gen_revision_history()
 
362
            self._cache_revision_history(history)
363
363
        return list(history)
364
364
 
365
365
    def revno(self):
1353
1353
            self.repository.unlock()
1354
1354
        if not self.control_files.is_locked():
1355
1355
            # we just released the lock
1356
 
            self._clear_revision_history_cache()
 
1356
            self._clear_cached_data()
1357
1357
        
1358
1358
    def peek_lock_mode(self):
1359
1359
        if self.control_files._lock_count == 0:
1929
1929
        if self._get_append_revisions_only():
1930
1930
            self._check_history_violation(revision_id)
1931
1931
        self._write_last_revision_info(revno, revision_id)
1932
 
        self._clear_revision_history_cache()
 
1932
        self._clear_cached_data()
1933
1933
 
1934
1934
    def _check_history_violation(self, revision_id):
1935
1935
        last_revision = self.last_revision()