src/Pure/General/mercurial.scala
author wenzelm
Sun, 02 Oct 2016 19:47:18 +0200
changeset 63997 e11ccb5aa82f
child 63998 2f38d8aff2f5
permissions -rw-r--r--
more formal Mercurial support (with the potential to upgrade to command server);

/*  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
  }
}