dirstate: fold parse into read
authorMatt Mackall <mpm@selenic.com>
Mon, 18 Jun 2007 13:24:33 -0500
changeset 4607 49dcac6ede26
parent 4606 2651099c5018
child 4608 220211b88656
dirstate: fold parse into read
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Jun 18 13:24:33 2007 -0500
+++ b/mercurial/dirstate.py	Mon Jun 18 13:24:33 2007 -0500
@@ -204,11 +204,22 @@
         except KeyError:
             return "?"
 
-    def parse(self, st):
+    def read(self):
+        self.map = {}
+        self.copymap = {}
+        self.pl = [nullid, nullid]
+        try:
+            st = self.opener("dirstate").read()
+        except IOError, err:
+            if err.errno != errno.ENOENT: raise
+            return
+        if not st:
+            return
+
         self.pl = [st[:20], st[20: 40]]
 
         # deref fields so they will be local in loop
-        map = self.map
+        dmap = self.map
         copymap = self.copymap
         format = self.format
         unpack = struct.unpack
@@ -226,20 +237,9 @@
             if '\0' in f:
                 f, c = f.split('\0')
                 copymap[f] = c
-            map[f] = e[:4]
+            dmap[f] = e[:4]
             pos = newpos
 
-    def read(self):
-        self.map = {}
-        self.copymap = {}
-        self.pl = [nullid, nullid]
-        try:
-            st = self.opener("dirstate").read()
-            if st:
-                self.parse(st)
-        except IOError, err:
-            if err.errno != errno.ENOENT: raise
-
     def reload(self):
         for a in "map copymap _branch pl dirs".split():
             if hasattr(self, a):