mercurial/streamclone.py
changeset 27882 319b0bf6ecc9
parent 27870 ed9950ba091e
child 27896 1d29893240cc
--- a/mercurial/streamclone.py	Sat Jan 16 18:30:01 2016 +0900
+++ b/mercurial/streamclone.py	Thu Jan 14 22:48:54 2016 -0800
@@ -329,16 +329,7 @@
                        (util.bytecount(bytecount), elapsed,
                         util.bytecount(bytecount / elapsed)))
 
-def applybundlev1(repo, fp):
-    """Apply the content from a stream clone bundle version 1.
-
-    We assume the 4 byte header has been read and validated and the file handle
-    is at the 2 byte compression identifier.
-    """
-    if len(repo):
-        raise error.Abort(_('cannot apply stream clone bundle on non-empty '
-                            'repo'))
-
+def readbundle1header(fp):
     compression = fp.read(2)
     if compression != 'UN':
         raise error.Abort(_('only uncompressed stream clone bundles are '
@@ -353,6 +344,20 @@
                             'requirements not properly encoded'))
 
     requirements = set(requires.rstrip('\0').split(','))
+
+    return filecount, bytecount, requirements
+
+def applybundlev1(repo, fp):
+    """Apply the content from a stream clone bundle version 1.
+
+    We assume the 4 byte header has been read and validated and the file handle
+    is at the 2 byte compression identifier.
+    """
+    if len(repo):
+        raise error.Abort(_('cannot apply stream clone bundle on non-empty '
+                            'repo'))
+
+    filecount, bytecount, requirements = readbundle1header(fp)
     missingreqs = requirements - repo.supportedformats
     if missingreqs:
         raise error.Abort(_('unable to apply stream clone: '