obsstore: move header encoding to a separate function
authorJun Wu <quark@fb.com>
Sun, 04 Jun 2017 00:38:11 -0700
changeset 32692 9576974a3b6d
parent 32691 5d8dd6c90af9
child 32693 c401ad7fdf86
obsstore: move header encoding to a separate function This patch moves encodeheader from encodemarkers. So markers and header could be encoded separately.
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Sun Jun 04 08:49:15 2017 -0700
+++ b/mercurial/obsolete.py	Sun Jun 04 00:38:11 2017 -0700
@@ -452,12 +452,15 @@
         raise error.UnknownVersion(msg, version=diskversion)
     return diskversion, formats[diskversion][0](data, off)
 
+def encodeheader(version=_fm0version):
+    return _pack('>B', version)
+
 def encodemarkers(markers, addheader=False, version=_fm0version):
     # Kept separate from flushmarkers(), it will be reused for
     # markers exchange.
     encodeone = formats[version][1]
     if addheader:
-        yield _pack('>B', version)
+        yield encodeheader(version)
     for marker in markers:
         yield encodeone(marker)