more formal Mercurial support (with the potential to upgrade to command server);
authorwenzelm
Sun, 02 Oct 2016 19:47:18 +0200
changeset 63997 e11ccb5aa82f
parent 63996 3f47fec9edfc
child 63998 2f38d8aff2f5
more formal Mercurial support (with the potential to upgrade to command server);
src/Pure/General/mercurial.scala
src/Pure/Tools/check_sources.scala
src/Pure/build-jars
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/General/mercurial.scala	Sun Oct 02 19:47:18 2016 +0200
@@ -0,0 +1,38 @@
+/*  Title:      Pure/General/mercurial.scala
+    Author:     Makarius
+
+Support for Mercurial repositories.
+*/
+
+package isabelle
+
+
+import java.io.{File => JFile}
+
+
+object Mercurial
+{
+  /* command-line syntax */
+
+  def opt_rev(rev: String): String = if (rev == "") "" else " --rev " + File.bash_string(rev)
+
+
+  /* repository access */
+
+  def open_repository(root: Path): Repository = new Repository(root)
+
+  class Repository private[Mercurial](val root: Path)
+  {
+    override def toString: String = root.toString
+
+    def close() { }
+
+    def command(cmd: String, cwd: JFile = null): Process_Result =
+      Isabelle_System.hg("--repository " + File.bash_path(root) + " " + cmd, cwd = cwd)
+
+    def manifest(rev: String = "", cwd: JFile = null): List[String] =
+      command("manifest" + opt_rev(rev), cwd = cwd).check.out_lines
+
+    command("root").check
+  }
+}
--- a/src/Pure/Tools/check_sources.scala	Sun Oct 02 19:36:57 2016 +0200
+++ b/src/Pure/Tools/check_sources.scala	Sun Oct 02 19:47:18 2016 +0200
@@ -44,11 +44,12 @@
   def check_hg(root: Path)
   {
     Output.writeln("Checking " + root + " ...")
-    Isabelle_System.hg("--repository " + File.bash_path(root) + " root").check
-    for {
-      file <- Isabelle_System.hg("manifest", cwd = root.file).check.out_lines
-      if file.endsWith(".thy") || file.endsWith(".ML") || file.endsWith("/ROOT")
-    } check_file(root + Path.explode(file))
+    using(Mercurial.open_repository(root)) { hg =>
+      for {
+        file <- hg.manifest()
+        if file.endsWith(".thy") || file.endsWith(".ML") || file.endsWith("/ROOT")
+      } check_file(root + Path.explode(file))
+    }
   }
 
 
--- a/src/Pure/build-jars	Sun Oct 02 19:36:57 2016 +0200
+++ b/src/Pure/build-jars	Sun Oct 02 19:47:18 2016 +0200
@@ -36,6 +36,7 @@
   General/json.scala
   General/linear_set.scala
   General/long_name.scala
+  General/mercurial.scala
   General/multi_map.scala
   General/output.scala
   General/path.scala