readmarkers: read node reading into node length conditional
authorMatt Mackall <mpm@selenic.com>
Sun, 11 Jan 2015 14:51:49 -0600
changeset 23801 20b5701cd90a
parent 23800 83f361a21d31
child 23802 a3b010f84c57
readmarkers: read node reading into node length conditional This removes some conditional assignments
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Sun Jan 11 14:46:55 2015 -0600
+++ b/mercurial/obsolete.py	Sun Jan 11 14:51:49 2015 -0600
@@ -294,23 +294,30 @@
         o1 = off + _fm1fsize
         t, secs, tz, flags, numsuc, numpar, nummeta, prec = ufixed(data[off:o1])
 
-        _fm1node = _fm1nodesha1
-        fnodesize = _fm1nodesha1size
         if flags & usingsha256:
-            _fm1node = _fm1nodesha256
-            fnodesize = _fm1nodesha256size
+            # read 0 or more successors
+            o2 = o1 + _fm1nodesha256size * numsuc
+            sucs = _unpack(_fm1nodesha256 * numsuc, data[o1:o2])
 
-        # read 0 or more successors
-        o2 = o1 + fnodesize * numsuc
-        sucs = _unpack(_fm1node * numsuc, data[o1:o2])
+            # read parents
+            if numpar == _fm1parentnone:
+                o3 = o2
+                parents = None
+            else:
+                o3 = o2 + _fm1nodesha256size * numpar
+                parents = _unpack(_fm1nodesha256 * numpar, data[o2:o3])
+        else:
+            # read 0 or more successors
+            o2 = o1 + _fm1nodesha1size * numsuc
+            sucs = _unpack(_fm1nodesha1 * numsuc, data[o1:o2])
 
-        # read parents
-        if numpar == _fm1parentnone:
-            o3 = o2
-            parents = None
-        else:
-            o3 = o2 + fnodesize * numpar
-            parents = _unpack(_fm1node * numpar, data[o2:o3])
+            # read parents
+            if numpar == _fm1parentnone:
+                o3 = o2
+                parents = None
+            else:
+                o3 = o2 + _fm1nodesha1size * numpar
+                parents = _unpack(_fm1nodesha1 * numpar, data[o2:o3])
 
         # read metadata
         metaformat = '>' + (_fm1metapair * nummeta)