Rev 2172: Implement revision_history caching for RemoteBranch. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

Andrew Bennetts andrew.bennetts at canonical.com
Tue Mar 27 12:34:25 BST 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

------------------------------------------------------------
revno: 2172
revision-id: andrew.bennetts at canonical.com-20070327113312-l712t10dawjvdujb
parent: andrew.bennetts at canonical.com-20070327094624-jeh2g92906trijk3
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss
timestamp: Tue 2007-03-27 21:33:12 +1000
message:
  Implement revision_history caching for RemoteBranch.
modified:
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-03-16 01:27:33 +0000
+++ b/bzrlib/remote.py	2007-03-27 11:33:12 +0000
@@ -231,6 +231,9 @@
         assert response[0][0] in ('ok', 'nosuchrevision'), 'unexpected response code %s' % (response[0],)
         if response[0][0] == 'ok':
             coded = response[1].read_body_bytes()
+            if coded == '':
+                # no revisions in this repository!
+                return {}
             lines = coded.split('\n')
             revision_graph = {}
             # FIXME
@@ -621,6 +624,8 @@
             format, usually accessing the data via the VFS.
         :param _client: Private parameter for testing.
         """
+        #branch.Branch.__init__(self)
+        self._revision_history_cache = None
         self.bzrdir = remote_bzrdir
         if _client is not None:
             self._client = _client
@@ -753,6 +758,7 @@
     def unlock(self):
         self._lock_count -= 1
         if not self._lock_count:
+            self._clear_cached_state()
             mode = self._lock_mode
             self._lock_mode = None
             if self._real_branch is not None:
@@ -794,11 +800,8 @@
             last_revision = NULL_REVISION
         return (revno, last_revision)
 
-    def revision_history(self):
-        """See Branch.revision_history()."""
-        # XXX: TODO: this does not cache the revision history for the duration
-        # of a lock, which is a bug - see the code for regular branches
-        # for details.
+    def _gen_revision_history(self):
+        """See Branch._gen_revision_history()."""
         path = self.bzrdir._path_for_remote_call(self._client)
         response = self._client.call2('Branch.revision_history', path)
         assert response[0][0] == 'ok', 'unexpected response code %s' % (response[0],)
@@ -824,6 +827,7 @@
         else:
             assert response == ('ok',), (
                 'unexpected response code %r' % (response,))
+        self._cache_revision_history(rev_history)
 
     def get_parent(self):
         self._ensure_real()
@@ -869,6 +873,7 @@
 
     def set_last_revision_info(self, revno, revision_id):
         self._ensure_real()
+        self._clear_cached_state()
         return self._real_branch.set_last_revision_info(revno, revision_id)
 
     def generate_revision_history(self, revision_id, last_rev=None,




More information about the bazaar-commits mailing list