mercurial/revlog.py
changeset 1559 59b3639df0a9
parent 1551 e793cbc8be00
child 1598 14d1f1868bf6
child 1677 11d12bd6e1dc
equal deleted inserted replaced
1554:68ec7b9e09a4 1559:59b3639df0a9
    50     if t == 'u': return bin[1:]
    50     if t == 'u': return bin[1:]
    51     raise RevlogError(_("unknown compression type %s") % t)
    51     raise RevlogError(_("unknown compression type %s") % t)
    52 
    52 
    53 indexformat = ">4l20s20s20s"
    53 indexformat = ">4l20s20s20s"
    54 
    54 
    55 class lazyparser:
    55 class lazyparser(object):
    56     """
    56     """
    57     this class avoids the need to parse the entirety of large indices
    57     this class avoids the need to parse the entirety of large indices
    58 
    58 
    59     By default we parse and load 1000 entries at a time.
    59     By default we parse and load 1000 entries at a time.
    60 
    60 
    92             e = struct.unpack(indexformat, d)
    92             e = struct.unpack(indexformat, d)
    93             self.index[i] = e
    93             self.index[i] = e
    94             self.map[e[6]] = i
    94             self.map[e[6]] = i
    95             i += 1
    95             i += 1
    96 
    96 
    97 class lazyindex:
    97 class lazyindex(object):
    98     """a lazy version of the index array"""
    98     """a lazy version of the index array"""
    99     def __init__(self, parser):
    99     def __init__(self, parser):
   100         self.p = parser
   100         self.p = parser
   101     def __len__(self):
   101     def __len__(self):
   102         return len(self.p.index)
   102         return len(self.p.index)
   112     def append(self, e):
   112     def append(self, e):
   113         self.p.index.append(e)
   113         self.p.index.append(e)
   114     def trunc(self, pos):
   114     def trunc(self, pos):
   115         self.p.trunc(pos)
   115         self.p.trunc(pos)
   116 
   116 
   117 class lazymap:
   117 class lazymap(object):
   118     """a lazy version of the node map"""
   118     """a lazy version of the node map"""
   119     def __init__(self, parser):
   119     def __init__(self, parser):
   120         self.p = parser
   120         self.p = parser
   121     def load(self, key):
   121     def load(self, key):
   122         if self.p.all: return
   122         if self.p.all: return
   150     def __delitem__(self, key):
   150     def __delitem__(self, key):
   151         del self.p.map[key]
   151         del self.p.map[key]
   152 
   152 
   153 class RevlogError(Exception): pass
   153 class RevlogError(Exception): pass
   154 
   154 
   155 class revlog:
   155 class revlog(object):
   156     """
   156     """
   157     the underlying revision storage object
   157     the underlying revision storage object
   158 
   158 
   159     A revlog consists of two parts, an index and the revision data.
   159     A revlog consists of two parts, an index and the revision data.
   160 
   160