Patchwork D2085: wireprotoserver: rename getfile() to forwardpayload() (API)

login
register
mail settings
Submitter phabricator
Date Feb. 8, 2018, 12:27 a.m.
Message ID <differential-rev-PHID-DREV-baelmmpbkwhxg6liitdo-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27455/
State Superseded
Headers show

Comments

phabricator - Feb. 8, 2018, 12:27 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  "file" can mean a lot of things. Let's rename the interface
  method to something more descriptive.
  
  While I was here, I moved the docs about the payload format to
  the implementation of the SSH protocol, because it was lying
  about what the HTTP payload looked like.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2085

AFFECTED FILES
  hgext/largefiles/proto.py
  mercurial/wireproto.py
  mercurial/wireprotoserver.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -64,14 +64,10 @@ 
         returns a list of values (same order as <args>)"""
 
     @abc.abstractmethod
-    def getfile(self, fp):
-        """write the whole content of a file into a file like object
+    def forwardpayload(self, fp):
+        """Read the raw payload and forward to a file.
 
-        The file is in the form::
-
-            (<chunk-size>\n<chunk>)+0\n
-
-        chunk size is the ascii version of the int.
+        The payload is read in full before the function returns.
         """
 
     @abc.abstractmethod
@@ -145,7 +141,7 @@ 
         args.update(cgi.parse_qs(argvalue, keep_blank_values=True))
         return args
 
-    def getfile(self, fp):
+    def forwardpayload(self, fp):
         length = int(self._req.env[r'CONTENT_LENGTH'])
         # If httppostargs is used, we need to read Content-Length
         # minus the amount that was consumed by args.
@@ -373,7 +369,12 @@ 
                 data[arg] = val
         return [data[k] for k in keys]
 
-    def getfile(self, fpout):
+    def forwardpayload(self, fpout):
+        # The file is in the form:
+        #
+        # <chunk size>\n<chunk>
+        # ...
+        # 0\n
         self._sendresponse('')
         count = int(self._fin.readline())
         while count:
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -1008,7 +1008,7 @@ 
             fp = os.fdopen(fd, pycompat.sysstr('wb+'))
             r = 0
             try:
-                proto.getfile(fp)
+                proto.forwardpayload(fp)
                 fp.seek(0)
                 gen = exchange.readbundle(repo.ui, fp, None)
                 if (isinstance(gen, changegroupmod.cg1unpacker)
diff --git a/hgext/largefiles/proto.py b/hgext/largefiles/proto.py
--- a/hgext/largefiles/proto.py
+++ b/hgext/largefiles/proto.py
@@ -40,7 +40,7 @@ 
         tmpfp = util.atomictempfile(path, createmode=repo.store.createmode)
 
         try:
-            proto.getfile(tmpfp)
+            proto.forwardpayload(tmpfp)
             tmpfp._fp.seek(0)
             if sha != lfutil.hexsha1(tmpfp._fp):
                 raise IOError(0, _('largefile contents do not match hash'))