storage: also use `deltamode argument` for ifiledata
authorBoris Feld <boris.feld@octobus.net>
Tue, 09 Oct 2018 23:26:35 +0200
changeset 53155 6a917075535aa9648a8aecb951d08e51c9159b4b
parent 53154 59a870a4ad6ee47266990f97bc57a4b8a28b42ae
child 53156 968dd7e02ac5ed059b1dba6e883538b835dd38c5
push id1065
push usergszorc@mozilla.com
push dateWed, 31 Oct 2018 02:06:22 +0000
storage: also use `deltamode argument` for ifiledata Now that lower level uses such argument, we can propagate the change to higher layers.
mercurial/changegroup.py
mercurial/filelog.py
mercurial/manifest.py
mercurial/repository.py
mercurial/revlog.py
mercurial/testing/storage.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -692,22 +692,26 @@ def deltagroup(repo, store, nodes, ischa
 
     # We expect the first pass to be fast, so we only engage the progress
     # meter for constructing the revision deltas.
     progress = None
     if topic is not None:
         progress = repo.ui.makeprogress(topic, unit=_('chunks'),
                                         total=len(nodes))
 
+    deltamode = repository.CG_DELTAMODE_STD
+    if forcedeltaparentprev:
+        deltamode = repository.CG_DELTAMODE_PREV
+
     revisions = store.emitrevisions(
         nodes,
         nodesorder=nodesorder,
         revisiondata=True,
         assumehaveparentrevisions=not ellipses,
-        deltaprevious=forcedeltaparentprev)
+        deltamode=deltamode)
 
     for i, revision in enumerate(revisions):
         if progress:
             progress.update(i + 1)
 
         if ellipses:
             linknode = linknodes[revision.node]
 
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -87,21 +87,21 @@ class filelog(object):
     def iscensored(self, rev):
         return self._revlog.iscensored(rev)
 
     def revision(self, node, _df=None, raw=False):
         return self._revlog.revision(node, _df=_df, raw=raw)
 
     def emitrevisions(self, nodes, nodesorder=None,
                       revisiondata=False, assumehaveparentrevisions=False,
-                      deltaprevious=False):
+                      deltamode=repository.CG_DELTAMODE_STD):
         return self._revlog.emitrevisions(
             nodes, nodesorder=nodesorder, revisiondata=revisiondata,
             assumehaveparentrevisions=assumehaveparentrevisions,
-            deltaprevious=deltaprevious)
+            deltamode=deltamode)
 
     def addrevision(self, revisiondata, transaction, linkrev, p1, p2,
                     node=None, flags=revlog.REVIDX_DEFAULT_FLAGS,
                     cachedelta=None):
         return self._revlog.addrevision(revisiondata, transaction, linkrev,
                                     p1, p2, node=node, flags=flags,
                                     cachedelta=cachedelta)
 
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1570,21 +1570,21 @@ class manifestrevlog(object):
     def cmp(self, node, text):
         return self._revlog.cmp(node, text)
 
     def deltaparent(self, rev):
         return self._revlog.deltaparent(rev)
 
     def emitrevisions(self, nodes, nodesorder=None,
                       revisiondata=False, assumehaveparentrevisions=False,
-                      deltaprevious=False):
+                      deltamode=repository.CG_DELTAMODE_STD):
         return self._revlog.emitrevisions(
             nodes, nodesorder=nodesorder, revisiondata=revisiondata,
             assumehaveparentrevisions=assumehaveparentrevisions,
-            deltaprevious=deltaprevious)
+            deltamode=deltamode)
 
     def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None):
         return self._revlog.addgroup(deltas, linkmapper, transaction,
                                      addrevisioncb=addrevisioncb)
 
     def rawsize(self, rev):
         return self._revlog.rawsize(rev)
 
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -613,17 +613,17 @@ class ifiledata(interfaceutil.Interface)
 
         TODO better document the copy metadata and censoring logic.
         """
 
     def emitrevisions(nodes,
                       nodesorder=None,
                       revisiondata=False,
                       assumehaveparentrevisions=False,
-                      deltaprevious=False):
+                      deltamode=CG_DELTAMODE_STD):
         """Produce ``irevisiondelta`` for revisions.
 
         Given an iterable of nodes, emits objects conforming to the
         ``irevisiondelta`` interface that describe revisions in storage.
 
         This method is a generator.
 
         The input nodes may be unordered. Implementations must ensure that a
@@ -656,20 +656,20 @@ class ifiledata(interfaceutil.Interface)
         is used. (Not all storage layers will have strong ordering and behavior
         of this mode is storage-dependent.) ``nodes`` ordering can force
         revisions to be emitted before their ancestors, so consumers should
         use it with care.
 
         The ``linknode`` attribute on the returned ``irevisiondelta`` may not
         be set and it is the caller's responsibility to resolve it, if needed.
 
-        If ``deltaprevious`` is True and revision data is requested, all
-        revision data should be emitted as deltas against the revision
-        emitted just prior. The initial revision should be a delta against
-        its 1st parent.
+        If ``deltamode`` is CG_DELTAMODE_PREV and revision data is requested,
+        all revision data should be emitted as deltas against the revision
+        emitted just prior. The initial revision should be a delta against its
+        1st parent.
         """
 
 class ifilemutation(interfaceutil.Interface):
     """Storage interface for mutation events of a tracked file."""
 
     def add(filedata, meta, transaction, linkrev, p1, p2):
         """Add a new revision to the store.
 
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2200,28 +2200,27 @@ class revlog(object):
 
     def files(self):
         res = [self.indexfile]
         if not self._inline:
             res.append(self.datafile)
         return res
 
     def emitrevisions(self, nodes, nodesorder=None, revisiondata=False,
-                      assumehaveparentrevisions=False, deltaprevious=False):
+                      assumehaveparentrevisions=False,
+                      deltamode=repository.CG_DELTAMODE_STD):
         if nodesorder not in ('nodes', 'storage', None):
             raise error.ProgrammingError('unhandled value for nodesorder: %s' %
                                          nodesorder)
 
         if nodesorder is None and not self._generaldelta:
             nodesorder = 'storage'
 
-        deltamode = repository.CG_DELTAMODE_STD
-        if deltaprevious:
-            deltamode = repository.CG_DELTAMODE_PREV
-        elif not self._storedeltachains:
+        if (not self._storedeltachains and
+                deltamode != repository.CG_DELTAMODE_PREV):
             deltamode = repository.CG_DELTAMODE_FULL
 
         return storageutil.emitrevisions(
             self, nodes, nodesorder, revlogrevisiondelta,
             deltaparentfn=self.deltaparent,
             candeltafn=self.candelta,
             rawsizefn=self.rawsize,
             revdifffn=self.revdiff,
--- a/mercurial/testing/storage.py
+++ b/mercurial/testing/storage.py
@@ -736,34 +736,35 @@ class ifiledatatests(basetestcase):
         self.assertIsNone(rev.baserevisionsize)
         self.assertIsNone(rev.revision)
         self.assertEqual(rev.delta,
                          b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x01' +
                          fulltext1)
 
         # forceprevious=True forces a delta against the previous revision.
         # Special case for initial revision.
-        gen = f.emitrevisions([node0], revisiondata=True, deltaprevious=True)
+        gen = f.emitrevisions([node0], revisiondata=True,
+                              deltamode=repository.CG_DELTAMODE_PREV)
 
         rev = next(gen)
         self.assertEqual(rev.node, node0)
         self.assertEqual(rev.p1node, nullid)
         self.assertEqual(rev.p2node, nullid)
         self.assertEqual(rev.basenode, nullid)
         self.assertIsNone(rev.baserevisionsize)
         self.assertIsNone(rev.revision)
         self.assertEqual(rev.delta,
                          b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00' +
                          fulltext0)
 
         with self.assertRaises(StopIteration):
             next(gen)
 
         gen = f.emitrevisions([node0, node2], revisiondata=True,
-                              deltaprevious=True)
+                              deltamode=repository.CG_DELTAMODE_PREV)
 
         rev = next(gen)
         self.assertEqual(rev.node, node0)
         self.assertEqual(rev.p1node, nullid)
         self.assertEqual(rev.p2node, nullid)
         self.assertEqual(rev.basenode, nullid)
         self.assertIsNone(rev.baserevisionsize)
         self.assertIsNone(rev.revision)