src/Pure/General/mercurial.scala
changeset 64252 e84cba30d7ff
parent 64233 ef6f7e8a018c
child 64255 a9f540881611
--- a/src/Pure/General/mercurial.scala	Sun Oct 16 13:11:47 2016 +0200
+++ b/src/Pure/General/mercurial.scala	Sun Oct 16 13:27:01 2016 +0200
@@ -40,13 +40,15 @@
   }
 
   def setup_repository(source: String, root: Path, ssh: Option[SSH.Session] = None): Repository =
-    ssh match {
-      case None => if (root.is_dir) repository(root) else clone_repository(source, root)
-      case Some(session) =>
-        using(session.sftp())(sftp =>
-          if (sftp.is_dir(root)) repository(root, ssh = ssh)
-          else clone_repository(source, root, ssh = ssh))
-    }
+  {
+    val present =
+      ssh match {
+        case None => root.is_dir
+        case Some(session) => using(session.sftp())(_.is_dir(root))
+      }
+    if (present) { val hg = repository(root, ssh = ssh); hg.pull(); hg }
+    else clone_repository(source, root, options = "--noupdate", ssh = ssh)
+  }
 
   class Repository private[Mercurial](root_path: Path, ssh: Option[SSH.Session])
   {