This is a required part of the interface. Abstract properties must
be defined at type creation time. So we make name a @property.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
This is a required part of the interface. Abstract properties must
be defined at type creation time. So we make name a @property.
| Lint Skipped |
| Unit Tests Skipped |
| class abstractserverproto(object): | class abstractserverproto(object): | ||||
| """abstract class that summarizes the protocol API | """abstract class that summarizes the protocol API | ||||
| Used as reference and documentation. | Used as reference and documentation. | ||||
| """ | """ | ||||
| __metaclass__ = abc.ABCMeta | __metaclass__ = abc.ABCMeta | ||||
| @abc.abstractproperty | |||||
| def name(self): | |||||
| """The name of the protocol implementation. | |||||
| Used for uniquely identifying the transport type. | |||||
| """ | |||||
| @abc.abstractmethod | @abc.abstractmethod | ||||
| def getargs(self, args): | def getargs(self, args): | ||||
| """return the value for arguments in <args> | """return the value for arguments in <args> | ||||
| returns a list of values (same order as <args>)""" | returns a list of values (same order as <args>)""" | ||||
| @abc.abstractmethod | @abc.abstractmethod | ||||
| def getfile(self, fp): | def getfile(self, fp): | ||||
| i += 1 | i += 1 | ||||
| return ''.join(chunks) | return ''.join(chunks) | ||||
| class webproto(abstractserverproto): | class webproto(abstractserverproto): | ||||
| def __init__(self, req, ui): | def __init__(self, req, ui): | ||||
| self._req = req | self._req = req | ||||
| self._ui = ui | self._ui = ui | ||||
| self.name = 'http' | |||||
| @property | |||||
| def name(self): | |||||
| return 'http' | |||||
| def getargs(self, args): | def getargs(self, args): | ||||
| knownargs = self._args() | knownargs = self._args() | ||||
| data = {} | data = {} | ||||
| keys = args.split() | keys = args.split() | ||||
| for k in keys: | for k in keys: | ||||
| if k == '*': | if k == '*': | ||||
| star = {} | star = {} | ||||
| raise error.ProgrammingError('hgweb.protocol internal failure', rsp) | raise error.ProgrammingError('hgweb.protocol internal failure', rsp) | ||||
| class sshserver(abstractserverproto): | class sshserver(abstractserverproto): | ||||
| def __init__(self, ui, repo): | def __init__(self, ui, repo): | ||||
| self._ui = ui | self._ui = ui | ||||
| self._repo = repo | self._repo = repo | ||||
| self._fin = ui.fin | self._fin = ui.fin | ||||
| self._fout = ui.fout | self._fout = ui.fout | ||||
| self.name = 'ssh' | |||||
| hook.redirect(True) | hook.redirect(True) | ||||
| ui.fout = repo.ui.fout = ui.ferr | ui.fout = repo.ui.fout = ui.ferr | ||||
| # Prevent insertion/deletion of CRs | # Prevent insertion/deletion of CRs | ||||
| util.setbinary(self._fin) | util.setbinary(self._fin) | ||||
| util.setbinary(self._fout) | util.setbinary(self._fout) | ||||
| @property | |||||
| def name(self): | |||||
| return 'ssh' | |||||
| def getargs(self, args): | def getargs(self, args): | ||||
| data = {} | data = {} | ||||
| keys = args.split() | keys = args.split() | ||||
| for n in xrange(len(keys)): | for n in xrange(len(keys)): | ||||
| argline = self._fin.readline()[:-1] | argline = self._fin.readline()[:-1] | ||||
| arg, l = argline.split() | arg, l = argline.split() | ||||
| if arg not in keys: | if arg not in keys: | ||||
| raise error.Abort(_("unexpected parameter %r") % arg) | raise error.Abort(_("unexpected parameter %r") % arg) | ||||