mercurial/manifest.py
changeset 44663 948fac24bc39
parent 44352 0bf3b5e80d30
child 44664 8c66a680f396
equal deleted inserted replaced
44662:25d97090c6ca 44663:948fac24bc39
  1210 
  1210 
  1211         if not ret._isempty():
  1211         if not ret._isempty():
  1212             ret._dirty = True
  1212             ret._dirty = True
  1213         return ret
  1213         return ret
  1214 
  1214 
       
  1215     def fastdelta(self, base, changes):
       
  1216         raise FastdeltaUnavailable()
       
  1217 
  1215     def diff(self, m2, match=None, clean=False):
  1218     def diff(self, m2, match=None, clean=False):
  1216         '''Finds changes between the current manifest and m2.
  1219         '''Finds changes between the current manifest and m2.
  1217 
  1220 
  1218         Args:
  1221         Args:
  1219           m2: the manifest to which this manifest should be compared.
  1222           m2: the manifest to which this manifest should be compared.
  1486 # and upper bound of what we expect from compression
  1489 # and upper bound of what we expect from compression
  1487 # (real live value seems to be "3")
  1490 # (real live value seems to be "3")
  1488 MAXCOMPRESSION = 3
  1491 MAXCOMPRESSION = 3
  1489 
  1492 
  1490 
  1493 
       
  1494 class FastdeltaUnavailable(Exception):
       
  1495     """Exception raised when fastdelta isn't usable on a manifest."""
       
  1496 
       
  1497 
  1491 @interfaceutil.implementer(repository.imanifeststorage)
  1498 @interfaceutil.implementer(repository.imanifeststorage)
  1492 class manifestrevlog(object):
  1499 class manifestrevlog(object):
  1493     '''A revlog that stores manifest texts. This is responsible for caching the
  1500     '''A revlog that stores manifest texts. This is responsible for caching the
  1494     full-text manifest contents.
  1501     full-text manifest contents.
  1495     '''
  1502     '''
  1612         added,
  1619         added,
  1613         removed,
  1620         removed,
  1614         readtree=None,
  1621         readtree=None,
  1615         match=None,
  1622         match=None,
  1616     ):
  1623     ):
  1617         if p1 in self.fulltextcache and util.safehasattr(m, b'fastdelta'):
  1624         try:
       
  1625             if p1 not in self.fulltextcache:
       
  1626                 raise FastdeltaUnavailable()
  1618             # If our first parent is in the manifest cache, we can
  1627             # If our first parent is in the manifest cache, we can
  1619             # compute a delta here using properties we know about the
  1628             # compute a delta here using properties we know about the
  1620             # manifest up-front, which may save time later for the
  1629             # manifest up-front, which may save time later for the
  1621             # revlog layer.
  1630             # revlog layer.
  1622 
  1631 
  1631             cachedelta = self._revlog.rev(p1), deltatext
  1640             cachedelta = self._revlog.rev(p1), deltatext
  1632             text = util.buffer(arraytext)
  1641             text = util.buffer(arraytext)
  1633             n = self._revlog.addrevision(
  1642             n = self._revlog.addrevision(
  1634                 text, transaction, link, p1, p2, cachedelta
  1643                 text, transaction, link, p1, p2, cachedelta
  1635             )
  1644             )
  1636         else:
  1645         except FastdeltaUnavailable:
  1637             # The first parent manifest isn't already loaded, so we'll
  1646             # The first parent manifest isn't already loaded or the
  1638             # just encode a fulltext of the manifest and pass that
  1647             # manifest implementation doesn't support fastdelta, so
  1639             # through to the revlog layer, and let it handle the delta
  1648             # we'll just encode a fulltext of the manifest and pass
  1640             # process.
  1649             # that through to the revlog layer, and let it handle the
       
  1650             # delta process.
  1641             if self._treeondisk:
  1651             if self._treeondisk:
  1642                 assert readtree, b"readtree must be set for treemanifest writes"
  1652                 assert readtree, b"readtree must be set for treemanifest writes"
  1643                 assert match, b"match must be specified for treemanifest writes"
  1653                 assert match, b"match must be specified for treemanifest writes"
  1644                 m1 = readtree(self.tree, p1)
  1654                 m1 = readtree(self.tree, p1)
  1645                 m2 = readtree(self.tree, p2)
  1655                 m2 = readtree(self.tree, p2)