Patchwork [3,of,5,V2] dirstate: add dirstatetuple to create dirstate values

login
register
mail settings
Submitter Siddharth Agarwal
Date May 29, 2014, 11:19 p.m.
Message ID <1c01003e3a34dc7ec6a8.1401405558@dev1738.prn1.facebook.com>
Download mbox | patch
Permalink /patch/4900/
State Accepted
Commit 7537e57f5dbd0805aad3c9e5e4f7dd8bbf6bbde1
Headers show

Comments

Siddharth Agarwal - May 29, 2014, 11:19 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1401235828 25200
#      Tue May 27 17:10:28 2014 -0700
# Node ID 1c01003e3a34dc7ec6a867da5fa587ecf6926fc7
# Parent  c8b554d5951988222aeab65ef56eaf291c2ec930
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.

Patch

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