[PATCH 3 of 5] dirstate: add dirstatetuple to create dirstate values

Siddharth Agarwal sid0 at fb.com
Wed May 28 00:05:19 CDT 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1401235828 25200
#      Tue May 27 17:10:28 2014 -0700
# Node ID 15a5e7f16a39f1991f2c510a8b8bccefbccfcc6c
# Parent  bd159c3071e91c5764e255253e2cec1eb703006f
dirstate: add dirstatetuple to create dirstate values

Upcoming patches will switch away from using Python tuples for dirstate values
in compiled builds.  Make that easier by introducing a variable called
dirstatetuple, currently set to tuple. In upcoming patches, this will be set to
an object from the parsers module.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -14,6 +14,10 @@
 filecache = scmutil.filecache
 _rangemask = 0x7fffffff
 
+def dirstatetuple(*x):
+    # x is a tuple
+    return x
+
 class repocache(filecache):
     """filecache for files in .hg/"""
     def join(self, obj, fname):
@@ -335,7 +339,7 @@
         if oldstate in "?r" and "_dirs" in self.__dict__:
             self._dirs.addpath(f)
         self._dirty = True
-        self._map[f] = (state, mode, size, mtime)
+        self._map[f] = dirstatetuple(state, mode, size, mtime)
 
     def normal(self, f):
         '''Mark a file normal and clean.'''
@@ -400,7 +404,7 @@
                 size = -1
             elif entry[0] == 'n' and entry[2] == -2: # other parent
                 size = -2
-        self._map[f] = ('r', 0, size, 0)
+        self._map[f] = dirstatetuple('r', 0, size, 0)
         if size == 0 and f in self._copymap:
             del self._copymap[f]
 
@@ -493,9 +497,9 @@
                 self._map[f] = oldmap[f]
             else:
                 if 'x' in allfiles.flags(f):
-                    self._map[f] = ('n', 0777, -1, 0)
+                    self._map[f] = dirstatetuple('n', 0777, -1, 0)
                 else:
-                    self._map[f] = ('n', 0666, -1, 0)
+                    self._map[f] = dirstatetuple('n', 0666, -1, 0)
         self._pl = (parent, nullid)
         self._dirty = True
 


More information about the Mercurial-devel mailing list