D2984: keepalive: implement readinto()
This revision was automatically updated to reflect the committed changes. Closed by commit rHG97eedbd5a56c: keepalive: implement readinto() (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2984?vs=7447=7558 REVISION DETAIL https://phab.mercurial-scm.org/D2984 AFFECTED FILES mercurial/keepalive.py CHANGE DETAILS diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py --- a/mercurial/keepalive.py +++ b/mercurial/keepalive.py @@ -349,7 +349,7 @@ class HTTPResponse(httplib.HTTPResponse): # we need to subclass HTTPResponse in order to -# 1) add readline() and readlines() methods +# 1) add readline(), readlines(), and readinto() methods # 2) add close_connection() methods # 3) add info() and geturl() methods @@ -522,6 +522,14 @@ break return list +def readinto(self, dest): +res = self.read(len(dest)) +if not res: +return 0 + +dest[0:len(res)] = res +return len(res) + def safesend(self, str): """Send `str' to the server. To: indygreg, #hg-reviewers, durin42 Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2984: keepalive: implement readinto()
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is part of the standard I/O interface. It is used by the framing protocol. So we need to implement it so frames can be decoded. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2984 AFFECTED FILES mercurial/keepalive.py CHANGE DETAILS diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py --- a/mercurial/keepalive.py +++ b/mercurial/keepalive.py @@ -349,7 +349,7 @@ class HTTPResponse(httplib.HTTPResponse): # we need to subclass HTTPResponse in order to -# 1) add readline() and readlines() methods +# 1) add readline(), readlines(), and readinto() methods # 2) add close_connection() methods # 3) add info() and geturl() methods @@ -522,6 +522,14 @@ break return list +def readinto(self, dest): +res = self.read(len(dest)) +if not res: +return 0 + +dest[0:len(res)] = res +return len(res) + def safesend(self, str): """Send `str' to the server. To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel