mercurial/revlog.py
changeset 4993 4205f626dc05
parent 4992 0a676643687b
child 4994 d36310dd51d7
equal deleted inserted replaced
4992:0a676643687b 4993:4205f626dc05
   234         if pos < 0:
   234         if pos < 0:
   235             pos += len(self.p.index)
   235             pos += len(self.p.index)
   236         self.p.loadindex(pos)
   236         self.p.loadindex(pos)
   237         return self.p.index[pos]
   237         return self.p.index[pos]
   238     def __getitem__(self, pos):
   238     def __getitem__(self, pos):
   239         ret = self.p.index[pos] or self.load(pos)
   239         return struct.unpack(indexformatng,
   240         if isinstance(ret, str):
   240                              self.p.index[pos] or self.load(pos))
   241             ret = struct.unpack(indexformatng, ret)
       
   242         return ret
       
   243     def __setitem__(self, pos, item):
   241     def __setitem__(self, pos, item):
   244         self.p.index[pos] = item
   242         self.p.index[pos] = struct.pack(indexformatng, *item)
   245     def __delitem__(self, pos):
   243     def __delitem__(self, pos):
   246         del self.p.index[pos]
   244         del self.p.index[pos]
   247     def insert(self, pos, e):
   245     def insert(self, pos, e):
   248         self.p.index.insert(pos, e)
   246         self.p.index.insert(pos, struct.pack(indexformatng, *e))
   249     def append(self, e):
   247     def append(self, e):
   250         self.p.index.append(e)
   248         self.p.index.append(struct.pack(indexformatng, *e))
   251 
   249 
   252 class lazymap(object):
   250 class lazymap(object):
   253     """a lazy version of the node map"""
   251     """a lazy version of the node map"""
   254     def __init__(self, parser):
   252     def __init__(self, parser):
   255         self.p = parser
   253         self.p = parser