~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/remote.py

  • Committer: Vincent Ladeuil
  • Date: 2007-04-26 09:01:46 UTC
  • mfrom: (2420.2.2 bzr.http.auth)
  • mto: This revision was merged to the branch mainline in revision 2463.
  • Revision ID: v.ladeuil+lp@free.fr-20070426090146-jbwl0muvk76wlw6c
Merge spiv modifications

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib import (
30
30
    errors,
31
31
    transport,
 
32
    urlutils,
32
33
    )
33
34
from bzrlib.smart import client, medium, protocol
34
35
 
485
486
 
486
487
    def _remote_path(self, relpath):
487
488
        """After connecting HTTP Transport only deals in relative URLs."""
488
 
        if relpath == '.':
489
 
            return ''
490
 
        else:
491
 
            return relpath
 
489
        # Adjust the relpath based on which URL this smart transport is
 
490
        # connected to.
 
491
        base = self._http_transport.base
 
492
        url = urlutils.join(self.base[len('bzr+'):], relpath)
 
493
        url = urlutils.normalize_url(url)
 
494
        return urlutils.relative_url(base, url)
492
495
 
493
496
    def abspath(self, relpath):
494
497
        """Return the full url to the given relative path.
504
507
        This is re-implemented rather than using the default
505
508
        RemoteTransport.clone() because we must be careful about the underlying
506
509
        http transport.
 
510
 
 
511
        Also, the cloned smart transport will POST to the same .bzr/smart
 
512
        location as this transport (although obviously the relative paths in the
 
513
        smart requests may be different).  This is so that the server doesn't
 
514
        have to handle .bzr/smart requests at arbitrary places inside .bzr
 
515
        directories, just at the initial URL the user uses.
 
516
 
 
517
        The exception is parent paths (i.e. relative_url of "..").
507
518
        """
508
519
        if relative_url:
509
520
            abs_url = self.abspath(relative_url)
510
521
        else:
511
522
            abs_url = self.base
512
 
        # By cloning the underlying http_transport, we are able to share the
513
 
        # connection.
514
 
        new_transport = self._http_transport.clone(relative_url)
515
 
        return RemoteHTTPTransport(abs_url, http_transport=new_transport)
 
523
        # We either use the exact same http_transport (for child locations), or
 
524
        # a clone of the underlying http_transport (for parent locations).  This
 
525
        # means we share the connection.
 
526
        normalized_rel_url = urlutils.relative_url(self.base, abs_url)
 
527
        if normalized_rel_url == ".." or normalized_rel_url.startswith("../"):
 
528
            http_transport = self._http_transport.clone(normalized_rel_url)
 
529
        else:
 
530
            http_transport = self._http_transport
 
531
        return RemoteHTTPTransport(abs_url, http_transport=http_transport)
516
532
 
517
533
 
518
534
def get_test_permutations():