Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireproto.py @ 20903:8d477543882b
wireproto: introduce an abstractserverproto class
sshserver and webproto now inherit from an abstractserverproto class. This class
is introduced for documentation purpose.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 28 Mar 2014 11:10:33 -0700 |
parents | 1e4fda2f5cf1 |
children | 3dbe6bcd7f62 |
line wrap: on
line diff
--- 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 <args> + + returns a list of values (same order as <args>)""" + raise NotImplementedError() + + def getfile(self, fp): + """write the whole content of a file into a file like object + + The file is in the form:: + + (<chunk-size>\n<chunk>)+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):