mercurial/dirstate.py
changeset 32770 b698921ee137
parent 32702 e696f597d02f
child 32792 7ad95626f6a7
--- a/mercurial/dirstate.py	Fri Jun 09 13:07:48 2017 +0900
+++ b/mercurial/dirstate.py	Fri Jun 09 13:07:48 2017 +0900
@@ -159,6 +159,11 @@
         return self._copymap
 
     @propertycache
+    def _identity(self):
+        self._read()
+        return self._identity
+
+    @propertycache
     def _nonnormalset(self):
         nonnorm, otherparents = nonnormalentries(self._map)
         self._otherparentset = otherparents
@@ -426,6 +431,8 @@
     def _read(self):
         self._map = {}
         self._copymap = {}
+        # ignore HG_PENDING because identity is used only for writing
+        self._identity = util.filestat(self._opener.join(self._filename))
         try:
             fp = self._opendirstatefile()
             try:
@@ -476,7 +483,8 @@
         rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
         check whether the dirstate has changed before rereading it.'''
 
-        for a in ("_map", "_copymap", "_filefoldmap", "_dirfoldmap", "_branch",
+        for a in ("_map", "_copymap", "_identity",
+                  "_filefoldmap", "_dirfoldmap", "_branch",
                   "_pl", "_dirs", "_ignore", "_nonnormalset",
                   "_otherparentset"):
             if a in self.__dict__:
@@ -741,6 +749,14 @@
 
         self._dirty = True
 
+    def identity(self):
+        '''Return identity of dirstate itself to detect changing in storage
+
+        If identity of previous dirstate is equal to this, writing
+        changes based on the former dirstate out can keep consistency.
+        '''
+        return self._identity
+
     def write(self, tr):
         if not self._dirty:
             return