~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/fakenfs.py

  • Committer: John Arbash Meinel
  • Date: 2013-05-19 14:29:37 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: (6437.63.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6575.
  • Revision ID: john@arbash-meinel.com-20130519142937-21ykz2n2y2f22za9
Merge in the actual 2.5 branch. It seems I failed before

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Transport implementation that adapts another transport to look like NFS.
18
18
 
22
22
To get a fake nfs transport use get_transport('fakenfs+' + real_url)
23
23
"""
24
24
 
 
25
from __future__ import absolute_import
 
26
 
25
27
from stat import S_ISDIR
26
28
 
27
 
import bzrlib.errors as errors
28
 
from bzrlib.transport.decorator import TransportDecorator, DecoratorServer
29
 
 
30
 
 
31
 
class FakeNFSTransportDecorator(TransportDecorator):
 
29
from bzrlib import (
 
30
    errors,
 
31
    urlutils,
 
32
    )
 
33
from bzrlib.transport import decorator
 
34
 
 
35
 
 
36
class FakeNFSTransportDecorator(decorator.TransportDecorator):
32
37
    """A transport that behaves like NFS, for testing"""
33
38
 
34
39
    @classmethod
53
58
            else:
54
59
                raise
55
60
 
56
 
 
57
 
class FakeNFSServer(DecoratorServer):
58
 
    """Server for the FakeNFSTransportDecorator for testing with."""
59
 
 
60
 
    def get_decorator_class(self):
61
 
        return FakeNFSTransportDecorator
 
61
    def delete(self, relpath):
 
62
        if urlutils.basename(relpath).startswith('.nfs'):
 
63
            raise errors.ResourceBusy(self.abspath(relpath))
 
64
        return self._decorated.delete(relpath)
62
65
 
63
66
 
64
67
def get_test_permutations():
65
68
    """Return the permutations to be used in testing."""
66
 
    return [(FakeNFSTransportDecorator, FakeNFSServer),
67
 
            ]
 
69
    from bzrlib.tests import test_server
 
70
    return [(FakeNFSTransportDecorator, test_server.FakeNFSServer),]