changeset 35754:fb0be099063f

util: move 'readexactly' in the util module This function is used in multiple place, having it in util would be better. (existing caller will be migrated in another series)
author Boris Feld <boris.feld@octobus.net>
date Fri, 19 Jan 2018 20:51:35 +0100
parents 069df0b952e8
children 2384523cee4d
files mercurial/changegroup.py mercurial/util.py
diffstat 2 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Fri Jan 19 19:13:11 2018 -0500
+++ b/mercurial/changegroup.py	Fri Jan 19 20:51:35 2018 +0100
@@ -32,14 +32,7 @@
 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
 _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH"
 
-def readexactly(stream, n):
-    '''read n bytes from stream.read and abort if less was available'''
-    s = stream.read(n)
-    if len(s) < n:
-        raise error.Abort(_("stream ended unexpectedly"
-                           " (got %d bytes, expected %d)")
-                          % (len(s), n))
-    return s
+readexactly = util.readexactly
 
 def getchunk(stream):
     """return the next chunk from stream as a string"""
--- a/mercurial/util.py	Fri Jan 19 19:13:11 2018 -0500
+++ b/mercurial/util.py	Fri Jan 19 20:51:35 2018 +0100
@@ -3865,3 +3865,12 @@
         fn = '%s~%s~%s' % (f, tag, n)
         if fn not in ctx and fn not in others:
             return fn
+
+def readexactly(stream, n):
+    '''read n bytes from stream.read and abort if less was available'''
+    s = stream.read(n)
+    if len(s) < n:
+        raise error.Abort(_("stream ended unexpectedly"
+                           " (got %d bytes, expected %d)")
+                          % (len(s), n))
+    return s