src/Pure/Thy/thy_resources.scala
changeset 68949 e848328cb2c1
parent 68947 ea804c814693
child 68951 a7b1fe2d30ad
--- a/src/Pure/Thy/thy_resources.scala	Sat Sep 08 14:30:31 2018 +0200
+++ b/src/Pure/Thy/thy_resources.scala	Sat Sep 08 16:52:38 2018 +0200
@@ -153,18 +153,23 @@
       {
         val st1 =
           if (commit.isDefined) {
-            val committed =
-              for {
-                name <- dep_theories
-                if !already_committed.isDefinedAt(name) && state.node_consolidated(version, name)
-              }
-              yield {
-                val snapshot = stable_snapshot(state, version, name)
-                val status = Document_Status.Node_Status.make(state, version, name)
-                commit.get.apply(snapshot, status)
-                (name -> status)
-              }
-            copy(already_committed = already_committed ++ committed)
+            val already_committed1 =
+              (already_committed /: dep_theories)({ case (committed, name) =>
+                def parents_committed: Boolean =
+                  version.nodes(name).header.imports.forall({ case (parent, _) =>
+                    Sessions.is_pure(parent.theory) || committed.isDefinedAt(parent)
+                  })
+                if (!committed.isDefinedAt(name) && parents_committed &&
+                    state.node_consolidated(version, name))
+                {
+                  val snapshot = stable_snapshot(state, version, name)
+                  val status = Document_Status.Node_Status.make(state, version, name)
+                  commit.get.apply(snapshot, status)
+                  committed + (name -> status)
+                }
+                else committed
+              })
+            copy(already_committed = already_committed1)
           }
           else this