Bug 229325 - devel/statsvn: does not work with subversion >= 1.10.0
Summary: devel/statsvn: does not work with subversion >= 1.10.0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Tobias Kortkamp
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-06-25 02:50 UTC by kensaku.masuda
Modified: 2022-01-25 13:34 UTC (History)
1 user (show)

See Also:


Attachments
Patch for SvnStartupUtils.java (1.96 KB, patch)
2018-06-25 02:50 UTC, kensaku.masuda
no flags Details | Diff
statsvn.diff (1.69 KB, patch)
2018-06-25 07:03 UTC, Tobias Kortkamp
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kensaku.masuda 2018-06-25 02:50:12 UTC
Created attachment 194618 [details]
Patch for SvnStartupUtils.java

StatSVN say

    "Subversion binary is incorrect version. Found: 1.10.0, required: 1.3.0 Updating"

And do nothing.
So, statsvn compare version information with corrupted method.
Collect method is ....

--- src/net/sf/statsvn/util/SvnStartupUtils.java.orig	2018-06-25 10:35:11.895337000 +0900
+++ src/net/sf/statsvn/util/SvnStartupUtils.java	2018-06-25 11:00:44.722623000 +0900
@@ -26,6 +26,9 @@
 	private static final String SVN_VERSION_LINE_PATTERN = ".* [0-9]+\\.[0-9]+\\.[0-9]+.*";
 
 	private static final String SVN_VERSION_PATTERN = "[0-9]+\\.[0-9]+\\.[0-9]+";
+	private static final int SVN_MINIMUM_MAJOR_VERSION = 1;
+	private static final int SVN_MINIMUM_MINOR_VERSION = 3;
+	private static final int SVN_MINIMUM_REVISION_VERSION = 0;
 
 
     protected ISvnProcessor processor;
@@ -62,7 +65,10 @@
 						final String versionString = line.substring(m.start(), m.end());
 
 						// we perform a simple string comparison against the version numbers
-						if (versionString.compareTo(SVN_MINIMUM_VERSION) >= 0) {
+						final int[] version = parseVersionNumber(versionString);
+						if (version[0] >= SVN_MINIMUM_MAJOR_VERSION &&
+						    version[1] >= SVN_MINIMUM_MINOR_VERSION &&
+						    version[2] >= SVN_MINIMUM_REVISION_VERSION) {
 							return versionString; // success
 						} else {
 							throw new SvnVersionMismatchException(versionString, SVN_MINIMUM_VERSION);
@@ -98,4 +104,25 @@
 		// we perform a simple string comparison against the version numbers
 		return version.compareTo(SVN_MINIMUM_VERSION_DIFF_PER_REV) >= 0;
 	}
+
+	/**
+	 * Get integer version array from version string.
+	 * @param versionString
+	 * @return
+	 *	triple of version number 
+	 * @exception SvnVersionMismatchException
+	 **/
+	static int[] parseVersionNumber(final String versionString) throws SvnVersionMismatchException {
+		final String[] versionNumberStrings = versionString.split("\\.");
+
+		if(versionNumberStrings.length == 3) {
+			int[] version = new int[3];
+			for(int i = 0 ; i < 3 ; i++) {
+				version[i] = Integer.parseInt(versionNumberStrings[i], 10);
+			}
+			return version;
+		} else {
+			throw new SvnVersionMismatchException(versionString, SVN_MINIMUM_VERSION);
+		}
+	}
 }
Comment 1 kensaku.masuda 2018-06-25 05:07:20 UTC
One more problem found.

Here is patches.

--- src/net/sf/statsvn/util/SvnStartupUtils.java.orig	2018-06-25 10:35:11.895337000 +0900
+++ src/net/sf/statsvn/util/SvnStartupUtils.java	2018-06-25 13:32:56.122954000 +0900
@@ -26,6 +26,13 @@
 	private static final String SVN_VERSION_LINE_PATTERN = ".* [0-9]+\\.[0-9]+\\.[0-9]+.*";
 
 	private static final String SVN_VERSION_PATTERN = "[0-9]+\\.[0-9]+\\.[0-9]+";
+	private static final int SVN_MINIMUM_MAJOR_VERSION = 1;
+	private static final int SVN_MINIMUM_MINOR_VERSION = 3;
+	private static final int SVN_MINIMUM_REVISION_VERSION = 0;
+
+	private static final int SVN_MINIMUM_MAJOR_VERSION_DIFF_PER_REV = 1;
+	private static final int SVN_MINIMUM_MINOR_VERSION_DIFF_PER_REV = 4;
+	private static final int SVN_MINIMUM_REVISION_VERSION_DIFF_PER_REV = 0;
 
 
     protected ISvnProcessor processor;
@@ -62,7 +69,10 @@
 						final String versionString = line.substring(m.start(), m.end());
 
 						// we perform a simple string comparison against the version numbers
-						if (versionString.compareTo(SVN_MINIMUM_VERSION) >= 0) {
+						final int[] version = parseVersionNumber(versionString);
+						if (version[0] >= SVN_MINIMUM_MAJOR_VERSION &&
+						    version[1] >= SVN_MINIMUM_MINOR_VERSION &&
+						    version[2] >= SVN_MINIMUM_REVISION_VERSION) {
 							return versionString; // success
 						} else {
 							throw new SvnVersionMismatchException(versionString, SVN_MINIMUM_VERSION);
@@ -94,8 +104,38 @@
 	/* (non-Javadoc)
      * @see net.sf.statsvn.util.IVersionProcessor#checkDiffPerRevPossible(java.lang.String)
      */
-	public synchronized boolean checkDiffPerRevPossible(final String version) {
+	public synchronized boolean checkDiffPerRevPossible(final String versionString) {
 		// we perform a simple string comparison against the version numbers
-		return version.compareTo(SVN_MINIMUM_VERSION_DIFF_PER_REV) >= 0;
+		try {
+			final int[] version = parseVersionNumber(versionString);
+
+			return	version[0] >= SVN_MINIMUM_MAJOR_VERSION_DIFF_PER_REV &&
+				version[1] >= SVN_MINIMUM_MINOR_VERSION_DIFF_PER_REV &&
+				version[2] >= SVN_MINIMUM_REVISION_VERSION_DIFF_PER_REV;
+		} catch(SvnVersionMismatchException e) {
+			SvnConfigurationOptions.getTaskLogger().info(e.getMessage());
+			return false;
+		}
+	}
+
+	/**
+	 * Get integer version array from version string.
+	 * @param versionString
+	 * @return
+	 *	triple of version number 
+	 * @exception SvnVersionMismatchException
+	 **/
+	static int[] parseVersionNumber(final String versionString) throws SvnVersionMismatchException {
+		final String[] versionNumberStrings = versionString.split("\\.");
+
+		if(versionNumberStrings.length == 3) {
+			int[] version = new int[3];
+			for(int i = 0 ; i < 3 ; i++) {
+				version[i] = Integer.parseInt(versionNumberStrings[i], 10);
+			}
+			return version;
+		} else {
+			throw new SvnVersionMismatchException(versionString, SVN_MINIMUM_VERSION);
+		}
 	}
 }
Comment 2 Tobias Kortkamp freebsd_committer freebsd_triage 2018-06-25 07:03:29 UTC
Created attachment 194622 [details]
statsvn.diff

I think we should just skip the check completely instead of fixing it.
The minimum version of svn is already specified in the port Makefile.

Can you test with this patch?
Comment 3 kensaku.masuda 2018-06-26 04:22:07 UTC
(In reply to Tobias Kortkamp from comment #2)

> The minimum version of svn is already specified in the port Makefile.

The problem is not build enviroment. In runtime problem.

> Can you test with this patch?

It is tested in my enviroment.

    greg@inner-vm:/home/greg % pkg info | grep subversion
    git-subversion-2.17.1          Distributed source code management tool with FreeBSD subversion bindings
    p5-subversion-1.10.0_1         Perl bindings for Version control system
    subversion-1.10.0              Version control system
    greg@inner-vm:/home/greg %

In runtime, Checking function compare string "1.10.0" and "1.3.0".
So, string "1.3.0" is greater than "1.10.0".
But we need a result for compaing between 1.10.0 and 1.3.0.
I have 2 solutions.

1) Canonical before comparing. ex) 1.3.0 -> 010300/1.10.0 -> 011000.
2) Disassembling version number, And compare.

1 is more better, but 2 is more easy.

# Most simple codes are .....
# int version = (majorNumber * 10000) + (minorNumber * 100) + revisionNumber;
# if ( version >= REQUIRED_MININUM_VERSION) {
#     .......
# }
#
# My be.
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-06-26 05:54:44 UTC
A commit references this bug:

Author: tobik
Date: Tue Jun 26 05:54:16 UTC 2018
New revision: 473374
URL: https://svnweb.freebsd.org/changeset/ports/473374

Log:
  devel/statsvn: Fix runtime after the update of devel/subversion to 1.10.0

  It tries to check that SVN >= 1.3.0 but the check is broken with
  version numbers like 1.10.0.  We will never have SVN < 1.3.0 again
  so add a patch to skip the version check altogether.

  "Subversion binary is incorrect version. Found: 1.10.0, required: 1.3.0"

  PR:		229325
  Reported by:	kensaku.masuda@gmail.com

Changes:
  head/devel/statsvn/Makefile
  head/devel/statsvn/files/patch-src_net_sf_statsvn_Main.java
Comment 5 Tobias Kortkamp freebsd_committer freebsd_triage 2018-06-26 05:58:26 UTC
(In reply to kensaku.masuda from comment #3)
I went ahead a committed a fix.  Please test if the runtime is still
broken now.
Comment 6 Tobias Kortkamp freebsd_committer freebsd_triage 2018-06-26 05:59:10 UTC
(In reply to Tobias Kortkamp from comment #5)
s/a committed/and committed/
Comment 7 shazi828 2022-01-25 13:34:38 UTC
Is there a built .jar file available following this bug fix? I would appreciate if one is already available.

thank you.