# HG changeset patch # User Pierre-Yves David # Date 1396030233 25200 # Node ID 8d477543882b0a4813aeb3d63052245c4daaa044 # Parent 1e4fda2f5cf14fab3413941ef2eb3f823e78f273 wireproto: introduce an abstractserverproto class sshserver and webproto now inherit from an abstractserverproto class. This class is introduced for documentation purpose. diff -r 1e4fda2f5cf1 -r 8d477543882b mercurial/hgweb/protocol.py --- a/mercurial/hgweb/protocol.py Fri Mar 28 11:37:42 2014 -0700 +++ b/mercurial/hgweb/protocol.py Fri Mar 28 11:10:33 2014 -0700 @@ -12,7 +12,7 @@ HGTYPE = 'application/mercurial-0.1' HGERRTYPE = 'application/hg-error' -class webproto(object): +class webproto(wireproto.abstractserverproto): def __init__(self, req, ui): self.req = req self.response = '' diff -r 1e4fda2f5cf1 -r 8d477543882b mercurial/sshserver.py --- a/mercurial/sshserver.py Fri Mar 28 11:37:42 2014 -0700 +++ b/mercurial/sshserver.py Fri Mar 28 11:10:33 2014 -0700 @@ -9,7 +9,7 @@ import util, hook, wireproto, changegroup import os, sys -class sshserver(object): +class sshserver(wireproto.abstractserverproto): def __init__(self, ui, repo): self.ui = ui self.repo = repo diff -r 1e4fda2f5cf1 -r 8d477543882b mercurial/wireproto.py --- a/mercurial/wireproto.py Fri Mar 28 11:37:42 2014 -0700 +++ b/mercurial/wireproto.py Fri Mar 28 11:10:33 2014 -0700 @@ -11,6 +11,53 @@ import changegroup as changegroupmod import peer, error, encoding, util, store + +class abstractserverproto(object): + """abstract class that summarizes the protocol API + + Used as reference and documentation. + """ + + def getargs(self, args): + """return the value for arguments in + + returns a list of values (same order as )""" + raise NotImplementedError() + + def getfile(self, fp): + """write the whole content of a file into a file like object + + The file is in the form:: + + (\n)+0\n + + chunk size is the ascii version of the int. + """ + raise NotImplementedError() + + def redirect(self): + """may setup interception for stdout and stderr + + See also the `restore` method.""" + raise NotImplementedError() + + # If the `redirect` function does install interception, the `restore` + # function MUST be defined. If interception is not used, this function + # MUST NOT be defined. + # + # left commented here on purpose + # + #def restore(self): + # """reinstall previous stdout and stderr and return intercepted stdout + # """ + # raise NotImplementedError() + + def groupchunks(self, cg): + """return 4096 chunks from a changegroup object + + Some protocols may have compressed the contents.""" + raise NotImplementedError() + # abstract batching support class future(object):