X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Flib%2Fsvn%2FSvnKitDriver.java;h=e6ef52c49961ce6ebf0da7149032b8f5945a35fb;hb=5fcacdb600e4c9e765cb93b46132932662832c1b;hp=365f7ba73ceec2901fa52321e5f70d9206250138;hpb=6e4e2314ce0605519c6165a7e34fde9a3418217a;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/lib/svn/SvnKitDriver.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/lib/svn/SvnKitDriver.java index 365f7ba73..e6ef52c49 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/lib/svn/SvnKitDriver.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/lib/svn/SvnKitDriver.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.lib.svn; import java.io.File; @@ -5,8 +21,11 @@ import java.io.OutputStream; import java.util.List; import java.util.Vector; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; import org.argeo.slc.deploy.VersioningDriver; +import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; @@ -14,15 +33,19 @@ import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNRevision; +import org.tmatesoft.svn.core.wc.SVNWCUtil; import org.tmatesoft.svn.core.wc.admin.ISVNChangeEntryHandler; import org.tmatesoft.svn.core.wc.admin.SVNChangeEntry; +/** Versioning driver with a Subversion backen, based on SVNKit */ public class SvnKitDriver implements VersioningDriver { + private final static Log log = LogFactory.getLog(SvnKitDriver.class); + private final SVNClientManager manager; public SvnKitDriver() { - DAVRepositoryFactory.setup(); - FSRepositoryFactory.setup(); + DAVRepositoryFactory.setup(); + FSRepositoryFactory.setup(); manager = SVNClientManager.newInstance(); } @@ -48,12 +71,37 @@ public class SvnKitDriver implements VersioningDriver { } } - @SuppressWarnings("deprecation") - public void checkout(String repositoryUrl, File destDir, Boolean recursive) { + public Boolean checkout(String repositoryUrl, File destDir, + Boolean recursive) { try { - manager.getUpdateClient().doCheckout( + SVNRevision previousRevision = null; + if (destDir.exists() && SVNWCUtil.isVersionedDirectory(destDir)) { + previousRevision = manager.getWCClient().doInfo(destDir, null) + .getRevision(); + } + if (previousRevision == null && log.isDebugEnabled()) + log.debug("Checking out " + repositoryUrl + " to " + destDir + + "..."); + long revision = manager.getUpdateClient().doCheckout( SVNURL.parseURIDecoded(repositoryUrl), destDir, - SVNRevision.UNDEFINED, SVNRevision.HEAD, recursive); + SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY, + recursive); + if (previousRevision != null + && previousRevision.getNumber() == revision) { + if (log.isTraceEnabled()) + log.trace(destDir + " already at revision " + revision); + return false; + + } else { + if (log.isDebugEnabled()) + if (previousRevision != null) + log.debug(destDir + " updated to revision " + revision + + " from " + previousRevision.getNumber()); + else + log.debug(destDir + " checked out to revision " + + revision); + return true; + } } catch (Exception e) { throw new SlcException("Cannot checkout " + repositoryUrl + " to " + destDir, e);