~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/vfs.py

(jameinel) Allow 'bzr serve' to interpret SIGHUP as a graceful shutdown.
 (bug #795025) (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
"""VFS operations for the smart server.
18
18
 
27
27
import os
28
28
 
29
29
from bzrlib import errors
 
30
from bzrlib import urlutils
30
31
from bzrlib.smart import request
31
32
 
32
33
 
51
52
 
52
53
class VfsRequest(request.SmartServerRequest):
53
54
    """Base class for VFS requests.
54
 
    
 
55
 
55
56
    VFS requests are disabled if vfs_enabled() returns False.
56
57
    """
57
58
 
59
60
        if not vfs_enabled():
60
61
            raise errors.DisabledMethod(self.__class__.__name__)
61
62
 
 
63
    def translate_client_path(self, relpath):
 
64
        # VFS requests are made with escaped paths so the escaping done in
 
65
        # SmartServerRequest.translate_client_path leads to double escaping.
 
66
        # Remove it here -- the fact that the result is still escaped means
 
67
        # that the str() will not fail on valid input.
 
68
        x = request.SmartServerRequest.translate_client_path(self, relpath)
 
69
        return str(urlutils.unescape(x))
 
70
 
62
71
 
63
72
class HasRequest(VfsRequest):
64
73
 
82
91
        relpath = self.translate_client_path(relpath)
83
92
        self._relpath = relpath
84
93
        self._mode = _deserialise_optional_mode(mode)
85
 
    
 
94
 
86
95
    def do_body(self, body_bytes):
87
96
        old_length = self._backing_transport.append_bytes(
88
97
            self._relpath, body_bytes, self._mode)