Index: /Users/jwhitlock/dev/subclipse/svnant/src/main/org/tigris/subversion/svnant/Info.java
===================================================================
--- /Users/jwhitlock/dev/subclipse/svnant/src/main/org/tigris/subversion/svnant/Info.java (revision 2144)
+++ /Users/jwhitlock/dev/subclipse/svnant/src/main/org/tigris/subversion/svnant/Info.java (working copy)
@@ -1,10 +1,10 @@
package org.tigris.subversion.svnant;
import java.io.File;
+import java.net.MalformedURLException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
-
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.ISVNInfo;
import org.tigris.subversion.svnclientadapter.SVNClientException;
@@ -24,7 +24,7 @@
* object if representative of a WC path. Otherwise, a
* SVNUrl
object.
*/
- private Object target = null;
+ private String target = null;
/** Whether or not to print the properties. */
private boolean verbose = false;
@@ -84,7 +84,9 @@
DIR_PROP_NAMES : FILE_PROP_NAMES);
for (int i = 0; i < propNames.length; i++) {
String value = getValue(propNames[i]);
+
project.setProperty(propPrefix + propNames[i], value);
+
if (verbose) {
log(" " + propPrefix + propNames[i] + ": " + value,
Project.MSG_INFO);
@@ -102,11 +104,26 @@
* ISVNInfo.getInfoFromWorkingCopy()
, which uses only
* the meta data from the WC.
*/
- private ISVNInfo acquireInfo(ISVNClientAdapter svnClient, Object target)
+ private ISVNInfo acquireInfo(ISVNClientAdapter svnClient, String target)
throws SVNClientException{
- return (target instanceof File ?
- svnClient.getInfo((File) target) :
- svnClient.getInfo((SVNUrl) target));
+ File targetFile = new File(target);
+ ISVNInfo info;
+
+ if (targetFile.exists()) {
+ info = svnClient.getInfo(targetFile);
+ } else {
+ SVNUrl url;
+
+ try {
+ url = new SVNUrl(target);
+ } catch (MalformedURLException murle) {
+ throw new BuildException(murle);
+ }
+
+ info = svnClient.getInfo(url);
+ }
+
+ return info;
}
/**
@@ -113,10 +130,16 @@
* Retrieve a value for the named property.
*
* @param propName Name of the property to retrieve a value for.
- * @return The value of the property, or null
+ * @return The value of the property, or a null string ""
*/
public String getValue(String propName) {
- String value = null;
+ String value = ""; // Used to set properties to a null string instead of
+ // returning null. Using a null string instead of null
+ // will allow the build to continue and since we log the
+ // unsupported propName, either an unrecognized propName
+ // (Which should never happen) or checksum, the user will
+ // have means to undertand the issue instead of failing
+ // the whole build.
// ASSUMPTION: DIR_PROP_NAMES is a subset of FILE_PROP_NAMES.
if (FILE_PROP_NAMES[0].equals(propName)) {
@@ -200,4 +223,4 @@
this.propPrefix = propPrefix + '.';
}
}
-}
+}
\ No newline at end of file
Index: /Users/jwhitlock/dev/subclipse/svnant/src/testcases/org/tigris/subversion/svnant/SvnTest.java
===================================================================
--- /Users/jwhitlock/dev/subclipse/svnant/src/testcases/org/tigris/subversion/svnant/SvnTest.java (revision 2144)
+++ /Users/jwhitlock/dev/subclipse/svnant/src/testcases/org/tigris/subversion/svnant/SvnTest.java (working copy)
@@ -841,11 +841,11 @@
"Dir or file must be set.");
expectBuildException("testInfoBadFile",
"fakefile.txt: (Not a versioned resource)");
-
- executeTarget("testInfoFile");
- String[] propNames = {
+
+ executeTarget("testInfoDirectory");
+
+ String[] propNames = new String[] {
"svn.info.path",
- "svn.info.name",
"svn.info.url",
"svn.info.repouuid",
"svn.info.rev",
@@ -853,7 +853,15 @@
"svn.info.schedule",
"svn.info.author",
"svn.info.lastRev",
- "svn.info.lastDate",
+ "svn.info.lastDate"
+ };
+
+ for (int i = 0; i < propNames.length; i++) {
+ assertPropertySet(propNames[i], true);
+ }
+
+ propNames = new String[] {
+ "svn.info.name",
"svn.info.lastTextUpdate",
"svn.info.lastPropUpdate",
"svn.info.checksum"
@@ -858,11 +866,14 @@
"svn.info.lastPropUpdate",
"svn.info.checksum"
};
+
+ // Property shouldn't be set for a directory.
for (int i = 0; i < propNames.length; i++) {
- assertPropertySet(propNames[i], true);
+ assertPropertyUnset(propNames[i]);
}
- executeTarget("testInfoDir");
+ executeTarget("testInfoFile");
+
propNames = new String[] {
"svn.info.path",
"svn.info.name",
@@ -873,12 +884,7 @@
"svn.info.schedule",
"svn.info.author",
"svn.info.lastRev",
- "svn.info.lastDate"
- };
- for (int i = 0; i < propNames.length; i++) {
- assertPropertySet(propNames[i], true);
- }
- propNames = new String[] {
+ "svn.info.lastDate",
"svn.info.lastTextUpdate",
"svn.info.lastPropUpdate",
"svn.info.checksum"
@@ -883,8 +889,9 @@
"svn.info.lastPropUpdate",
"svn.info.checksum"
};
+
for (int i = 0; i < propNames.length; i++) {
- assertPropertySet(propNames[i], false);
+ assertPropertySet(propNames[i], true);
}
executeTarget("testInfoCustomPrefix");
Index: /Users/jwhitlock/dev/subclipse/svnant/test/svn/build.xml
===================================================================
--- /Users/jwhitlock/dev/subclipse/svnant/test/svn/build.xml (revision 2144)
+++ /Users/jwhitlock/dev/subclipse/svnant/test/svn/build.xml (working copy)
@@ -1017,7 +1017,7 @@
-
+
@@ -1023,7 +1023,7 @@
-
+
@@ -1029,7 +1029,7 @@
-
+
@@ -1035,7 +1035,7 @@
-
+