Java Code Examples for org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages()

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommitAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns log message for given revision
 * @param client
 * @param file
 * @param revision
 * @return log message
 * @throws org.tigris.subversion.svnclientadapter.SVNClientException
 */
private static ISVNLogMessage getLogMessage (ISVNClientAdapter client, File file, long revision) throws SVNClientException {
    SVNRevision rev = SVNRevision.HEAD;
    ISVNLogMessage log = null;
    try {
        rev = SVNRevision.getRevision(String.valueOf(revision));
    } catch (ParseException ex) {
        Subversion.LOG.log(Level.WARNING, "" + revision, ex);
    }
    if (Subversion.LOG.isLoggable(Level.FINER)) {
        Subversion.LOG.log(Level.FINER, "{0}: getting last commit message for svn hooks", CommitAction.class.getName());
    }
    // log has to be called directly on the file
    final SVNUrl fileRepositoryUrl = SvnUtils.getRepositoryUrl(file);
    ISVNLogMessage[] ls = client.getLogMessages(fileRepositoryUrl, rev, rev);
    if (ls.length > 0) {
        log = ls[0];
    } else {
        Subversion.LOG.log(Level.WARNING, "no logs available for file {0} with repo url {1}", new Object[]{file, fileRepositoryUrl});
    }
    return log;
}
 
Example 2
Source File: ShowAnnotationOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private String getSingleEntry(ISVNRemoteFile file, Long revLong) {
	ISVNClientAdapter client = null;
	try {
		client = file.getRepository().getSVNClient();
		SVNRevision revision = SVNRevision.getRevision(revLong.toString());
		ISVNLogMessage [] messages = client.getLogMessages(file.getRepository().getRepositoryRoot(), revision, revision, false);
		if (messages.length == 1)
			return messages[0].getMessage();
		else
			return null;
	} catch (Exception e) {
		return null;
	}
	finally {
		file.getRepository().returnSVNClient(client);
	}
}
 
Example 3
Source File: ResolveTreeConflictWizard.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private ISVNLogMessage[] getLogMessages() throws Exception {
	if (logMessages == null) {
		ISVNClientAdapter svnClient = null;
		try {
			svnClient = svnResource.getRepository().getSVNClient();
			IProject project = treeConflict.getResource().getProject();
			ISVNLocalResource svnProject =  SVNWorkspaceRoot.getSVNResourceFor(project);
			SVNRevision revision1 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision());
			SVNRevision revision2 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision());
			logMessages = svnClient.getLogMessages(svnProject.getUrl(), revision1, revision2, true); 
		} catch (Exception e) {
			throw e;
		}
		finally {
			svnResource.getRepository().returnSVNClient(svnClient);
		}
	}
	return logMessages;
}
 
Example 4
Source File: RemoteResource.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNLogMessage[] getLogMessages(SVNRevision pegRevision,
		SVNRevision revisionStart, SVNRevision revisionEnd,
		boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions)
		throws TeamException {
   	ISVNClientAdapter svnClient = repository.getSVNClient();
	try {
		return svnClient.getLogMessages(getUrl(),
				pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath,
				limit, includeMergedRevisions);
	} catch (SVNClientException e) {
		throw new TeamException("Failed in RemoteResource.getLogMessages()",
				e);
	}
	finally {
		repository.returnSVNClient(svnClient);
	}
}
 
Example 5
Source File: BaseResource.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNLogMessage[] getLogMessages(SVNRevision pegRevision,
		SVNRevision revisionStart, SVNRevision revisionEnd,
		boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions)
		throws TeamException {
   	ISVNClientAdapter svnClient = getRepository().getSVNClient();
	try {
		return svnClient.getLogMessages(getFile(), pegRevision,
				revisionStart, revisionEnd, stopOnCopy, fetchChangePath,
				limit, includeMergedRevisions);
	} catch (SVNClientException e) {
		throw new TeamException("Failed in BaseResource.getLogMessages()",
				e);
	}
	finally {
		getRepository().returnSVNClient(svnClient);
	}
}
 
Example 6
Source File: LogEntry.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private ISVNLogMessageChangePath[] getPathsOnDemand(SVNUrl url) {
ISVNLogMessage[] tmpMessage;
ISVNClientAdapter client = null;
      try {
          client = SVNProviderPlugin.getPlugin().getSVNClient(); // errors will not log to console
          SVNProviderPlugin.disableConsoleLogging(); 
          tmpMessage = client.getLogMessages(url, getRevision(), getRevision(), true);
          SVNProviderPlugin.enableConsoleLogging(); 
       if (tmpMessage != null && tmpMessage.length > 0)
	    return tmpMessage[0].getChangedPaths();
	else
	    return null;
      } catch (Exception e) {
          SVNProviderPlugin.enableConsoleLogging(); 
          return null;
      } finally {
       SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
      }
  }
 
Example 7
Source File: SVNChangeSetCollector.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
   * Fetch the comment of the given SyncInfo
   * @param info info to get comment for
   * @return the comment
   */
  private String fetchComment(SVNStatusSyncInfo info) {
String fetchedComment = Policy.bind("SynchronizeView.standardIncomingChangeSetComment"); // $NON-NLS-1$
  	IResourceVariant remoteResource = info.getRemote();
  	if (remoteResource instanceof ISVNRemoteResource) {
  		ISVNRemoteResource svnRemoteResource = (ISVNRemoteResource)remoteResource;
  		ISVNClientAdapter client = null;
  		try {
		client = svnRemoteResource.getRepository().getSVNClient();
   		SVNUrl url = svnRemoteResource.getRepository().getRepositoryRoot();
   		SVNRevision rev = svnRemoteResource.getLastChangedRevision();
   		ISVNLogMessage[] logMessages = client.getLogMessages(url, rev, rev, false);
		if (logMessages.length != 0) {
			String logComment = logMessages[0].getMessage();
			if (logComment.trim().length() != 0) {
				fetchedComment = flattenComment(logComment); 
			} else {
				fetchedComment = "";
			}
		}
	} catch (SVNException e1) {
		if (!e1.operationInterrupted()) {
			SVNUIPlugin.log(e1);
		}
	} catch (SVNClientException e) {
		SVNUIPlugin.log(SVNException.wrapException(e));
	}
  		finally {
  			svnRemoteResource.getRepository().returnSVNClient(client);
  		}
 		}
  	return fetchedComment;
  }
 
Example 8
Source File: GetLogsCommand.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * execute the command
 * @param aMonitor
 * @throws SVNException
 */
public void run(IProgressMonitor aMonitor) throws SVNException {
	ISVNRepositoryLocation repository = null;
	ISVNClientAdapter svnClient = null;
    logEntries = null;
    IProgressMonitor monitor = Policy.monitorFor(aMonitor);
    monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
    
    ISVNLogMessage[] logMessages;
    try {
    	if (callback == null) {
         logMessages = remoteResource.getLogMessages(
                 pegRevision,
                 revisionStart,
                 revisionEnd, 
                 stopOnCopy,
                 !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(),
                 limit, includeMergedRevisions);
    	} else {
    		repository = remoteResource.getRepository();
    		svnClient = repository.getSVNClient();
    		if (remoteResource instanceof BaseResource) {
    			boolean logMessagesRetrieved = false;
    			ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(remoteResource.getResource());
    			if (svnResource != null) {
    				LocalResourceStatus status = svnResource.getStatus();
    				if (status != null && status.isCopied()) {
    					ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
    					SVNUrl copiedFromUrl = info.getCopyUrl();
    					if (copiedFromUrl != null) {
    						svnClient.getLogMessages(copiedFromUrl, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
    						logMessagesRetrieved = true;
    		        		GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(remoteResource.getRepository(), copiedFromUrl, SVNRevision.HEAD);
    		        		getRemoteResourceCommand.run(null);
    		        		remoteResource = getRemoteResourceCommand.getRemoteResource();
    					}
    				}
    			}
    			if (!logMessagesRetrieved) svnClient.getLogMessages(((BaseResource)remoteResource).getFile(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
    		} else {
    			svnClient.getLogMessages(remoteResource.getUrl(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
    		}
    		logMessages = callback.getLogMessages();
    	}
        if (remoteResource.isFolder()) {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFolder) remoteResource, logMessages, getTags(logMessages));   
        } else {
        	logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFile) remoteResource, logMessages, getTags(logMessages), getUrls(logMessages));
        }

    } catch (Exception e) {
        throw SVNException.wrapException(e);
    } finally {
    	if (repository != null) {
    		repository.returnSVNClient(svnClient);
    	}
    	monitor.done();
    }
}