Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r3881 - branches/GSoC2008/gimenete/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion: subclipse/graph/popup/actions sublicpse/graph/cache

subclipse
Discussion topic

Back to topic list

svn commit: r3881 - branches/GSoC2008/gimenete/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion: subclipse/graph/popup/actions sublicpse/graph/cache

Author gimenete
Full name Alberto Gimeno
Date 2008-06-23 08:49:16 PDT
Message Author: gimenete
Date: 2008-06-23 08:49:16-0700
New Revision: 3881

Modified:
   branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/popup/actions​/ViewGraphAction.jav​a
   branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava

Log:
* support for 'R' actions
* some bugs fixed

Modified: branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/popup/actions​/ViewGraphAction.jav​a
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/branches​/GSoC2008/gimenete/o​rg.tigris.subversion​.subclipse.graph/src​/org/tigris/subversi​on/subclipse/graph/p​opup/actions/ViewGra​phAction.java?view=d​iff&rev=3881​&p1=branches/GSoC200​8/gimenete/org.tigri​s.subversion.subclip​se.graph/src/org/tig​ris/subversion/subcl​ipse/graph/popup/act​ions/ViewGraphAction​.java&p2=branche​s/GSoC2008/gimenete/​org.tigris.subversio​n.subclipse.graph/sr​c/org/tigris/subvers​ion/subclipse/graph/​popup/actions/ViewGr​aphAction.java&r​1=3880&r2=3881
====================​====================​====================​==================
--- branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/popup/actions​/ViewGraphAction.jav​a (original)
+++ branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/popup/actions​/ViewGraphAction.jav​a 2008-06-23 08:49:16-0700
@@ -1,6 +1,8 @@
 package org.tigris.subversio​n.subclipse.graph.po​pup.actions;
 
 import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
 import java.lang.reflect.In​vocationTargetExcept​ion;
 import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
@@ -63,7 +65,10 @@
                     long revision = info.getRevision().getNumber();
                     String path = info.getUrl().toStri​ng().substring(info.​getRepository().toSt​ring().length());
                     
+ long now = System.currentTimeMillis();
                     cache = getCache(file, info.getUuid());
+ long diff = System.currentTimeMillis() - now;
+ System.out.println("getCache(): "+diff);
                     
                     // update the cache
                     long latestRevisionStored = cache.getLatestRevision();
@@ -74,10 +79,17 @@
                         latest = new SVNRevision.Number(l​atestRevisionStored+​1);
                     
                     try {
+ now = System.currentTimeMillis();
                         ISVNLogMessage[] messages = client.getLogMessage​s(info.getRepository​(),
                                 latest, SVNRevision.HEAD);
- // printLogMessages(messages);
+ diff = System.currentTimeMillis() - now;
+ System.out.println("​getLogMessages(): "+diff+" "+messages.length+" messages");
+
+// printLogMessages(messages);
+ now = System.currentTimeMillis();
                         cache.update(messages);
+ diff = System.currentTimeMillis() - now;
+ System.out.println("​cache.update(): "+diff+" "+messages.length+" messages");
                     } catch(SVNClientException e) {
                         System.err.println("cache may be up to date "+e.getMessage()+" "+e.getClass());
                     } catch(Exception e) {
@@ -86,7 +98,11 @@
                     
                     // query information
                     Long fileId = cache.getFileId(path, revision);
+ now = System.currentTimeMillis();
                     List nodes = cache.getNodes(fileI​d.longValue());
+ diff = System.currentTimeMillis() - now;
+ System.out.println("​cache.getNodes(): "+diff+" "+nodes.size()+" nodes");
+ System.out.println();
                     // printNodes(nodes);
                     showGraph(nodes, path);
 
@@ -188,19 +204,38 @@
     }
     
     private void printLogMessages(ISV​NLogMessage[] messages) {
- for (int i = 0; i < messages.length; i++) {
- ISVNLogMessage message = messages[i];
- System.out.println(M​essageFormat.format(​"{0} rev {1} on {3} message: {2}",
- new Object[]{ message.getAuthor(),
- message.getRevision(),
- message.getMessage(),
- new SimpleDateFormat("dd/MM/yyyy mm:ss").format(messa​ge.getDate())}));
- ISVNLogMessageChangePath[] changedPaths = message.getChangedPaths();
- for (int j = 0; j < changedPaths.length; j++) {
- ISVNLogMessageChangePath cp = changedPaths[j];
- System.out.println(M​essageFormat.format(​"{0} {1}",
- new Object[]{ Character.toString(c​p.getAction()), cp.getPath()}));
+ try {
+ FileWriter writer = new FileWriter("c:/out.txt");
+ PrintWriter out = new PrintWriter(writer);
+ for (int i = 0; i < messages.length; i++) {
+ ISVNLogMessage message = messages[i];
+ out.println(message.​getRevision());
+// System.out.println(M​essageFormat.format(​"{0}",
+// new Object[]{ message.getRevision(),
+// message.getRevision(),
+// message.getMessage(),
+// new SimpleDateFormat("dd/MM/yyyy mm:ss").format(messa​ge.getDate())}));
+ ISVNLogMessageChangePath[] changedPaths = message.getChangedPaths();
+ for (int j = 0; j < changedPaths.length; j++) {
+ ISVNLogMessageChangePath cp = changedPaths[j];
+ if(cp.getCopySrcRevision() == null) {
+ out.println(MessageF​ormat.format("{0} {1}",
+ new Object[]{
+ Character.toString(c​p.getAction()),
+ cp.getPath()}));
+ } else {
+ out.println(MessageF​ormat.format("{0} {1} from {2} at {3}",
+ new Object[]{
+ Character.toString(c​p.getAction()),
+ cp.getPath(),
+ cp.getCopySrcPath(),
+ new Long(cp.getCopySrcRe​vision().getNumber()​) }));
+ }
+ }
             }
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
         }
     }
     

Modified: branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/branches​/GSoC2008/gimenete/o​rg.tigris.subversion​.subclipse.graph/src​/org/tigris/subversi​on/sublicpse/graph/c​ache/Cache.java?view​=diff&rev=3881​&p1=branches/GSoC2​008/gimenete/org.tig​ris.subversion.subcl​ipse.graph/src/org/t​igris/subversion/sub​licpse/graph/cache/C​ache.java&p2=bra​nches/GSoC2008/gimen​ete/org.tigris.subve​rsion.subclipse.grap​h/src/org/tigris/sub​version/sublicpse/gr​aph/cache/Cache.java​&r1=3880&r2=​3881
====================​====================​====================​==================
--- branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava (original)
+++ branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava 2008-06-23 08:49:16-0700
@@ -7,6 +7,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Types;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -54,9 +55,9 @@
                 "file_id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), " +
                 "revision_from BIGINT NOT NULL, " +
                 "revision_to BIGINT, " +
- "path VARCHAR(32672) NOT NULL)"; // no primary key
+ "path VARCHAR(32672) NOT NULL)";
         
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "CREATE TABLE revisions (" +
                 "revision_id BIGINT NOT NULL, " +
@@ -65,7 +66,7 @@
                 "message VARCHAR(32672) NOT NULL, " +
                 "PRIMARY KEY (revision_id))";
 
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "CREATE TABLE change_paths (" +
                 "path VARCHAR(32672) NOT NULL, " +
@@ -73,31 +74,31 @@
                 "copy_src_revision BIGINT, " +
                 "copy_src_path VARCHAR(32672), " +
                 "action CHAR(1) NOT NULL, " +
- "file_id BIGINT NOT NULL, "+
- "PRIMARY KEY (path, revision_id))";
+ "file_id BIGINT NOT NULL)";
+// "PRIMARY KEY (revision_id, path, action))"; // We can have an A and M change_path from the same path in the same revision
         
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "ALTER TABLE change_paths ADD CONSTRAINT fk_change_revision " +
                 "FOREIGN KEY (revision_id) REFERENCES revisions (revision_id)";
         
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "CREATE INDEX files_revision_from ON files (revision_from)";
         
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "CREATE INDEX files_revision_to ON files (revision_to)";
         
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "CREATE INDEX files_path ON files (path)";
         
- executeUpdate(connection, s);
+ executeUpdate(s);
 
         s = "CREATE INDEX files_file_id ON files (file_id)";
         
- executeUpdate(connection, s);
+ executeUpdate(s);
         
     }
     
@@ -125,6 +126,16 @@
             }
         }
     }
+
+ private void closeResultSet(ResultSet result) {
+ if(result != null) {
+ try {
+ result.close();
+ } catch (SQLException e) {
+ throw new CacheException("Error closing ResultSet", e);
+ }
+ }
+ }
 
     private void insertRevision(long revision, Date revisionDate, String author, String message) {
         if(insertRevision == null) {
@@ -134,7 +145,8 @@
                         "revision_date, " +
                         "author, " +
                         "message" +
- ") VALUES (?, ?, ?, ?)");
+ ") VALUES (?, ?, ?, ?)",
+ ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
             } catch(SQLException e) {
                 throw new CacheException("Cannot create insertRevision statement", e);
             }
@@ -178,13 +190,7 @@
         } catch(SQLException e) {
             throw new CacheException("Error inserting revision", e);
         } finally {
- if(result != null) {
- try {
- result.close();
- } catch (SQLException e) {
- throw new CacheException("Error closing ResultSet", e);
- }
- }
+ closeResultSet(result);
         }
     }
     
@@ -195,7 +201,8 @@
                     "file_id, "+
                     "revision_from, " +
                     "path" +
- ") VALUES (?, ?, ?)");
+ ") VALUES (?, ?, ?)",
+ ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
             } catch(SQLException e) {
                 throw new CacheException("Cannot create insertCopyFile statement", e);
             }
@@ -221,7 +228,8 @@
                         "action, " +
                         "file_id, " +
                         "path" +
- ") VALUES (?, ?, ?, ?, ?, ?)");
+ ") VALUES (?, ?, ?, ?, ?, ?)",
+ ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
             } catch(SQLException e) {
                 throw new CacheException("Cannot create insertChangePath statement", e);
             }
@@ -240,14 +248,15 @@
             insertChangePath.setString(6, path);
             insertChangePath.exe​cuteUpdate();
         } catch(SQLException e) {
+ System.err.println(revision+" at "+path+" "+action);
             throw new CacheException("Error inserting change path", e);
         }
     }
     
- private void deleteFile(long revision, long fileId) {
+ private void deleteFile(Map fileIds, long revision, long fileId, String path, boolean recursive) {
         if(deleteFile == null) {
             try {
- deleteFile = connection.prepareSt​atement("UPDATE files SET revision_to=? WHERE file_id=?");
+ deleteFile = connection.prepareSt​atement("UPDATE files SET revision_to=? WHERE file_id=? AND path=?");
             } catch(SQLException e) {
                 throw new CacheException("Cannot create deleteFile statement", e);
             }
@@ -256,40 +265,107 @@
         try {
             deleteFile.setLong(1, revision);
             deleteFile.setLong(2, fileId);
+ deleteFile.setString(3, path);
             deleteFile.executeUpdate();
         } catch(SQLException e) {
             throw new CacheException("Error deleting file", e);
         }
+
+ if(!recursive) return;
+
+ fileIds.remove(path);
+ PreparedStatement selectFiles = null;
+ PreparedStatement delete = null;
+ ResultSet resultSet = null;
+ try {
+ selectFiles = connection.prepareSt​atement("SELECT path FROM files WHERE revision_to IS NULL AND path LIKE ?",
+ ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ selectFiles.setString(1, path+"/%");
+ resultSet = selectFiles.executeQuery();
+ while(resultSet.next()) {
+ String p = resultSet.getString(1);
+ fileIds.remove(p);
+ }
+
+ delete = connection.prepareSt​atement("UPDATE files SET revision_to=? WHERE revision_to IS NULL AND path LIKE ?");
+ delete.setLong(1, revision);
+ delete.setString(2, path+"/%");
+ delete.executeUpdate();
+ } catch(SQLException e) {
+ throw new CacheException("Error while deleting subfiles", e);
+ } finally {
+ closeStatement(selectFiles);
+ closeStatement(delete);
+ closeResultSet(resultSet);
+ }
     }
     
- private void calculateBranches(Map fileIds, String copySrcPath, String path, char action, long copySrcRevision, long revision) {
- // anything with copy_src_path/something has a branch in path/something
+ private void initSelectFiles() {
         if(selectFiles == null) {
             try {
- selectFiles = connection.prepareSt​atement("SELECT path, file_id FROM files WHERE revision_to IS NULL AND path LIKE ?");
+ selectFiles = connection.prepareSt​atement("SELECT path, file_id FROM files WHERE revision_from <=? AND (revision_to IS NULL OR revision_to>?) AND path LIKE ?");
             } catch(SQLException e) {
                 throw new CacheException("Cannot create selectFiles statement", e);
             }
         }
-
+ }
+
+ private void addSubfiles(Map fileIds, String copySrcPath, String path, char action, long copySrcRevision, long revision, boolean ignoreIfAlreadyExists) {
+ // anything with copy_src_path/something has a branch in path/something
+ initSelectFiles();
         try {
- selectFiles.setString(1, copySrcPath+"/%");
+ selectFiles.setLong(1, copySrcRevision);
+ selectFiles.setLong(2, copySrcRevision);
+ selectFiles.setString(3, copySrcPath+"/%");
 
             int length = copySrcPath.length();
             ResultSet r = selectFiles.executeQuery();
+// System.out.println("calculating branches. "+path+" from "+copySrcPath);
             while(r.next()) {
                 String fromPath = r.getString(1);
                 long fileId = r.getLong(2);
                 String finalPath = path + fromPath.substring(length);
- insertCopyFile(fileId, revision, finalPath);
- fileIds.put(finalPath, new Long(fileId));
+// System.out.println(finalPath);
+
+ Long id = getFileId(finalPath, revision);
+ if(id == null) {
+ insertCopyFile(fileId, revision, finalPath);
+ fileIds.put(finalPath, new Long(fileId));
+
+ insertChangePath(revision,
+ new Long(copySrcRevision),
+ fromPath,
+ action,
+ fileId,
+ finalPath);
+ } else {
+ if(!ignoreIfAlreadyExists) {
+ System.err.println(finalPath+" at "+revision+" already exists");
+ System.err.println("when calculating branches for copy of "+path+" from "+fromPath);
+ /*
+ try {
+ PreparedStatement st = connection.prepareSt​atement("SELECT file_id, revision_from, revision_to, path FROM files WHERE file_id=? OR path=?");
+ st.setLong(1, id.longValue());
+ st.setString(2, finalPath);
+ ResultSet result = st.executeQuery();
+ while(result.next()) {
+ System.err.println(M​essageFormat.format(​"{0} {1}:{2} {3}", new Object[]{
+ new Long(result.getLong(1)),
+ new Long(result.getLong(2)),
+ new Long(result.getLong(3)),
+ result.getString(4)
+ }));
+ }
+ } catch(SQLException ex) {
+ ex.printStackTrace();
+ }
+ */
 
- insertChangePath(revision,
- new Long(copySrcRevision),
- fromPath,
- action,
- fileId,
- finalPath);
+// throw new CacheException();
+ } else {
+// System.out.println("...");
+ }
+ }
             }
         } catch(SQLException e) {
             throw new CacheException("Error calculating branches", e);
@@ -301,71 +377,135 @@
         
         for (int i = 0; i < messages.length; i++) {
             ISVNLogMessage logMessage = messages[i];
-
             long revision = logMessage.getRevisi​on().getNumber();
-
             insertRevision(revision,
                     logMessage.getDate(),
                     logMessage.getAuthor(),
                     logMessage.getMessage());
             
             ISVNLogMessageChangePath[] changedPaths = logMessage.getChangedPaths();
-
             for (int j = 0; j < changedPaths.length; j++) {
                 ISVNLogMessageChangePath changePath = changedPaths[j];
                 
- char action = changePath.getAction();
- long fileId;
+ Long copySrcRevision = null;
+ if(changePath.getCop​ySrcRevision() != null) {
+ copySrcRevision = new Long(changePath.getC​opySrcRevision().get​Number());
+ }
                 
- switch(action) {
+ switch(changePath.getAction()) {
                 case 'A':
- if(changePath.getCop​ySrcRevision() == null) {
- fileId = insertFile(revision, changePath.getPath());
- fileIds.put(changePa​th.getPath(), new Long(fileId));
- } else {
- fileId = getFileId(changePath​.getCopySrcPath(), changePath.getCopySr​cRevision().getNumbe​r()).longValue();
- insertCopyFile(fileId, revision, changePath.getPath());
- fileIds.put(changePa​th.getPath(), new Long(fileId));
-
- calculateBranches(fileIds,
- changePath.getCopySrcPath(),
- changePath.getPath(),
- action,
- changePath.getCopySr​cRevision().getNumbe​r(),
- revision);
- }
+ addedAction(changePath, fileIds, revision, copySrcRevision);
                     break;
                 case 'M':
- fileId = getFileId(fileIds, changePath.getPath(), revision);
+ modifiedAction(changePath, fileIds, revision, copySrcRevision);
                     break;
                 case 'D':
- fileId = getFileId(fileIds, changePath.getPath(), revision);
- deleteFile(revision, fileId);
+ deletedAction(changePath, fileIds, revision, copySrcRevision, true);
                     break;
+ case 'R':
+ deletedAction(changePath, fileIds, revision, copySrcRevision, false);
+ addedAction(changePath, fileIds, revision, copySrcRevision);
+ continue;
                 default:
- // TODO: assert or throw exception
- System.err.println("Unknown action: "+action);
- fileId = 0;
+ System.err.println("Unknown action: "+changePath.getAction());
                 }
+ }
+ }
+ }
+
+ private void addedAction(ISVNLogM​essageChangePath changePath, Map fileIds, long revision, Long copySrcRevision) throws Exception {
+ long fileId = 0;
+ char action = 'A';
+ if(changePath.getCop​ySrcRevision() == null) {
+ fileId = insertFile(revision, changePath.getPath());
+ fileIds.put(changePa​th.getPath(), new Long(fileId));
+ } else {
+ Long l = getFileId(changePath​.getCopySrcPath(), changePath.getCopySr​cRevision().getNumbe​r());
+ if(l == null) {
+ System.err.println(c​hangePath.getCopySrc​Path()+" not found at revision "+changePath.getCopy​SrcRevision().getNum​ber());
+ System.err.println(c​hangePath.getPath())​;
                 
- Long copySrcRevision = null;
- if(changePath.getCop​ySrcRevision() != null) {
- copySrcRevision = new Long(changePath.getC​opySrcRevision().get​Number());
+ PreparedStatement st = connection.prepareSt​atement("SELECT file_id, revision_from, revision_to, path FROM files WHERE path LIKE ?");
+ st.setString(1, changePath.getCopySrcPath());
+ ResultSet result = st.executeQuery();
+ while(result.next()) {
+ System.err.println(M​essageFormat.format(​"{0} {1}:{2} {3}", new Object[]{
+ new Long(result.getLong(1)),
+ new Long(result.getLong(2)),
+ new Long(result.getLong(3)),
+ result.getString(4)
+ }));
                 }
-
- insertChangePath(revision,
- copySrcRevision,
- changePath.getCopySrcPath(),
- action, fileId,
- changePath.getPath());
             }
- }
+ fileId = l.longValue();
+ insertCopyFile(fileId, revision, changePath.getPath());
+ fileIds.put(changePa​th.getPath(), new Long(fileId));
+
+ boolean ignoreIfAlreadyExists = changePath.getAction() == 'R';
+// if(changePath.getAction() == 'A') { // not if R
+ addSubfiles(fileIds,
+ changePath.getCopySrcPath(),
+ changePath.getPath(),
+ action,
+ changePath.getCopySr​cRevision().getNumbe​r(),
+ revision,
+ ignoreIfAlreadyExists);
+// }
+ }
+
+ insertChangePath(revision,
+ copySrcRevision,
+ changePath.getCopySrcPath(),
+ action,
+ fileId,
+ changePath.getPath());
+ }
+
+ private void modifiedAction(ISVNL​ogMessageChangePath changePath, Map fileIds, long revision, Long copySrcRevision) {
+ long fileId = getFileId(fileIds, changePath.getPath(), revision);
+ insertChangePath(revision,
+ copySrcRevision,
+ changePath.getCopySrcPath(),
+ changePath.getAction(),
+ fileId,
+ changePath.getPath());
+ }
+
+ private void deletedAction(ISVNLo​gMessageChangePath changePath, Map fileIds,
+ long revision, Long copySrcRevision, boolean recursive) {
+ long fileId = getFileId(fileIds, changePath.getPath(), revision);
+ deleteFile(fileIds, revision, fileId, changePath.getPath(), recursive);
+ insertChangePath(revision,
+ copySrcRevision,
+ changePath.getCopySrcPath(),
+ 'D',
+ fileId,
+ changePath.getPath());
     }
     
     private long getFileId(Map fileIds, String path, long revision) {
         Long l = ((Long) fileIds.get(path));
         if(l == null) {
             l = getFileId(path, revision);
+ if(l == null) {
+ System.err.println(path+" not in revision "+revision);
+
+ try {
+ PreparedStatement st = connection.prepareSt​atement("SELECT file_id, revision_from, revision_to, path FROM files WHERE path LIKE ?");
+ st.setString(1, path);
+ ResultSet result = st.executeQuery();
+ while(result.next()) {
+ System.err.println(M​essageFormat.format(​"{0} {1}:{2} {3}", new Object[]{
+ new Long(result.getLong(1)),
+ new Long(result.getLong(2)),
+ new Long(result.getLong(3)),
+ result.getString(4)
+ }));
+ }
+ } catch(SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
             fileIds.put(path, l);
         }
         return l.longValue();
@@ -373,7 +513,7 @@
     
     public Long getFileId(String path, long revision) {
         String sql = "SELECT file_id FROM files " +
- "WHERE path=? AND revision_from<=? AND (revision_to>=? OR revision_to IS NULL)";
+ "WHERE path=? AND revision_from<=? AND (revision_to>? OR revision_to IS NULL)"; // revision_to>=?
 
         PreparedStatement statement = null;
         ResultSet result = null;
@@ -390,20 +530,8 @@
         } catch(SQLException e) {
             throw new CacheException(e);
         } finally {
- if(result != null) {
- try {
- result.close();
- } catch (SQLException e) {
- throw new CacheException(e);
- }
- }
- if(statement != null) {
- try {
- statement.close();
- } catch (SQLException e) {
- throw new CacheException(e);
- }
- }
+ closeResultSet(result);
+ closeStatement(statement);
         }
     }
     
@@ -422,20 +550,8 @@
         } catch(SQLException e) {
             throw new CacheException(e);
         } finally {
- if(result != null) {
- try {
- result.close();
- } catch (SQLException e) {
- throw new CacheException(e);
- }
- }
- if(statement != null) {
- try {
- statement.close();
- } catch (SQLException e) {
- throw new CacheException(e);
- }
- }
+ closeResultSet(result);
+ closeStatement(statement);
         }
     }
     
@@ -469,24 +585,12 @@
         } catch(SQLException e) {
             throw new CacheException(e);
         } finally {
- if(result != null) {
- try {
- result.close();
- } catch (SQLException e) {
- throw new CacheException(e);
- }
- }
- if(statement != null) {
- try {
- statement.close();
- } catch (SQLException e) {
- throw new CacheException(e);
- }
- }
+ closeResultSet(result);
+ closeStatement(statement);
         }
     }
     
- private void executeUpdate(Connection connection, String sql) {
+ private void executeUpdate(String sql) {
         try {
             connection.createSta​tement().executeUpda​te(sql);
         } catch (SQLException e) {
@@ -507,9 +611,10 @@
         return node;
     }
     
- public static void main(String[] args) throws Exception {
- File f = new File("foo");
- new Cache(f);
+ public void clearCache() {
+ executeUpdate("DELETE FROM change_paths");
+ executeUpdate("DELETE FROM revisions");
+ executeUpdate("DELETE FROM files");
     }
 
 }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r3881 - branches/GSoC2008/gimenete/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion: subclipse/graph/popup/actions sublicpse/graph/cache gimenete Alberto Gimeno 2008-06-23 08:49:16 PDT
Messages per page: