~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Robert Collins
  • Date: 2007-05-07 16:48:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2485.
  • Revision ID: robertc@robertcollins.net-20070507164814-wpagonutf4b5cf8s
Move HACKING to docs/developers/HACKING and adjust Makefile to accomodate this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
        if offset is None:
76
76
            return LocalTransport(self.base)
77
77
        else:
78
 
            return LocalTransport(self.abspath(offset))
 
78
            abspath = self.abspath(offset)
 
79
            if abspath == 'file://':
 
80
                # fix upwalk for UNC path
 
81
                # when clone from //HOST/path updir recursively
 
82
                # we should stop at least at //HOST part
 
83
                abspath = self.base
 
84
            return LocalTransport(abspath)
79
85
 
80
86
    def _abspath(self, relative_reference):
81
87
        """Return a path for use in os calls.
474
480
            return True
475
481
 
476
482
 
 
483
class EmulatedWin32LocalTransport(LocalTransport):
 
484
    """Special transport for testing Win32 [UNC] paths on non-windows"""
 
485
 
 
486
    def __init__(self, base):
 
487
        if base[-1] != '/':
 
488
            base = base + '/'
 
489
        super(LocalTransport, self).__init__(base)
 
490
        self._local_base = urlutils._win32_local_path_from_url(base)
 
491
 
 
492
    def abspath(self, relpath):
 
493
        assert isinstance(relpath, basestring), (type(relpath), relpath)
 
494
        path = osutils.normpath(osutils.pathjoin(
 
495
                    self._local_base, urlutils.unescape(relpath)))
 
496
        return urlutils._win32_local_path_to_url(path)
 
497
 
 
498
    def clone(self, offset=None):
 
499
        """Return a new LocalTransport with root at self.base + offset
 
500
        Because the local filesystem does not require a connection, 
 
501
        we can just return a new object.
 
502
        """
 
503
        if offset is None:
 
504
            return EmulatedWin32LocalTransport(self.base)
 
505
        else:
 
506
            abspath = self.abspath(offset)
 
507
            if abspath == 'file://':
 
508
                # fix upwalk for UNC path
 
509
                # when clone from //HOST/path updir recursively
 
510
                # we should stop at least at //HOST part
 
511
                abspath = self.base
 
512
            return EmulatedWin32LocalTransport(abspath)
 
513
 
 
514
 
477
515
class LocalURLServer(Server):
478
516
    """A pretend server for local transports, using file:// urls.
479
517
    
481
519
    this just exists to tell the test code how to get to it.
482
520
    """
483
521
 
 
522
    def setUp(self):
 
523
        """Setup the server to service requests.
 
524
        
 
525
        :param decorated_transport: ignored by this implementation.
 
526
        """
 
527
 
484
528
    def get_url(self):
485
529
        """See Transport.Server.get_url."""
486
530
        return urlutils.local_path_to_url('')