~bzr/ubuntu/maverick/bzr/sru-2.2.4

« back to all changes in this revision

Viewing changes to bzrlib/tests/stub_sftp.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-08-07 00:54:52 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100807005452-g4zb99ezl3xn44r4
Tags: 2.2.0-1
* New upstream release.
 + Adds support for setting timestamps to originating revisions.
   Closes: #473450
 + Removes remaining string exception. Closes: #585193, LP: #586926
 + Add C extension to work around Python issue 1628205. LP: #583941,
   Closes: #577110
 + Avoids showing progress bars when --quiet is used. Closes: #542105,
   LP: #320035
 + No longer creates ~/.bazaar as root when run under sudo. LP: #376388
 + 'bzr commit' now supports -p as alternative for --show-diff. LP: #571467
 + 'bzr add' no longer adds .THIS/.BASE/.THEIRS files unless
   explicitly requested. LP: #322767
 + When parsing patch files, Bazaar now supports diff lines before each
   patch. LP: #502076
 + WorkingTrees now no longer requires using signal.signal, so can
   be used in a threaded environment. LP: #521989
 + An assertion error is no longer triggered when pushing to a pre-1.6
   Bazaar server. LP: #528041
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    urlutils,
34
34
    )
35
35
from bzrlib.transport import (
36
 
    local,
37
 
    Server,
38
36
    ssh,
39
37
    )
 
38
from bzrlib.tests import test_server
 
39
 
40
40
 
41
41
class StubServer (paramiko.ServerInterface):
42
42
 
135
135
        try:
136
136
            out = [ ]
137
137
            # TODO: win32 incorrectly lists paths with non-ascii if path is not
138
 
            # unicode. However on Linux the server should only deal with
 
138
            # unicode. However on unix the server should only deal with
139
139
            # bytestreams and posix.listdir does the right thing
140
140
            if sys.platform == 'win32':
141
141
                flist = [f.encode('utf8') for f in os.listdir(path)]
283
283
        self._socket.close()
284
284
 
285
285
    def run(self):
 
286
        trace.mutter('SocketListener %r has started', self)
286
287
        while True:
287
288
            readable, writable_unused, exception_unused = \
288
289
                select.select([self._socket], [], [], 0.1)
289
290
            if self._stop_event.isSet():
 
291
                trace.mutter('SocketListener %r has stopped', self)
290
292
                return
291
293
            if len(readable) == 0:
292
294
                continue
293
295
            try:
294
296
                s, addr_unused = self._socket.accept()
 
297
                trace.mutter('SocketListener %r has accepted connection %r',
 
298
                    self, s)
295
299
                # because the loopback socket is inline, and transports are
296
300
                # never explicitly closed, best to launch a new thread.
297
301
                threading.Thread(target=self._callback, args=(s,)).start()
382
386
        return bytes_sent
383
387
 
384
388
 
385
 
class SFTPServer(Server):
 
389
class SFTPServer(test_server.TestServer):
386
390
    """Common code for SFTP server facilities."""
387
391
 
388
392
    def __init__(self, server_interface=StubServer):
436
440
        # XXX: TODO: make sftpserver back onto backing_server rather than local
437
441
        # disk.
438
442
        if not (backing_server is None or
439
 
                isinstance(backing_server, local.LocalURLServer)):
 
443
                isinstance(backing_server, test_server.LocalURLServer)):
440
444
            raise AssertionError(
441
445
                'backing_server should not be %r, because this can only serve '
442
446
                'the local current working directory.' % (backing_server,))
443
447
        self._original_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
444
448
        ssh._ssh_vendor_manager._cached_ssh_vendor = self._vendor
445
 
        # FIXME: the following block should certainly just be self._homedir =
446
 
        # osutils.getcwd() but that fails badly on Unix -- vila 20100224
447
449
        if sys.platform == 'win32':
448
450
            # Win32 needs to use the UNICODE api
449
451
            self._homedir = os.getcwdu()
 
452
            # Normalize the path or it will be wrongly escaped
 
453
            self._homedir = osutils.normpath(self._homedir)
450
454
        else:
451
 
            # But Linux SFTP servers should just deal in bytestreams
 
455
            # But unix SFTP servers should just deal in bytestreams
452
456
            self._homedir = os.getcwd()
453
457
        if self._server_homedir is None:
454
458
            self._server_homedir = self._homedir