mercurial/peer.py
changeset 33806 dedab036215d
parent 33767 b47fe9733d76
child 34693 56bb07a0b75c
equal deleted inserted replaced
33805:f913e90f15a0 33806:dedab036215d
     6 # This software may be used and distributed according to the terms of the
     6 # This software may be used and distributed according to the terms of the
     7 # GNU General Public License version 2 or any later version.
     7 # GNU General Public License version 2 or any later version.
     8 
     8 
     9 from __future__ import absolute_import
     9 from __future__ import absolute_import
    10 
    10 
    11 from .i18n import _
       
    12 from . import (
    11 from . import (
    13     error,
    12     error,
    14     util,
    13     util,
    15 )
    14 )
    16 
    15 
    93         self = args[0]
    92         self = args[0]
    94         encresref.set(self._submitone(f.func_name, encargsorres))
    93         encresref.set(self._submitone(f.func_name, encargsorres))
    95         return next(batchable)
    94         return next(batchable)
    96     setattr(plain, 'batchable', f)
    95     setattr(plain, 'batchable', f)
    97     return plain
    96     return plain
    98 
       
    99 class peerrepository(object):
       
   100     def iterbatch(self):
       
   101         """Batch requests but allow iterating over the results.
       
   102 
       
   103         This is to allow interleaving responses with things like
       
   104         progress updates for clients.
       
   105         """
       
   106         return localiterbatcher(self)
       
   107 
       
   108     def capable(self, name):
       
   109         '''tell whether repo supports named capability.
       
   110         return False if not supported.
       
   111         if boolean capability, return True.
       
   112         if string capability, return string.'''
       
   113         caps = self._capabilities()
       
   114         if name in caps:
       
   115             return True
       
   116         name_eq = name + '='
       
   117         for cap in caps:
       
   118             if cap.startswith(name_eq):
       
   119                 return cap[len(name_eq):]
       
   120         return False
       
   121 
       
   122     def requirecap(self, name, purpose):
       
   123         '''raise an exception if the given capability is not present'''
       
   124         if not self.capable(name):
       
   125             raise error.CapabilityError(
       
   126                 _('cannot %s; remote repository does not '
       
   127                   'support the %r capability') % (purpose, name))
       
   128 
       
   129     def local(self):
       
   130         '''return peer as a localrepo, or None'''
       
   131         return None
       
   132 
       
   133     def peer(self):
       
   134         return self
       
   135 
       
   136     def canpush(self):
       
   137         return True
       
   138 
       
   139     def close(self):
       
   140         pass