From: <jbo...@li...> - 2005-12-17 17:40:50
|
Author: adamw Date: 2005-12-17 12:40:41 -0500 (Sat, 17 Dec 2005) New Revision: 1836 Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-37 : wc update optimization Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2005-12-17 17:03:21 UTC (rev 1835) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2005-12-17 17:40:41 UTC (rev 1836) @@ -60,6 +60,12 @@ private Set<String> frozenModifiedTrees; private Set<String> frozenDeletedResources; + /** + * <code>lastRevision</code> - last revision to which the wc was updated. + * Used to prevent unnecessary updates if the revision hasn't changed. + */ + private long lastRevision; + private Object synchronizer; public SvnRepository(String username, String password, @@ -78,6 +84,8 @@ log.warn("Error while creating SVNRepoistory.", e); } + lastRevision = -1; + this.url = url; wc = new File(localpath); @@ -136,6 +144,17 @@ */ private synchronized void update(boolean tryCheckout, boolean firstTime) { /* + * Checking if there is any need for updating the working copy. + */ + try { + if (lastRevision == repository.getLatestRevision()) { + return; + } + } catch (SVNException e1) { + // Trying to continue ... + } + + /* * Freezing all entries in the modified/ deleted sets. After update, * these sets will be cleaned, because all changes that they stored * information about will be reflected in the WC. But any files that @@ -168,7 +187,7 @@ * probably the wc hasn't been checked out yet. That's why * we try to do a check out in case of an error. */ - updateClient.doUpdate(wc, SVNRevision.HEAD, + lastRevision = updateClient.doUpdate(wc, SVNRevision.HEAD, true); } catch (SVNException e) { if (tryCheckout) { |