~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/smart.py

Add list_dir and iter_files_recursive smart transport

Show diffs side-by-side

added added

removed removed

Lines of Context:
338
338
    def do_delete(self, relpath):
339
339
        self._backing_transport.delete(relpath)
340
340
 
 
341
    def do_iter_files_recursive(self, abspath):
 
342
        # XXX: the path handling needs some thought.
 
343
        #relpath = self._backing_transport.relpath(abspath)
 
344
        transport = self._backing_transport.clone(abspath)
 
345
        filenames = transport.iter_files_recursive()
 
346
        return SmartServerResponse(('names',) + tuple(filenames))
 
347
 
 
348
    def do_list_dir(self, relpath):
 
349
        filenames = self._backing_transport.list_dir(relpath)
 
350
        return SmartServerResponse(('names',) + tuple(filenames))
 
351
 
341
352
    def do_mkdir(self, relpath, mode):
342
353
        self._backing_transport.mkdir(relpath, self._optional_mode(mode))
343
354
 
652
663
    def stat(self, relpath):
653
664
        raise errors.TransportNotPossible('smart client does not support stat()')
654
665
 
655
 
    def listable(self):
656
 
        return False
657
 
 
658
666
    ## def lock_read(self, relpath):
659
667
    ##     """Lock the given file for shared (read) access.
660
668
    ##     :return: A lock object, which should be passed to Transport.unlock()
668
676
    ##             pass
669
677
    ##     return BogusLock(relpath)
670
678
 
 
679
    def listable(self):
 
680
        return True
 
681
 
 
682
    def list_dir(self, relpath):
 
683
        resp = self._client._call('list_dir',
 
684
                                  self._remote_path(relpath))
 
685
        if resp[0] == 'names':
 
686
            return resp[1:]
 
687
        else:
 
688
            self._translate_error(resp)
 
689
 
 
690
    def iter_files_recursive(self):
 
691
        resp = self._client._call('iter_files_recursive',
 
692
                                  self._remote_path(''))
 
693
        if resp[0] == 'names':
 
694
            return resp[1:]
 
695
        else:
 
696
            self._translate_error(resp)
 
697
 
671
698
 
672
699
class SmartStreamClient(SmartProtocolBase):
673
700
    """Connection to smart server over two streams"""