hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1505126 - in /httpcomponents/project-release-tools/trunk: ./ buildSrc/src/main/groovy/
Date Sat, 20 Jul 2013 12:21:12 GMT
Author: olegk
Date: Sat Jul 20 12:21:11 2013
New Revision: 1505126

URL: http://svn.apache.org/r1505126
Log:
Improved SVN get, update and status tasks

Added:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnScheduleForAddition.groovy
      - copied, changed from r1504953, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnUpdate.groovy
      - copied, changed from r1504953, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy
Modified:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnContentTask.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy
    httpcomponents/project-release-tools/trunk/rc.gradle

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy?rev=1505126&r1=1505125&r2=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy Sat Jul
20 12:21:11 2013
@@ -25,82 +25,107 @@
  *
  */
 
-import org.tmatesoft.svn.cli.svn.SVNCommandEnvironment
-import org.tmatesoft.svn.cli.svn.SVNNotifyPrinter
-import org.tmatesoft.svn.cli.svn.SVNStatusPrinter
+import org.tmatesoft.svn.cli.svn.SVNCommandEnvironment
+import org.tmatesoft.svn.cli.svn.SVNNotifyPrinter
+import org.tmatesoft.svn.cli.svn.SVNStatusPrinter
+import org.tmatesoft.svn.core.SVNDepth
 import org.tmatesoft.svn.core.SVNException
 import org.tmatesoft.svn.core.SVNURL
-import org.tmatesoft.svn.core.internal.wc17.SVNWCContext
-import org.tmatesoft.svn.core.internal.wc2.compat.SvnCodec
+import org.tmatesoft.svn.core.internal.wc17.SVNWCContext
+import org.tmatesoft.svn.core.internal.wc2.compat.SvnCodec
 import org.tmatesoft.svn.core.wc.SVNWCUtil
 import org.tmatesoft.svn.core.wc2.ISvnObjectReceiver
 import org.tmatesoft.svn.core.wc2.SvnCheckout
 import org.tmatesoft.svn.core.wc2.SvnGetStatus
 import org.tmatesoft.svn.core.wc2.SvnOperationFactory
+import org.tmatesoft.svn.core.wc2.SvnScheduleForAddition
 import org.tmatesoft.svn.core.wc2.SvnStatus
 import org.tmatesoft.svn.core.wc2.SvnTarget
 import org.tmatesoft.svn.core.wc2.SvnUpdate
 
 class Svn {
 
-    private static SVNCommandEnvironment getSVNCommandEnvironment() {
-        new SVNCommandEnvironment("SVN", System.out, System.err, System.in);
-    }
-
-    private static SvnOperationFactory createOperationFactory(SVNCommandEnvironment env)
{
+    private static SVNCommandEnvironment getSVNCommandEnvironment() {
+        new SVNCommandEnvironment("SVN", System.out, System.err, System.in);
+    }
+
+    private static SvnOperationFactory createOperationFactory(SVNCommandEnvironment env)
{
         SvnOperationFactory opfactory = new SvnOperationFactory()
         opfactory.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager())
-        opfactory.setEventHandler(new SVNNotifyPrinter(env))
-        opfactory
-    }
-
-    static void checkout(URI src, File dst) {
-        SVNCommandEnvironment env = getSVNCommandEnvironment()
-        SvnOperationFactory opfactory = createOperationFactory(env)
+        opfactory.setEventHandler(new SVNNotifyPrinter(env))
+        opfactory
+    }
+
+    static void checkout(URI src, File dst) {
+        SVNCommandEnvironment env = getSVNCommandEnvironment()
+        SvnOperationFactory opfactory = createOperationFactory(env)
         try {
-            SvnCheckout checkoutOp = opfactory.createCheckout()
-            checkoutOp.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(src.toASCIIString())))
-            checkoutOp.setSingleTarget(SvnTarget.fromFile(dst))
-            checkoutOp.run()
+            SvnCheckout checkoutOp = opfactory.createCheckout()
+            checkoutOp.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(src.toASCIIString())))
+            checkoutOp.setSingleTarget(SvnTarget.fromFile(dst))
+            checkoutOp.run()
         } finally {
             opfactory.dispose()
         }
     }
 
     static void update(File dir) {
-        SVNCommandEnvironment env = getSVNCommandEnvironment()
-        SvnOperationFactory opfactory = createOperationFactory(env)
+        SVNCommandEnvironment env = getSVNCommandEnvironment()
+        SvnOperationFactory opfactory = createOperationFactory(env)
         try {
-            SvnUpdate updateOp = opfactory.createUpdate()
-            updateOp.setSingleTarget(SvnTarget.fromFile(dir))
-            updateOp.run()
+            SvnUpdate updateOp = opfactory.createUpdate()
+            updateOp.setSingleTarget(SvnTarget.fromFile(dir))
+            updateOp.run()
         } finally {
             opfactory.dispose()
         }
     }
 
     static void status(File dir) {
-        SVNCommandEnvironment env = getSVNCommandEnvironment()
-        SvnOperationFactory opfactory = createOperationFactory(env)
+        SVNCommandEnvironment env = getSVNCommandEnvironment()
+        SvnOperationFactory opfactory = createOperationFactory(env)
         try {
-            SVNStatusPrinter statusPrinter = new SVNStatusPrinter(env);
-            SVNWCContext context = opfactory.getWcContext();
-            SvnGetStatus statusOp = opfactory.createGetStatus()
-            statusOp.setSingleTarget(SvnTarget.fromFile(dir))
-            statusOp.setReportAll(false)
-            statusOp.setReceiver(new ISvnObjectReceiver<SvnStatus>() {
+            SVNStatusPrinter statusPrinter = new SVNStatusPrinter(env)
+            SVNWCContext context = opfactory.getWcContext();
+            SvnGetStatus statusOp = opfactory.createGetStatus()
+            statusOp.setSingleTarget(SvnTarget.fromFile(dir))
+            statusOp.setReportAll(false)
+            statusOp.setReceiver(new ISvnObjectReceiver<SvnStatus>() {
 
                 @Override
                 void receive(SvnTarget target, SvnStatus object) throws SVNException {
-                    statusPrinter.printStatus(
-                            env.getRelativePath(target.getFile()),
-                            SvnCodec.status(context, object), false, true, true, false)
+                    String root = dir.getAbsoluteFile();
+                    String f = target.getFile().getAbsolutePath()
+                    if (f.startsWith(root)) {
+                        f = f.substring(root.length())
+                        if (f.startsWith('/')) {
+                            f = f.substring(1, f.length() - 1)
+                        }
+                    }
+                    statusPrinter.printStatus(f,
+                            SvnCodec.status(context, object), false, true, true, false)
                 }
 
             })
-            statusOp.run()
+            statusOp.run()
         } finally {
             opfactory.dispose()
         }
     }
+
+    static void scheduleForAddition(File dir) {
+        SVNCommandEnvironment env = getSVNCommandEnvironment()
+        SvnOperationFactory opfactory = createOperationFactory(env)
+        try {
+            SvnScheduleForAddition schedulingOp = opfactory.createScheduleForAddition()
+            schedulingOp.setSingleTarget(SvnTarget.fromFile(dir))
+            schedulingOp.setDepth(SVNDepth.INFINITY)
+            schedulingOp.setForce(true)
+            schedulingOp.setIncludeIgnored(false)
+            schedulingOp.run()
+        } finally {
+            opfactory.dispose()
+        }
+    }
+
 }

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnContentTask.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnContentTask.groovy?rev=1505126&r1=1505125&r2=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnContentTask.groovy
(original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnContentTask.groovy
Sat Jul 20 12:21:11 2013
@@ -39,13 +39,16 @@ class SvnContentTask extends DefaultTask
     void setRepo(URI repo) {
         this.repo = repo
         if (!repo.absolute) {
-            this.localDir = new File(repo.toString())
+            localDir = new File(repo.toString())
         } else {
             String l = repo.path
+            if (l.startsWith('/')) {
+                l = l.substring(1)
+            }
             if (l.endsWith('/')) {
                 l = l.substring(0, l.length() - 1)
             }
-            this.localDir = new File(buildDir, l.replace('/', '-'))
+            localDir = new File(project.buildDir, l.replace('/', '-'))
         }
     }
 

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy?rev=1505126&r1=1505125&r2=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy Sat
Jul 20 12:21:11 2013
@@ -32,11 +32,9 @@ class SvnGet extends SvnContentTask {
     @TaskAction
     void get() {
         if (repo.absolute) {
-            println("Site content source: ${repo}")
             if (!localDir.exists()) {
+                println("Checking out from ${repo}")
                 Svn.checkout(repo, localDir)
-            } else {
-                Svn.update(localDir)
             }
         }
     }

Copied: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnScheduleForAddition.groovy
(from r1504953, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy)
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnScheduleForAddition.groovy?p2=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnScheduleForAddition.groovy&p1=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy&r1=1504953&r2=1505126&rev=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnScheduleForAddition.groovy
Sat Jul 20 12:21:11 2013
@@ -27,13 +27,13 @@
 
 import org.gradle.api.tasks.TaskAction
 
-class SvnStatus extends SvnContentTask {
+class SvnScheduleForAddition extends SvnContentTask {
 
     @TaskAction
-    void status() {
+    void schedule() {
         if (repo.absolute) {
-            println("Local changes ${repo}")
-            Svn.status(localDir)
+            println("Scheduling changes for addition to ${repo}")
+            Svn.scheduleForAddition(localDir)
         }
     }
 

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy?rev=1505126&r1=1505125&r2=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy Sat
Jul 20 12:21:11 2013
@@ -31,8 +31,8 @@ class SvnStatus extends SvnContentTask {
 
     @TaskAction
     void status() {
-        if (repo.absolute) {
-            println("Local changes ${repo}")
+        if (localDir.exists()) {
+            println("Local changes of ${repo}")
             Svn.status(localDir)
         }
     }

Copied: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnUpdate.groovy
(from r1504953, httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy)
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnUpdate.groovy?p2=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnUpdate.groovy&p1=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy&r1=1504953&r2=1505126&rev=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnUpdate.groovy Sat
Jul 20 12:21:11 2013
@@ -27,13 +27,13 @@
 
 import org.gradle.api.tasks.TaskAction
 
-class SvnStatus extends SvnContentTask {
+class SvnUpdate extends SvnContentTask {
 
     @TaskAction
-    void status() {
-        if (repo.absolute) {
-            println("Local changes ${repo}")
-            Svn.status(localDir)
+    void update() {
+        println("Updating local checkout of ${repo}")
+        if (localDir.exists()) {
+            Svn.update(localDir)
         }
     }
 

Modified: httpcomponents/project-release-tools/trunk/rc.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/rc.gradle?rev=1505126&r1=1505125&r2=1505126&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/rc.gradle (original)
+++ httpcomponents/project-release-tools/trunk/rc.gradle Sat Jul 20 12:21:11 2013
@@ -129,6 +129,21 @@ task copyReleaseNotes(type: Copy, depend
     rename { "RELEASE_NOTES-${rc.pom.major}.${rc.pom.minor}.x.txt" }
 }
 
+task stageUpdate(type: SvnUpdate, dependsOn: prepareStage) {
+    repo = tasks.prepareStage.repo
+}
+
+task addChanges(type: SvnScheduleForAddition, dependsOn: prepareStage) {
+    repo = tasks.prepareStage.repo
+}
+
+task stage(dependsOn: ['prepareStage', 'assemble', 'sign', 'digest', 'copyReleaseNotes'])
{
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+Copy specs
+//////////////////////////////////////////////////////////////////////////////////////////
+
 CopySpec docs(HCProject hcProject, String delim) {
     CopySpec spec = copySpec {
         from (hcProject.localDir) {



Mime
View raw message