D758: dirstate: move parent reading to the dirstatemap class

durham (Durham Goode) phabricator at mercurial-scm.org
Thu Sep 21 00:03:51 UTC 2017


durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As part of moving dirstate storage logic to a separate class, let's move the
  function that reads the parents from the file. This will allow extensions to
  write dirstate's that store the parents in other ways.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D758

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -186,19 +186,7 @@
 
     @propertycache
     def _pl(self):
-        try:
-            fp = self._map._opendirstatefile()
-            st = fp.read(40)
-            fp.close()
-            l = len(st)
-            if l == 40:
-                return st[:20], st[20:40]
-            elif l > 0 and l < 40:
-                raise error.Abort(_('working directory state appears damaged!'))
-        except IOError as err:
-            if err.errno != errno.ENOENT:
-                raise
-        return [nullid, nullid]
+        return self._map.parents()
 
     @propertycache
     def _dirs(self):
@@ -1375,3 +1363,17 @@
         self._pendingmode = mode
         return fp
 
+    def parents(self):
+        try:
+            fp = self._opendirstatefile()
+            st = fp.read(40)
+            fp.close()
+            l = len(st)
+            if l == 40:
+                return st[:20], st[20:40]
+            elif l > 0 and l < 40:
+                raise error.Abort(_('working directory state appears damaged!'))
+        except IOError as err:
+            if err.errno != errno.ENOENT:
+                raise
+        return [nullid, nullid]



To: durham, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list