Patchwork [5,of,8,"] manifestcache: abstract the filename in a class attribute

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2019, 10:36 a.m.
Message ID <fe4fb6f5891c9990e4cd.1552732586@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39287/
State Accepted
Headers show

Comments

Pierre-Yves David - March 16, 2019, 10:36 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1552652250 0
#      Fri Mar 15 12:17:30 2019 +0000
# Node ID fe4fb6f5891c9990e4cdfe22919a8f4d64f3bcf5
# Parent  79362091afef9fb409ebe8385172ca2fa4aa4cd4
# EXP-Topic manifestcache
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fe4fb6f5891c
manifestcache: abstract the filename in a class attribute

This make the code clearer and simpler to update.

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1276,6 +1276,9 @@  class manifestfulltextcache(util.lrucach
     These are written in reverse cache order (oldest to newest).
 
     """
+
+    _file = 'manifestfulltextcache'
+
     def __init__(self, max):
         super(manifestfulltextcache, self).__init__(max)
         self._dirty = False
@@ -1287,7 +1290,7 @@  class manifestfulltextcache(util.lrucach
             return
 
         try:
-            with self._opener('manifestfulltextcache') as fp:
+            with self._opener(self._file) as fp:
                 set = super(manifestfulltextcache, self).__setitem__
                 # ignore trailing data, this is a cache, corruption is skipped
                 while True:
@@ -1313,8 +1316,7 @@  class manifestfulltextcache(util.lrucach
         if not self._dirty or self._opener is None:
             return
         # rotate backwards to the first used node
-        with self._opener(
-                'manifestfulltextcache', 'w', atomictemp=True, checkambig=True
+        with self._opener(self._file, 'w', atomictemp=True, checkambig=True
             ) as fp:
             node = self._head.prev
             while True: