In debugging this, the first time it actually opens a connection is in the
BzrDir.open_from_transport() call. Because the Transport doesn't connect until necessary.
The second time is in BzrDir.clone() which calls self._make_tail(). _make_tail() also *only* works in a URL, not a Transport, so it has to create a new connection.
The final connection is BzrDir.clone() at self._format.initialize() Which also uses only a URL.
After that initialize we have an actual BzrDir object, so it maintains a transport which gets re-used.
The fix which seems most reasonable is to:
1) Update BzrDir.clone() to take a transport
2) Fix BzrDir._make_tail() to use a transport rather than a URL
3) Use BzrDirFormat.initialize_on_transport() rather than initialize()
In debugging this, the first time it actually opens a connection is in the open_from_ transport( ) call. Because the Transport doesn't connect until necessary.
BzrDir.
The second time is in BzrDir.clone() which calls self._make_tail(). _make_tail() also *only* works in a URL, not a Transport, so it has to create a new connection.
The final connection is BzrDir.clone() at self._format. initialize( ) Which also uses only a URL.
After that initialize we have an actual BzrDir object, so it maintains a transport which gets re-used.
The fix which seems most reasonable is to:
1) Update BzrDir.clone() to take a transport initialize_ on_transport( ) rather than initialize()
2) Fix BzrDir._make_tail() to use a transport rather than a URL
3) Use BzrDirFormat.