Patchwork [05,of,22] obsstore: move marker version reading to a separate function

login
register
mail settings
Submitter Jun Wu
Date June 4, 2017, 11:59 p.m.
Message ID <d9ed7d0a4373b12c9205.1496620757@x1c>
Download mbox | patch
Permalink /patch/21184/
State Accepted
Headers show

Comments

Jun Wu - June 4, 2017, 11:59 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1496457296 25200
#      Fri Jun 02 19:34:56 2017 -0700
# Node ID d9ed7d0a4373b12c92055dd10718cffe96c98224
# Parent  e1d6126ed614db6ec664c79afcb3a141c9a0dfa4
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r d9ed7d0a4373
obsstore: move marker version reading to a separate function

This allows us to read marker version without reading markers.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -440,10 +440,12 @@  formats = {_fm0version: (_fm0readmarkers
            _fm1version: (_fm1readmarkers, _fm1encodeonemarker)}
 
+def _readmarkerversion(data):
+    return _unpack('>B', data[0:1])[0]
+
 @util.nogc
 def _readmarkers(data):
     """Read and enumerate markers from raw data"""
-    off = 0
-    diskversion = _unpack('>B', data[off:off + 1])[0]
-    off += 1
+    diskversion = _readmarkerversion(data)
+    off = 1
     if diskversion not in formats:
         msg = _('parsing obsolete marker: unknown version %r') % diskversion