mercurial/obsolete.py
changeset 23803 2763edaba857
parent 23802 a3b010f84c57
child 23804 e880036719e3
equal deleted inserted replaced
23802:a3b010f84c57 23803:2763edaba857
   284 _fm1parentmask = (_fm1parentnone << _fm1parentshift)
   284 _fm1parentmask = (_fm1parentnone << _fm1parentshift)
   285 _fm1metapair = 'BB'
   285 _fm1metapair = 'BB'
   286 _fm1metapairsize = _calcsize('BB')
   286 _fm1metapairsize = _calcsize('BB')
   287 
   287 
   288 def _fm1readmarkers(data, off=0):
   288 def _fm1readmarkers(data, off=0):
       
   289     # make some global constants local for performance
       
   290     noneflag = _fm1parentnone
       
   291     sha2flag = usingsha256
       
   292     sha1size = _fm1nodesha1size
       
   293     sha2size = _fm1nodesha256size
       
   294     sha1fmt = _fm1nodesha1
       
   295     sha2fmt = _fm1nodesha256
       
   296     metasize = _fm1metapairsize
       
   297     metafmt = _fm1metapair
       
   298     fsize = _fm1fsize
       
   299     unpack = _unpack
       
   300 
   289     # Loop on markers
   301     # Loop on markers
   290     stop = len(data) - _fm1fsize
   302     stop = len(data) - _fm1fsize
   291     ufixed = util.unpacker(_fm1fixed)
   303     ufixed = util.unpacker(_fm1fixed)
   292     while off <= stop:
   304     while off <= stop:
   293         # read fixed part
   305         # read fixed part
   294         o1 = off + _fm1fsize
   306         o1 = off + fsize
   295         t, secs, tz, flags, numsuc, numpar, nummeta, prec = ufixed(data[off:o1])
   307         t, secs, tz, flags, numsuc, numpar, nummeta, prec = ufixed(data[off:o1])
   296 
   308 
   297         if flags & usingsha256:
   309         if flags & sha2flag:
   298             # read 0 or more successors
   310             # read 0 or more successors
   299             o2 = o1 + _fm1nodesha256size * numsuc
   311             o2 = o1 + sha2size * numsuc
   300             sucs = _unpack(_fm1nodesha256 * numsuc, data[o1:o2])
   312             sucs = unpack(sha2fmt * numsuc, data[o1:o2])
   301 
   313 
   302             # read parents
   314             # read parents
   303             if numpar == _fm1parentnone:
   315             if numpar == noneflag:
   304                 o3 = o2
   316                 o3 = o2
   305                 parents = None
   317                 parents = None
   306             else:
   318             else:
   307                 o3 = o2 + _fm1nodesha256size * numpar
   319                 o3 = o2 + sha2size * numpar
   308                 parents = _unpack(_fm1nodesha256 * numpar, data[o2:o3])
   320                 parents = unpack(sha2fmt * numpar, data[o2:o3])
   309         else:
   321         else:
   310             # read 0 or more successors
   322             # read 0 or more successors
   311             o2 = o1 + _fm1nodesha1size * numsuc
   323             o2 = o1 + sha1size * numsuc
   312             sucs = _unpack(_fm1nodesha1 * numsuc, data[o1:o2])
   324             sucs = unpack(sha1fmt * numsuc, data[o1:o2])
   313 
   325 
   314             # read parents
   326             # read parents
   315             if numpar == _fm1parentnone:
   327             if numpar == noneflag:
   316                 o3 = o2
   328                 o3 = o2
   317                 parents = None
   329                 parents = None
   318             else:
   330             else:
   319                 o3 = o2 + _fm1nodesha1size * numpar
   331                 o3 = o2 + sha1size * numpar
   320                 parents = _unpack(_fm1nodesha1 * numpar, data[o2:o3])
   332                 parents = unpack(sha1fmt * numpar, data[o2:o3])
   321 
   333 
   322         # read metadata
   334         # read metadata
   323         off = o3 + _fm1metapairsize * nummeta
   335         off = o3 + metasize * nummeta
   324         metapairsize = _unpack('>' + (_fm1metapair * nummeta), data[o3:off])
   336         metapairsize = unpack('>' + (metafmt * nummeta), data[o3:off])
   325         metadata = []
   337         metadata = []
   326         for idx in xrange(0, len(metapairsize), 2):
   338         for idx in xrange(0, len(metapairsize), 2):
   327             o1 = off + metapairsize[idx]
   339             o1 = off + metapairsize[idx]
   328             o2 = o1 + metapairsize[idx + 1]
   340             o2 = o1 + metapairsize[idx + 1]
   329             metadata.append((data[off:o1], data[o1:o2]))
   341             metadata.append((data[off:o1], data[o1:o2]))