tests/simplestorerepo.py
changeset 47012 d55b71393907
parent 46780 6266d19556ad
child 47877 2174f54aab18
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
    16 
    16 
    17 from mercurial.i18n import _
    17 from mercurial.i18n import _
    18 from mercurial.node import (
    18 from mercurial.node import (
    19     bin,
    19     bin,
    20     hex,
    20     hex,
    21     nullid,
       
    22     nullrev,
    21     nullrev,
    23 )
    22 )
    24 from mercurial.thirdparty import attr
    23 from mercurial.thirdparty import attr
    25 from mercurial import (
    24 from mercurial import (
    26     ancestor,
    25     ancestor,
   134 
   133 
   135         for i, entry in enumerate(self._indexdata):
   134         for i, entry in enumerate(self._indexdata):
   136             self._indexbynode[entry[b'node']] = entry
   135             self._indexbynode[entry[b'node']] = entry
   137             self._indexbyrev[i] = entry
   136             self._indexbyrev[i] = entry
   138 
   137 
   139         self._indexbynode[nullid] = {
   138         self._indexbynode[self._repo.nullid] = {
   140             b'node': nullid,
   139             b'node': self._repo.nullid,
   141             b'p1': nullid,
   140             b'p1': self._repo.nullid,
   142             b'p2': nullid,
   141             b'p2': self._repo.nullid,
   143             b'linkrev': nullrev,
   142             b'linkrev': nullrev,
   144             b'flags': 0,
   143             b'flags': 0,
   145         }
   144         }
   146 
   145 
   147         self._indexbyrev[nullrev] = {
   146         self._indexbyrev[nullrev] = {
   148             b'node': nullid,
   147             b'node': self._repo.nullid,
   149             b'p1': nullid,
   148             b'p1': self._repo.nullid,
   150             b'p2': nullid,
   149             b'p2': self._repo.nullid,
   151             b'linkrev': nullrev,
   150             b'linkrev': nullrev,
   152             b'flags': 0,
   151             b'flags': 0,
   153         }
   152         }
   154 
   153 
   155         for i, entry in enumerate(self._indexdata):
   154         for i, entry in enumerate(self._indexdata):
   158             # start, length, rawsize, chainbase, linkrev, p1, p2, node
   157             # start, length, rawsize, chainbase, linkrev, p1, p2, node
   159             self._index.append(
   158             self._index.append(
   160                 (0, 0, 0, -1, entry[b'linkrev'], p1rev, p2rev, entry[b'node'])
   159                 (0, 0, 0, -1, entry[b'linkrev'], p1rev, p2rev, entry[b'node'])
   161             )
   160             )
   162 
   161 
   163         self._index.append((0, 0, 0, -1, -1, -1, -1, nullid))
   162         self._index.append((0, 0, 0, -1, -1, -1, -1, self._repo.nullid))
   164 
   163 
   165     def __len__(self):
   164     def __len__(self):
   166         return len(self._indexdata)
   165         return len(self._indexdata)
   167 
   166 
   168     def __iter__(self):
   167     def __iter__(self):
   286             node = self.node(nodeorrev)
   285             node = self.node(nodeorrev)
   287         else:
   286         else:
   288             node = nodeorrev
   287             node = nodeorrev
   289         validatenode(node)
   288         validatenode(node)
   290 
   289 
   291         if node == nullid:
   290         if node == self._repo.nullid:
   292             return b''
   291             return b''
   293 
   292 
   294         rev = self.rev(node)
   293         rev = self.rev(node)
   295         flags = self._flags(rev)
   294         flags = self._flags(rev)
   296 
   295 
   323         return revision[start + 2 :]
   322         return revision[start + 2 :]
   324 
   323 
   325     def renamed(self, node):
   324     def renamed(self, node):
   326         validatenode(node)
   325         validatenode(node)
   327 
   326 
   328         if self.parents(node)[0] != nullid:
   327         if self.parents(node)[0] != self._repo.nullid:
   329             return False
   328             return False
   330 
   329 
   331         fulltext = self.revision(node)
   330         fulltext = self.revision(node)
   332         m = storageutil.parsemeta(fulltext)[0]
   331         m = storageutil.parsemeta(fulltext)[0]
   333 
   332 
   449         assumehaveparentrevisions=False,
   448         assumehaveparentrevisions=False,
   450         deltamode=repository.CG_DELTAMODE_STD,
   449         deltamode=repository.CG_DELTAMODE_STD,
   451         sidedata_helpers=None,
   450         sidedata_helpers=None,
   452     ):
   451     ):
   453         # TODO this will probably break on some ordering options.
   452         # TODO this will probably break on some ordering options.
   454         nodes = [n for n in nodes if n != nullid]
   453         nodes = [n for n in nodes if n != self._repo.nullid]
   455         if not nodes:
   454         if not nodes:
   456             return
   455             return
   457         for delta in storageutil.emitrevisions(
   456         for delta in storageutil.emitrevisions(
   458             self,
   457             self,
   459             nodes,
   458             nodes,
   557                     duplicaterevisioncb(self, self.rev(node))
   556                     duplicaterevisioncb(self, self.rev(node))
   558                 empty = False
   557                 empty = False
   559                 continue
   558                 continue
   560 
   559 
   561             # Need to resolve the fulltext from the delta base.
   560             # Need to resolve the fulltext from the delta base.
   562             if deltabase == nullid:
   561             if deltabase == self._repo.nullid:
   563                 text = mdiff.patch(b'', delta)
   562                 text = mdiff.patch(b'', delta)
   564             else:
   563             else:
   565                 text = mdiff.patch(self.revision(deltabase), delta)
   564                 text = mdiff.patch(self.revision(deltabase), delta)
   566 
   565 
   567             rev = self._addrawrevision(
   566             rev = self._addrawrevision(
   586 
   585 
   587     def heads(self, start=None, stop=None):
   586     def heads(self, start=None, stop=None):
   588         # This is copied from revlog.py.
   587         # This is copied from revlog.py.
   589         if start is None and stop is None:
   588         if start is None and stop is None:
   590             if not len(self):
   589             if not len(self):
   591                 return [nullid]
   590                 return [self._repo.nullid]
   592             return [self.node(r) for r in self._headrevs()]
   591             return [self.node(r) for r in self._headrevs()]
   593 
   592 
   594         if start is None:
   593         if start is None:
   595             start = nullid
   594             start = self._repo.nullid
   596         if stop is None:
   595         if stop is None:
   597             stop = []
   596             stop = []
   598         stoprevs = {self.rev(n) for n in stop}
   597         stoprevs = {self.rev(n) for n in stop}
   599         startrev = self.rev(start)
   598         startrev = self.rev(start)
   600         reachable = {startrev}
   599         reachable = {startrev}