Author: bodewig
Date: Thu Oct 16 06:26:00 2008
New Revision: 705238
URL: http://svn.apache.org/viewvc?rev=705238&view=rev
Log:
Make cvsversion work for local repositories as well
Added:
ant/core/trunk/src/tests/antunit/taskdefs/cvs/cvs.xml (with props)
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=705238&r1=705237&r2=705238&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Oct 16 06:26:00 2008
@@ -451,6 +451,8 @@
CVS_CLIENT_PORT.
Bugzilla Report 30124.
+ * <cvsversion> now works for local repositories as well.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java?rev=705238&r1=705237&r2=705238&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java
Thu Oct 16 06:26:00 2008
@@ -17,6 +17,7 @@
*/
package org.apache.tools.ant.taskdefs.cvslib;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.AbstractCvsTask;
import java.io.ByteArrayOutputStream;
@@ -115,12 +116,17 @@
setCommand("version");
super.execute();
String output = bos.toString();
+ log("Received version response \"" + output + "\"",
+ Project.MSG_DEBUG);
StringTokenizer st = new StringTokenizer(output);
boolean client = false;
boolean server = false;
String cvs = null;
- while (st.hasMoreTokens()) {
- String currentToken = st.nextToken();
+ String cachedVersion = null;
+ boolean haveReadAhead = false;
+ while (haveReadAhead || st.hasMoreTokens()) {
+ String currentToken = haveReadAhead ? cachedVersion :
st.nextToken();
+ haveReadAhead = false;
if (currentToken.equals("Client:")) {
client = true;
} else if (currentToken.equals("Server:")) {
@@ -129,7 +135,11 @@
&& currentToken.endsWith(")")) {
cvs = currentToken.length() == 5 ? "" : " " + currentToken;
}
- if (client && cvs != null) {
+ if (!client && !server && cvs != null
+ && cachedVersion == null && st.hasMoreTokens()) {
+ cachedVersion = st.nextToken();
+ haveReadAhead = true;
+ } else if (client && cvs != null) {
if (st.hasMoreTokens()) {
clientVersion = st.nextToken() + cvs;
}
@@ -141,8 +151,13 @@
}
server = false;
cvs = null;
+ } else if (currentToken.equals("(client/server)")
+ && cvs != null && cachedVersion != null
+ && !client && !server) {
+ client = server = true;
+ clientVersion = serverVersion = cachedVersion + cvs;
+ cachedVersion = cvs = null;
}
-
}
if (clientVersionProperty != null) {
getProject().setNewProperty(clientVersionProperty, clientVersion);
Added: ant/core/trunk/src/tests/antunit/taskdefs/cvs/cvs.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/cvs/cvs.xml?rev=705238&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/cvs/cvs.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/cvs/cvs.xml Thu Oct 16 06:26:00
2008
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<!-- this file is not executed by the automated tests since it
+ requires a working CVS client. -->
+
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../../antunit-base.xml" />
+
+ <property name="cvsrootloc" location="repository"/>
+ <property name="cvsroot" value=":local:${cvsrootloc}"/>
+
+ <target name="testVersion">
+ <cvsversion clientversionproperty="client" cvsroot="${cvsroot}"/>
+ <au:assertPropertySet name="client"/>
+ </target>
+</project>
Propchange: ant/core/trunk/src/tests/antunit/taskdefs/cvs/cvs.xml
------------------------------------------------------------------------------
svn:eol-style = native