Rev 2529: Explain that we share connection and credentials (from in http://bazaar.launchpad.net/~bzr/bzr/bzr.connection.sharing

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Jun 8 17:07:53 BST 2007


At http://bazaar.launchpad.net/~bzr/bzr/bzr.connection.sharing

------------------------------------------------------------
revno: 2529
revision-id: v.ladeuil+lp at free.fr-20070608160750-pr023mg4apgxb2us
parent: v.ladeuil+lp at free.fr-20070608121205-3yf92bbzzca9tgpm
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: bzr.connection.sharing
timestamp: Fri 2007-06-08 18:07:50 +0200
message:
  Explain that we share connection and credentials (from
  jam-back-to-the-future remarks preceding review).
  
  * bzrlib/transport/__init__.py:
  (ConnectedTransport): Rename _connection to _connection_sharing to
  undelrline the fact that we share the connection *and* the
  associated credentials.
modified:
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
-------------- next part --------------
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-06-08 12:12:05 +0000
+++ b/bzrlib/transport/__init__.py	2007-06-08 16:07:50 +0000
@@ -1072,11 +1072,11 @@
 
         super(ConnectedTransport, self).__init__(base)
         if from_transport is None:
-            self._init_connection()
+            self._init_connection_sharing()
         else:
             # set_connection MUST not be used here, see set_connection for an
             # explanation
-            self._connection = from_transport._connection
+            self._connection_sharing = from_transport._connection_sharing
 
     def clone(self, offset=None):
         """Return a new transport with root at self.base + offset
@@ -1215,8 +1215,10 @@
         remote_path = self._combine_paths(self._path, relative)
         return remote_path
 
-    def _init_connection(self):
-        self._connection = [(None, None)]
+    def _init_connection_sharing(self):
+        # Note: What we share is really the connection itself and any
+        # credentials that may be needed to create a new one.
+        self._connection_sharing = [(None, None)]
 
     def _set_connection(self, connection, credentials=None):
         """Record a newly created connection with its associated credentials.
@@ -1237,16 +1239,16 @@
         # temporary failure. It also quarantee that the connection will still
         # be shared even if a transport is cloned before the first effective
         # connection (generally the first request) is made.
-        self._connection[0] = (connection, credentials)
+        self._connection_sharing[0] = (connection, credentials)
 
     def _get_connection(self):
         """Returns the transport specific connection object."""
-        return self._connection[0][0]
+        return self._connection_sharing[0][0]
 
     def _get_credentials(self):
         """Returns the credentials used to establish the connection."""
-        (connection, credentials) = self._connection[0]
-        return self._connection[0][1]
+        (connection, credentials) = self._connection_sharing[0]
+        return self._connection_sharing[0][1]
 
     def _update_credentials(self, credentials):
         """Update the credentials of the current connection.
@@ -1258,8 +1260,8 @@
         """
         # We don't want to call _set_connection here as we are only updating
         # the credentials not creating a new connection.
-        (connection, old_credentials) = self._connection[0]
-        self._connection[0] = (connection, credentials)
+        (connection, old_credentials) = self._connection_sharing[0]
+        self._connection_sharing[0] = (connection, credentials)
 
     def _reuse_for(self, other_base):
         """Returns a transport sharing the same connection if possible.



More information about the bazaar-commits mailing list