mercurial/manifest.py
changeset 22788 160efd225b24
parent 22787 4a13849ca359
child 22929 bf69cb09a6c9
equal deleted inserted replaced
22787:4a13849ca359 22788:160efd225b24
   158         l = text[start:end]
   158         l = text[start:end]
   159         f, n = l.split('\0')
   159         f, n = l.split('\0')
   160         return revlog.bin(n[:40]), n[40:-1]
   160         return revlog.bin(n[:40]), n[40:-1]
   161 
   161 
   162     def add(self, map, transaction, link, p1, p2, added, removed):
   162     def add(self, map, transaction, link, p1, p2, added, removed):
   163         # if we're using the cache, make sure it is valid and
   163         if p1 in self._mancache:
   164         # parented by the same node we're diffing against
   164             # If our first parent is in the manifest cache, we can
   165         if not (p1 and (p1 in self._mancache)):
   165             # compute a delta here using properties we know about the
   166             files = sorted(map)
   166             # manifest up-front, which may save time later for the
   167             _checkforbidden(files)
   167             # revlog layer.
   168 
       
   169             # if this is changed to support newlines in filenames,
       
   170             # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
   171             hex, flags = revlog.hex, map.flags
       
   172             text = ''.join("%s\0%s%s\n" % (f, hex(map[f]), flags(f))
       
   173                            for f in files)
       
   174             arraytext = array.array('c', text)
       
   175             cachedelta = None
       
   176         else:
       
   177             addlist = self._mancache[p1][1]
   168             addlist = self._mancache[p1][1]
   178 
   169 
   179             _checkforbidden(added)
   170             _checkforbidden(added)
   180             # combine the changed lists into one list for sorting
   171             # combine the changed lists into one list for sorting
   181             work = [(x, False) for x in added]
   172             work = [(x, False) for x in added]
   222             # apply the delta to the addlist, and get a delta for addrevision
   213             # apply the delta to the addlist, and get a delta for addrevision
   223             deltatext, addlist = _addlistdelta(addlist, delta)
   214             deltatext, addlist = _addlistdelta(addlist, delta)
   224             cachedelta = (self.rev(p1), deltatext)
   215             cachedelta = (self.rev(p1), deltatext)
   225             arraytext = addlist
   216             arraytext = addlist
   226             text = util.buffer(arraytext)
   217             text = util.buffer(arraytext)
       
   218         else:
       
   219             # The first parent manifest isn't already loaded, so we'll
       
   220             # just encode a fulltext of the manifest and pass that
       
   221             # through to the revlog layer, and let it handle the delta
       
   222             # process.
       
   223             files = sorted(map)
       
   224             _checkforbidden(files)
       
   225 
       
   226             # if this is changed to support newlines in filenames,
       
   227             # be sure to check the templates/ dir again (especially *-raw.tmpl)
       
   228             hex, flags = revlog.hex, map.flags
       
   229             text = ''.join("%s\0%s%s\n" % (f, hex(map[f]), flags(f))
       
   230                            for f in files)
       
   231             arraytext = array.array('c', text)
       
   232             cachedelta = None
   227 
   233 
   228         n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
   234         n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
   229         self._mancache[n] = (map, arraytext)
   235         self._mancache[n] = (map, arraytext)
   230 
   236 
   231         return n
   237         return n