--- a/src/Pure/General/mercurial.scala Sun May 14 17:19:46 2017 +0200
+++ b/src/Pure/General/mercurial.scala Sun May 14 20:16:13 2017 +0200
@@ -10,6 +10,9 @@
import java.io.{File => JFile}
+import scala.annotation.tailrec
+import scala.collection.mutable
+
object Mercurial
{
@@ -155,4 +158,32 @@
}
}
}
+
+
+ /* unknown files */
+
+ def unknown_files(files: List[Path], ssh: Option[SSH.Session] = None): List[Path] =
+ {
+ val unknown = new mutable.ListBuffer[Path]
+
+ @tailrec def check(paths: List[Path])
+ {
+ paths match {
+ case path :: rest =>
+ find_repository(path, ssh) match {
+ case None => unknown += path; check(rest)
+ case Some(hg) =>
+ val known =
+ hg.known_files().iterator.map(name =>
+ (hg.root + Path.explode(name)).file.getCanonicalFile).toSet
+ if (!known(path.file.getCanonicalFile)) unknown += path
+ check(rest.filterNot(p => known(p.file.getCanonicalFile)))
+ }
+ case Nil =>
+ }
+ }
+
+ check(files)
+ unknown.toList
+ }
}
--- a/src/Pure/Tools/build.scala Sun May 14 17:19:46 2017 +0200
+++ b/src/Pure/Tools/build.scala Sun May 14 20:16:13 2017 +0200
@@ -338,6 +338,7 @@
def build(
options: Options,
progress: Progress = No_Progress,
+ check_unknown_files: Boolean = false,
build_heap: Boolean = false,
clean_build: Boolean = false,
dirs: List[Path] = Nil,
@@ -377,6 +378,19 @@
def sources_stamp(name: String): List[String] =
(selected_sessions(name).meta_digest :: deps.sources(name)).map(_.toString).sorted
+ if (check_unknown_files) {
+ val source_files =
+ (for {
+ (_, base) <- deps.session_bases.iterator
+ (path, _) <- base.sources.iterator
+ } yield path).toList
+ val unknown_files = Mercurial.unknown_files(source_files)
+ if (unknown_files.nonEmpty) {
+ progress.echo_warning("Unknown files (not part of a Mercurial repository):" +
+ unknown_files.map(path => path.expand.implode).sorted.mkString("\n ", "\n ", ""))
+ }
+ }
+
/* main build process */
@@ -680,6 +694,7 @@
val results =
progress.interrupt_handler {
build(options, progress,
+ check_unknown_files = Mercurial.is_repository(Path.explode("~~")),
build_heap = build_heap,
clean_build = clean_build,
dirs = dirs,