Browse Source

Make cvsversion work for local repositories as well

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@705238 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
d302bf9117
3 changed files with 53 additions and 4 deletions
  1. +2
    -0
      WHATSNEW
  2. +19
    -4
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java
  3. +32
    -0
      src/tests/antunit/taskdefs/cvs/cvs.xml

+ 2
- 0
WHATSNEW View File

@@ -451,6 +451,8 @@ Other changes:
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
=============================================



+ 19
- 4
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java View File

@@ -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 @@ public class CvsVersion extends AbstractCvsTask {
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 @@ public class CvsVersion extends AbstractCvsTask {
&& 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 @@ public class CvsVersion extends AbstractCvsTask {
}
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);


+ 32
- 0
src/tests/antunit/taskdefs/cvs/cvs.xml View File

@@ -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>

Loading…
Cancel
Save