# HG changeset patch
# User Stefan Hühner <stefan.huehner@openbravo.com>
# Date 1523204496 -7200
#      Sun Apr 08 18:21:36 2018 +0200
# Node ID 9c5ef158ca5f7b5e674b2d99edd89017fb75bde5
# Parent  9f30ffa8fee35d78e72e1ceb315a0564b6e9f644
Issue 38300. Remove using/showing obsolete ad_system_info.code_revision

Export.database safety to not overwrite files is using md5 checksum for files
for a long time. However there was a leftover of printing the old obsolete
ad_system_info.code_revision which is hereby removed.

Commit also removes the longer unused verifyRevision call on top of the
getDBRevision.

diff -r 9f30ffa8fee3 -r 9c5ef158ca5f src/org/openbravo/ddlutils/task/ExportDatabase.java
--- a/src/org/openbravo/ddlutils/task/ExportDatabase.java	Thu Mar 22 11:54:48 2018 +0100
+++ b/src/org/openbravo/ddlutils/task/ExportDatabase.java	Sun Apr 08 18:21:36 2018 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2001-2017 Openbravo S.L.U.
+ * Copyright (C) 2001-2018 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * 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
@@ -96,7 +96,6 @@
         getLog()
             .error(
                 "A file was modified in the database folder (this can happen if you update your repository or modify the files, and don't do update.database). Eliminate the differences (by either reverting the changes in the files, or reverting to the old revision of sources), and try to export again.");
-        getLog().info("Mercurial revision in database: " + DBSMOBUtil.getDBRevision(platform));
         throw new BuildException("Found modifications in files when exporting");
       }
     }
diff -r 9f30ffa8fee3 -r 9c5ef158ca5f src/org/openbravo/ddlutils/util/DBSMOBUtil.java
--- a/src/org/openbravo/ddlutils/util/DBSMOBUtil.java	Thu Mar 22 11:54:48 2018 +0100
+++ b/src/org/openbravo/ddlutils/util/DBSMOBUtil.java	Sun Apr 08 18:21:36 2018 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2001-2017 Openbravo S.L.U.
+ * Copyright (C) 2001-2018 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * 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
@@ -268,40 +268,6 @@
     return value;
   }
 
-  public static String getDBRevision(Platform platform) {
-    final String sql = "SELECT * FROM AD_SYSTEM_INFO";
-
-    final Connection connection = platform.borrowConnection();
-    ResultSet resultSet = null;
-    try {
-      final PreparedStatement statement = connection.prepareStatement(sql);
-      statement.execute();
-      resultSet = statement.getResultSet();
-    } catch (final Exception e) {
-      System.out.println(e.getMessage());
-      throw new BuildException("Code revision id not found in database");
-    }
-    try {
-      if (resultSet.next()) {
-      } else {
-        throw new BuildException("Code revision id not found in database");
-      }
-    } catch (final Exception e) {
-      throw new BuildException("Code revision id not found in database");
-    }
-    String databaseRevision = "0";
-    try {
-      databaseRevision = resultSet.getString("CODE_REVISION");
-    } catch (final Exception e) {
-      try {
-        databaseRevision = resultSet.getString("code_revision");
-      } catch (final Exception er) {
-        System.out.println("Error while trying to fetch code revision id from database.");
-      }
-    }
-    return databaseRevision;
-  }
-
   public static Map<String, String> getModulesVersion(Platform platform) {
     final String sql = "SELECT ad_module_id AS moduleid, version AS version FROM ad_module";
     final Connection connection = platform.borrowConnection();
@@ -324,26 +290,6 @@
     return moduleVersionMap;
   }
 
-  public static void verifyRevision(Platform platform, String codeRevision, Logger _log) {
-    String databaseRevision = getDBRevision(platform);
-
-    _log.info("Database code revision id: " + databaseRevision);
-
-    _log.info("Source code revision id: " + codeRevision);
-    if (codeRevision.equals("0")) {
-      _log.info("Mercurial code revision id not found.");
-    } else if (!filterRevision(codeRevision).equals(filterRevision(databaseRevision))) {
-      throw new BuildException(
-          "Database revision id differs from the source code revision id. A hg update to your previous revision ID should be performed before exporting: hg update -r REV");
-    }
-  }
-
-  private static String filterRevision(String revision) {
-    if (revision.charAt(revision.length() - 1) == '+')
-      return revision.substring(0, revision.length() - 1);
-    return revision;
-  }
-
   public static Vector<File> loadFilesFromFolder(String folders) {
     final StringTokenizer strTokFol = new StringTokenizer(folders, ",");
     final Vector<File> files = new Vector<File>();
