add dirstate._dirtypl variable
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Thu, 19 Jul 2007 19:43:25 -0300
changeset 4952 a11921d24ec4
parent 4951 667290b6c95e
child 4953 6b3ed43f77ba
add dirstate._dirtypl variable Theoretically, it's possible to forget modified dirstate parents by doing: dirstate.invalidate() dirstate.setparents(p1, p2) dirstate._map The final access to _map should call _read(), which will unconditionally overwrite dirstate._pl. This doesn't actually happen right now because invalidate accidentally ends up rebuilding dirstate._map.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Thu Jul 19 19:43:25 2007 -0300
+++ b/mercurial/dirstate.py	Thu Jul 19 19:43:25 2007 -0300
@@ -21,6 +21,7 @@
         self._opener = opener
         self._root = root
         self._dirty = 0
+        self._dirtypl = 0
         self._ui = ui
 
     def __getattr__(self, name):
@@ -114,6 +115,7 @@
 
     def setparents(self, p1, p2=nullid):
         self.markdirty()
+        self._dirtypl = 1
         self._pl = p1, p2
 
     def setbranch(self, branch):
@@ -126,7 +128,8 @@
     def _read(self):
         self._map = {}
         self._copymap = {}
-        self._pl = [nullid, nullid]
+        if not self._dirtypl:
+            self._pl = [nullid, nullid]
         try:
             st = self._opener("dirstate").read()
         except IOError, err:
@@ -135,7 +138,8 @@
         if not st:
             return
 
-        self._pl = [st[:20], st[20: 40]]
+        if not self._dirtypl:
+            self._pl = [st[:20], st[20: 40]]
 
         # deref fields so they will be local in loop
         dmap = self._map
@@ -262,6 +266,7 @@
         st.write(cs.getvalue())
         st.rename()
         self._dirty = 0
+        self._dirtypl = 0
 
     def filterfiles(self, files):
         ret = {}