From e4f809953f40d291751990a512452b3203752971 Mon Sep 17 00:00:00 2001 From: Sanjin Sehic Date: Mon, 19 Dec 2011 15:28:26 +0100 Subject: [PATCH] Implement resolver for subversion repositories All subversion URIs have to be prefixed with 'svn:' to separate them from URIs for other resolvers. For example, 'svn:https://server/repo' can now be used. --- main/Build.scala | 1 + main/Resolvers.scala | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/main/Build.scala b/main/Build.scala index 4ec004a2b..c6d1f90aa 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -42,6 +42,7 @@ object RetrieveUnit def apply(info: ResolveInfo): Option[() => File] = { info.uri match { + case Scheme("svn") | Scheme("svn+ssh") => Resolvers.subversion(info) case Scheme("hg") => Resolvers.mercurial(info) case Scheme("git") => Resolvers.git(info) case Path(path) if path.endsWith(".git") => Resolvers.git(info) diff --git a/main/Resolvers.scala b/main/Resolvers.scala index bccc3ec89..5558cb9d8 100644 --- a/main/Resolvers.scala +++ b/main/Resolvers.scala @@ -40,6 +40,32 @@ object Resolvers } } + val subversion: Resolver = (info: ResolveInfo) => { + def normalized(uri: URI) = uri.copy(scheme = "svn") + + def checkout(at: URI, into: File, revision: Option[String]) = + { + creates(into) { + revision match { + case Some(r) => + run(None, "svn", "checkout", "-r", r, at.toASCIIString, into.getAbsolutePath) + case None => + run(None, "svn", "checkout", at.toASCIIString, into.getAbsolutePath) + } + } + } + + val uri = info.uri.withoutMarkerScheme + Some { + () => + checkout( + at = uri.withoutFragment, + into = uniqueSubdirectoryFor(normalized(uri), in = info.staging), + revision = Option(uri.getFragment) + ) + } + } + val mercurial: Resolver = new DistributedVCS { override val scheme = "hg"