Simplify checkout slightly, replace checkdir with os.makedirs
authormpm@selenic.com
Fri, 20 May 2005 17:33:24 -0800
changeset 114 82fb6d09f911
parent 113 1918852a67a8
child 115 39b438eeb25a
Simplify checkout slightly, replace checkdir with os.makedirs
mercurial/hg.py
--- a/mercurial/hg.py	Fri May 20 17:31:55 2005 -0800
+++ b/mercurial/hg.py	Fri May 20 17:33:24 2005 -0800
@@ -343,35 +343,26 @@
         self.dircache.update(new)
         self.dircache.remove(remove)
 
-    def checkdir(self, path):
-        d = os.path.dirname(path)
-        if not d: return
-        if not os.path.isdir(d):
-            self.checkdir(d)
-            os.mkdir(d)
-
     def checkout(self, node):
         # checkout is really dumb at the moment
         # it ought to basically merge
         change = self.changelog.read(node)
-        mmap = self.manifest.read(change[0])
-
-        l = mmap.keys()
+        l = self.manifest.read(change[0]).items()
         l.sort()
-        stats = []
-        for f in l:
-            self.ui.note(f + "\n")
-            r = self.file(f)
-            t = r.revision(mmap[f])
+
+        for f,n in l:
+            if f[0] == "/": continue
+            self.ui.note(f, "\n")
+            t = self.file(f).revision(n)
             try:
                 file(f, "w").write(t)
-            except:
-                self.checkdir(f)
+            except IOError:
+                os.makedirs(os.path.dirname(f))
                 file(f, "w").write(t)
 
         self.setcurrent(node)
         self.dircache.clear()
-        self.dircache.update(l)
+        self.dircache.update([f for f,n in l])
 
     def diffdir(self, path, changeset):
         changed = []