Patchwork [1,of,6] dirstate: use self._filename instead of immediate string `dirstate`

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 19, 2015, 4:42 p.m.
Message ID <9832a882c21e23139b6b.1432053721@feefifofum>
Download mbox | patch
Permalink /patch/9182/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Katsunori FUJIWARA - May 19, 2015, 4:42 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1432051569 -32400
#      Wed May 20 01:06:09 2015 +0900
# Node ID 9832a882c21e23139b6bda2b5004c4253b3b35df
# Parent  472a685a49618c684ef7a03ce977bc442f7b6ce8
dirstate: use self._filename instead of immediate string `dirstate`

This prevents immediate string `dirstate` from studding. This is also
a preparation for making dirstate aware of PENDING mechanism in
subsequent patches.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -47,6 +47,7 @@ 
         self._ui = ui
         self._filecache = {}
         self._parentwriters = 0
+        self._filename = 'dirstate'
 
     def beginparentchange(self):
         '''Marks the beginning of a set of changes that involve changing
@@ -121,7 +122,7 @@ 
     @propertycache
     def _pl(self):
         try:
-            fp = self._opener("dirstate")
+            fp = self._opener(self._filename)
             st = fp.read(40)
             fp.close()
             l = len(st)
@@ -319,7 +320,7 @@ 
         self._map = {}
         self._copymap = {}
         try:
-            st = self._opener.read("dirstate")
+            st = self._opener.read(self._filename)
         except IOError, err:
             if err.errno != errno.ENOENT:
                 raise
@@ -586,7 +587,7 @@ 
             import time # to avoid useless import
             time.sleep(delaywrite)
 
-        st = self._opener("dirstate", "w", atomictemp=True)
+        st = self._opener(self._filename, "w", atomictemp=True)
         # use the modification time of the newly created temporary file as the
         # filesystem's notion of 'now'
         now = util.fstat(st).st_mtime