Patchwork [3,of,7] manifestctx: add _revlog() function

login
register
mail settings
Submitter Durham Goode
Date Nov. 8, 2016, 4:42 p.m.
Message ID <801efaac42a7088b8f09.1478623377@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17410/
State Accepted
Headers show

Comments

Durham Goode - Nov. 8, 2016, 4:42 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1478621023 28800
#      Tue Nov 08 08:03:43 2016 -0800
# Node ID 801efaac42a7088b8f09e9d37b11e7d7d8a9c21b
# Parent  734fe516a6a23c43bfb56543e8e12b419b715b8d
manifestctx: add _revlog() function

The `self._repo.manifestlog._revlog` code is getting copy and pasted a lot in
manifestctx. Let's make it a function so it can be reused. This will make future
patches cleaner too.

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1335,6 +1335,9 @@  class manifestctx(object):
         #rev = revlog.rev(node)
         #self.linkrev = revlog.linkrev(rev)
 
+    def _revlog(self):
+        return self._repo.manifestlog._revlog
+
     def node(self):
         return self._node
 
@@ -1343,7 +1346,7 @@  class manifestctx(object):
             if self._node == revlog.nullid:
                 self._data = manifestdict()
             else:
-                rl = self._repo.manifestlog._revlog
+                rl = self._revlog()
                 text = rl.revision(self._node)
                 arraytext = array.array('c', text)
                 rl._fulltextcache[self._node] = arraytext
@@ -1357,7 +1360,7 @@  class manifestctx(object):
 
         If `shallow` is True, nothing changes since this is a flat manifest.
         '''
-        rl = self._repo.manifestlog._revlog
+        rl = self._revlog()
         r = rl.rev(self._node)
         deltaparent = rl.deltaparent(r)
         if deltaparent != revlog.nullrev and deltaparent in rl.parentrevs(r):
@@ -1371,7 +1374,7 @@  class manifestctx(object):
 
         Changing the value of `shallow` has no effect on flat manifests.
         '''
-        revlog = self._repo.manifestlog._revlog
+        revlog = self._revlog()
         if revlog._usemanifestv2:
             # Need to perform a slow delta
             r0 = revlog.deltaparent(revlog.rev(self._node))