~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

add gettext to all the builtin commands outf usage

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 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
38
38
from bzrlib import (
39
39
    debug,
40
40
    errors,
41
 
    symbol_versioning,
42
41
    trace,
43
42
    ui,
44
43
    urlutils,
491
490
        return self._medium._get_line()
492
491
 
493
492
 
 
493
class _VfsRefuser(object):
 
494
    """An object that refuses all VFS requests.
 
495
 
 
496
    """
 
497
 
 
498
    def __init__(self):
 
499
        client._SmartClient.hooks.install_named_hook(
 
500
            'call', self.check_vfs, 'vfs refuser')
 
501
 
 
502
    def check_vfs(self, params):
 
503
        try:
 
504
            request_method = request.request_handlers.get(params.method)
 
505
        except KeyError:
 
506
            # A method we don't know about doesn't count as a VFS method.
 
507
            return
 
508
        if issubclass(request_method, vfs.VfsRequest):
 
509
            raise errors.HpssVfsRequestNotAllowed(params.method, params.args)
 
510
 
 
511
 
494
512
class _DebugCounter(object):
495
513
    """An object that counts the HPSS calls made to each client medium.
496
514
 
551
569
            self.done(ref)
552
570
 
553
571
_debug_counter = None
 
572
_vfs_refuser = None
554
573
 
555
574
 
556
575
class SmartClientMedium(SmartMedium):
573
592
            if _debug_counter is None:
574
593
                _debug_counter = _DebugCounter()
575
594
            _debug_counter.track(self)
 
595
        if 'hpss_client_no_vfs' in debug.debug_flags:
 
596
            global _vfs_refuser
 
597
            if _vfs_refuser is None:
 
598
                _vfs_refuser = _VfsRefuser()
576
599
 
577
600
    def _is_remote_before(self, version_tuple):
578
601
        """Is it possible the remote side supports RPCs for a given version?