D4771: wireprotov2: change name and behavior of readframe()
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Oct 3 15:29:37 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf5a05bb48116: wireprotov2: change name and behavior of readframe() (authored by indygreg, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4771?vs=11442&id=11622
REVISION DETAIL
https://phab.mercurial-scm.org/D4771
AFFECTED FILES
mercurial/httppeer.py
mercurial/wireprotov2peer.py
CHANGE DETAILS
diff --git a/mercurial/wireprotov2peer.py b/mercurial/wireprotov2peer.py
--- a/mercurial/wireprotov2peer.py
+++ b/mercurial/wireprotov2peer.py
@@ -148,6 +148,7 @@
self._requests = {}
self._futures = {}
self._responses = {}
+ self._frameseof = False
def callcommand(self, command, args, f):
"""Register a request to call a command.
@@ -180,18 +181,23 @@
return meta['framegen']
- def readframe(self, fh):
- """Attempt to read and process a frame.
+ def readdata(self, framefh):
+ """Attempt to read data and do work.
- Returns None if no frame was read. Presumably this means EOF.
+ Returns None if no data was read. Presumably this means we're
+ done with all read I/O.
"""
- frame = wireprotoframing.readframe(fh)
- if frame is None:
- # TODO tell reactor?
- return
+ if not self._frameseof:
+ frame = wireprotoframing.readframe(framefh)
+ if frame is None:
+ # TODO tell reactor?
+ self._frameseof = True
+ else:
+ self._ui.note(_('received %r\n') % frame)
+ self._processframe(frame)
- self._ui.note(_('received %r\n') % frame)
- self._processframe(frame)
+ if self._frameseof:
+ return None
return True
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -712,7 +712,7 @@
def _handleresponse(self, handler, resp):
# Called in a thread to read the response.
- while handler.readframe(resp):
+ while handler.readdata(resp):
pass
# TODO implement interface for version 2 peers
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list