Patchwork [1,of,3,fix-default] addrevision: rename 'd' to 'delta'

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 2, 2015, 8:37 a.m.
Message ID <ebf8b06f9dbfe03e2877.1449045443@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11739/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 2, 2015, 8:37 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1449012551 28800
#      Tue Dec 01 15:29:11 2015 -0800
# Node ID ebf8b06f9dbfe03e28776032f5dc3d64db18579b
# Parent  5ca02ed199d88c84f05fc5a1064164e975c205cf
# EXP-Topic generaldelta
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r ebf8b06f9dbf
addrevision: rename 'd' to 'delta'

That variable is quite central to the whole function. Giving it a more explicit
name help with code readability.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1406,11 +1406,11 @@  class revlog(object):
         curr = len(self)
         prev = curr - 1
         base = chainbase = curr
         chainlen = None
         offset = self.end(prev)
-        d = None
+        delta = None
         if self._basecache is None:
             self._basecache = (prev, self.chainbase(prev))
         basecache = self._basecache
         p1r, p2r = self.rev(p1), self.rev(p2)
 
@@ -1425,45 +1425,45 @@  class revlog(object):
         # should we try to build a delta?
         if prev != nullrev:
             if cachedelta and self._generaldelta and self._lazydeltabase:
                 # Assume what we received from the server is a good choice
                 # build delta will reuse the cache
-                d = builddelta(cachedelta[0])
+                delta = builddelta(cachedelta[0])
             elif self._generaldelta:
                 if p2r != nullrev and self._aggressivemergedeltas:
-                    d = builddelta(p1r)
-                    d2 = builddelta(p2r)
-                    p1good = self._isgooddelta(d, textlen)
-                    p2good = self._isgooddelta(d2, textlen)
+                    delta = builddelta(p1r)
+                    delta2 = builddelta(p2r)
+                    p1good = self._isgooddelta(delta, textlen)
+                    p2good = self._isgooddelta(delta2, textlen)
                     if p1good and p2good:
                         # If both are good deltas, choose the smallest
-                        if d2[1] < d[1]:
-                            d = d2
+                        if delta2[1] < delta[1]:
+                            delta = delta2
                     elif p2good:
                         # If only p2 is good, use it
-                        d = d2
+                        delta = delta2
                     elif p1good:
                         pass
                     else:
                         # Neither is good, try against prev to hopefully save us
                         # a fulltext.
-                        d = builddelta(prev)
+                        delta = builddelta(prev)
                 else:
                     # Pick whichever parent is closer to us (to minimize the
                     # chance of having to build a fulltext). Since
                     # nullrev == -1, any non-merge commit will always pick p1r.
                     drev = p2r if p2r > p1r else p1r
-                    d = builddelta(drev)
+                    delta = builddelta(drev)
                     # If the chosen delta will result in us making a full text,
                     # give it one last try against prev.
-                    if drev != prev and not self._isgooddelta(d, textlen):
-                        d = builddelta(prev)
+                    if drev != prev and not self._isgooddelta(delta, textlen):
+                        delta = builddelta(prev)
             else:
-                d = builddelta(prev)
-            dist, l, data, base, chainbase, chainlen, compresseddeltalen = d
+                delta = builddelta(prev)
+            dist, l, data, base, chainbase, chainlen, compresseddeltalen = delta
 
-        if not self._isgooddelta(d, textlen):
+        if not self._isgooddelta(delta, textlen):
             text = buildtext()
             data = self.compress(text)
             l = len(data[1]) + len(data[0])
             base = chainbase = curr