From 39939cbeb2965312e1fee64c4cbf824b37ea857c Mon Sep 17 00:00:00 2001
From: jpikus <jpikus@localhost>
Date: Fri, 20 Mar 2009 14:40:00 +0000
Subject: [PATCH] fix incorrect svn revision and add svn url in start-ds -F

---
 opends/src/server/org/opends/server/core/DirectoryServer.java            |    1 
 opends/build.xml                                                         |   17 ++++
 opends/src/build-tools/org/opends/build/tools/GetSubversionRevision.java |    5 +
 opends/src/build-tools/org/opends/build/tools/GetSubversionUrlRepo.java  |  145 ++++++++++++++++++++++++++++++++++++
 opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java        |   11 ++
 opends/src/server/org/opends/server/util/SetupUtils.java                 |    2 
 opends/resource/DynamicConstants.java.stubs                              |    6 +
 7 files changed, 185 insertions(+), 2 deletions(-)

diff --git a/opends/build.xml b/opends/build.xml
index 6b15c58..05d21e2 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -466,6 +466,21 @@
 
     <getsvnrevision property="REVISION_NUMBER" />
 
+    <!-- Get the url repo of the current Subversion workspace -->
+    <taskdef name="getsvnurlrepo"
+             classname="org.opends.build.tools.GetSubversionUrlRepo">
+      <classpath>
+        <fileset dir="${build.dir}/build-tools">
+          <include name="*.jar" />
+        </fileset>
+        <fileset dir="${svnkit.dir}">
+          <include name="*.jar" />
+        </fileset>
+      </classpath>
+    </taskdef>
+
+    <getsvnurlrepo property="URL_REPOSITORY" />
+
 
     <!-- Construct the version number string -->
     <taskdef name="getversionnumber"
@@ -484,7 +499,7 @@
       Be warned that the .stubs file references the following properties
       PRODUCT_NAME, SHORT_NAME, MAJOR_VERSION, MINOR_VERSION, POINT_VERSION,
       VERSION_QUALIFIER, FIX_IDS, timestamp, user.name, java.version,
-      java.vendor, java.vm.version, JVM_VENDOR, DEBUG_BUILD, REVISION_NUMBER,
+      java.vendor, java.vm.version, JVM_VENDOR, DEBUG_BUILD, REVISION_NUMBER,URL_REPOSITORY,
       WEAVE_ENABLED, VERSION_NUMBER_STRING
       If you change the name of any of those properties in this build.xml
       you'll need to reflect the same change in the .stubs file
diff --git a/opends/resource/DynamicConstants.java.stubs b/opends/resource/DynamicConstants.java.stubs
index 80b238d..9f2176e 100644
--- a/opends/resource/DynamicConstants.java.stubs
+++ b/opends/resource/DynamicConstants.java.stubs
@@ -127,6 +127,12 @@
   public static final long REVISION_NUMBER = ${REVISION_NUMBER};
 
   /**
+   * The Subversion url repository location on which this build is based.
+   */
+  public static final String URL_REPOSITORY = 
+      "${URL_REPOSITORY}";
+
+  /**
    * Indicates wheater this build includes AspectJ weaving for the debug logging
    * framework.
    */
diff --git a/opends/src/build-tools/org/opends/build/tools/GetSubversionRevision.java b/opends/src/build-tools/org/opends/build/tools/GetSubversionRevision.java
index 73f86f3..5469b10 100644
--- a/opends/src/build-tools/org/opends/build/tools/GetSubversionRevision.java
+++ b/opends/src/build-tools/org/opends/build/tools/GetSubversionRevision.java
@@ -115,7 +115,9 @@
     try
     {
       SVNInfo svnInfo = ourClientManager.getWCClient().doInfo(workspacePath, SVNRevision.WORKING);
-      SVNRevision revision = svnInfo.getRevision();
+      SVNRevision revision = svnInfo.getCommittedRevision();
+      
+  
       if (revision == null)
       {
         System.err.println("WARNING:  Could not determine Subversion " +
@@ -127,6 +129,7 @@
         getProject().setNewProperty(propertyName,
                                     String.valueOf(revision.getNumber()));
       }
+  
     }
     catch (SVNException svnException)
     {
diff --git a/opends/src/build-tools/org/opends/build/tools/GetSubversionUrlRepo.java b/opends/src/build-tools/org/opends/build/tools/GetSubversionUrlRepo.java
new file mode 100644
index 0000000..ed4aad0
--- /dev/null
+++ b/opends/src/build-tools/org/opends/build/tools/GetSubversionUrlRepo.java
@@ -0,0 +1,145 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2009 Sun Microsystems, Inc.
+ */
+package org.opends.build.tools;
+
+
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNInfo;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.SVNURL;
+
+
+
+/**
+ * This class provides an implementation of an Ant task that may be used to
+ * determine the current Subversion revision number of the current working
+ * copy.  The value of the revision number will be stored in an Ant property.
+ */
+public class GetSubversionUrlRepo
+       extends Task
+{
+  // The name of the property in which the revision number should be set.
+  private String propertyName = null;
+
+  // The path to the root of the Subversion workspace for which to retrieve the
+  // revision number.
+  private String workspace = null;
+
+  // The svn client manager. Required by svnkit 1.2.x
+  private static SVNClientManager ourClientManager =
+          SVNClientManager.newInstance();
+
+  /**
+   * Specifies the name of the Ant property into which the Subversion revision
+   * number will be stored.
+   *
+   * @param  propertyName  The name of the Ant property into which the
+   *                       Subversion revision number will be stored.
+   */
+  public void setProperty(String propertyName)
+  {
+    this.propertyName = propertyName;
+  }
+
+
+
+  /**
+   * Specifies the path to the root of the Subversion workspace for which to
+   * retrieve the revision number.
+   *
+   * @param  workspace  The path to the root of the Subversion workspace for
+   *                    which to retrieve the revision number.
+   */
+  public void setWorkspace(String workspace)
+  {
+    this.workspace = workspace;
+  }
+
+
+
+  /**
+   * Performs the appropriate processing needed for this task.  In this case,
+   * it uses SVNKit to identify the current revision number for the local
+   * workspace and store it in a specified property.
+   */
+  @Override()
+  public void execute()
+  {
+    if ((propertyName == null) || (propertyName.length() == 0))
+    {
+      throw new BuildException("ERROR:  No property was specified for " +
+                               "storing the revision number value.");
+    }
+
+    File workspacePath;
+    if ((workspace == null) || (workspace.length() == 0))
+    {
+      workspacePath = getProject().getBaseDir();
+    }
+    else
+    {
+      workspacePath = new File(workspace);
+    }
+
+
+    try
+    {
+      SVNInfo svnInfo = ourClientManager.getWCClient().doInfo(workspacePath, SVNRevision.WORKING);
+      SVNURL url_repo = svnInfo.getURL();
+      
+  
+      if (url_repo == null)
+      {
+        System.err.println("WARNING:  Could not determine Subversion URL Repository " +
+                           "for current workspace.");
+        getProject().setNewProperty(propertyName, "-1");
+      }
+      else
+      {
+        getProject().setNewProperty(propertyName,
+                                    String.valueOf(url_repo));
+
+      }
+  
+    }
+    catch (SVNException svnException)
+    {
+      System.err.println("WARNING:  Could not determine Subversion " +
+                         "URL repository for current workspace:  " +
+                         svnException);
+      getProject().setNewProperty(propertyName, "-1");
+    }
+  }
+}
+
diff --git a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
index e2fffe8..9d47a6e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -254,6 +254,8 @@
             String.valueOf(DynamicConstants.VERSION_QUALIFIER));
     bi.values.put(REVISION_NUMBER,
             String.valueOf(DynamicConstants.REVISION_NUMBER));
+    bi.values.put(URL_REPOSITORY,
+            String.valueOf(DynamicConstants.URL_REPOSITORY));
     bi.values.put(FIX_IDS, DynamicConstants.FIX_IDS);
     bi.values.put(DEBUG_BUILD, String.valueOf(DynamicConstants.DEBUG_BUILD));
     bi.values.put(BUILD_OS, DynamicConstants.BUILD_OS);
@@ -341,6 +343,15 @@
   }
 
   /**
+   * Gets the SVN URL repository.
+   *
+   * @return String representing the SVN URL repository
+   */
+  public String getURLRepository() {
+    return new String(values.get(URL_REPOSITORY));
+  }
+
+  /**
    * Gets the set of IDs representing <code>IncompatibleVersionEvents</code>.
    * @return set of integers representing events
    * @see org.opends.server.util.VersionCompatibilityIssue
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index a0e3691..32291ec 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -9942,6 +9942,7 @@
                      new DecimalFormat("000").format(BUILD_NUMBER));
     }
     System.out.println(SetupUtils.REVISION_NUMBER+separator+REVISION_NUMBER);
+    System.out.println(SetupUtils.URL_REPOSITORY+separator+URL_REPOSITORY);
     System.out.println(SetupUtils.FIX_IDS+separator+FIX_IDS);
     System.out.println(SetupUtils.DEBUG_BUILD+separator+DEBUG_BUILD);
     System.out.println(SetupUtils.BUILD_OS+separator+BUILD_OS);
diff --git a/opends/src/server/org/opends/server/util/SetupUtils.java b/opends/src/server/org/opends/server/util/SetupUtils.java
index 31fd13c..a9803fd 100644
--- a/opends/src/server/org/opends/server/util/SetupUtils.java
+++ b/opends/src/server/org/opends/server/util/SetupUtils.java
@@ -107,6 +107,8 @@
   public static final String POINT_VERSION = "Point Version";
   /** Revision number in SVN. */
   public static final String REVISION_NUMBER = "Revision Number";
+  /** the SVN url repository. */
+  public static final String URL_REPOSITORY = "URL Repository";
   /** The version qualifier. */
   public static final String VERSION_QUALIFIER = "Version Qualifier";
   /** Incompatibilities found between builds (used by the upgrade tool). */

--
Gitblit v1.10.0