use of org.tigris.subversion.svnclientadapter.ISVNLogMessage in project subclipse by subclipse.
the class Cache method createGraph.
public Graph createGraph(String rootPath, long revision, WorkListener listener) {
// System.out.println("create graph");
Graph graph = new Graph(rootPath);
// root path is the first opened branch
graph.addBranch(rootPath);
long seek = getSeek(revision);
RandomAccessFile file = null;
try {
file = new RandomAccessFile(logMessagesFile, "r");
file.seek(seek);
while (file.getFilePointer() < file.length()) {
ISVNLogMessage lm = readNext(file, true);
ISVNLogMessageChangePath[] changedPaths = lm.getChangedPaths();
String[] pa = graph.getPathsAsArray();
Node node = null;
for (int n = 0; n < changedPaths.length; n++) {
ISVNLogMessageChangePath cp = changedPaths[n];
String nodePath = cp.getPath();
String copySrcPath = cp.getCopySrcPath();
for (int i = 0; i < pa.length; i++) {
String branchPath = pa[i];
if (copySrcPath == null) {
if ((cp.getAction() == 'A' && nodePath.equals(branchPath)) || (cp.getAction() == 'D' && isEqualsOrParent(nodePath, branchPath)) || (cp.getAction() == 'M' && nodePath.equals(branchPath))) {
Branch branch = graph.getBranch(branchPath);
if (branch.isEnded()) {
// the branch was ended with a D action
continue;
}
node = toNode(lm, cp);
node.setParent(branch.getLastNode());
branch.addNode(node);
if (node.getAction() == 'D') {
branch.end();
}
}
} else if (copySrcPath != null && isEqualsOrParent(copySrcPath, branchPath)) {
Branch branch = graph.getBranch(branchPath);
Node source = branch.getSource(cp.getCopySrcRevision().getNumber());
if (source == null)
continue;
node = toNode(lm, cp);
node.setSource(source);
String path = nodePath + branchPath.substring(copySrcPath.length());
Branch newBranch = graph.getBranch(path);
if (newBranch == null) {
newBranch = graph.addBranch(path);
}
newBranch.addNode(node);
}
}
}
if (node != null && lm.hasChildren()) {
ISVNLogMessage[] cm = lm.getChildMessages();
for (int i = 0; i < cm.length; i++) {
ISVNLogMessage child = cm[i];
ISVNLogMessageChangePath[] cp = child.getChangedPaths();
for (int j = 0; j < cp.length; j++) {
ISVNLogMessageChangePath changePath = cp[j];
for (int k = 0; k < pa.length; k++) {
String path = pa[k];
if (path.equals(changePath.getPath())) {
Branch branch = graph.getBranch(path);
Node source = branch.getSource(child.getRevision().getNumber());
if (source == null)
continue;
// add connection between "node" and "source"
node.addMergedRevision(source);
}
}
}
}
}
if (listener != null)
listener.worked();
}
} catch (IOException e) {
throw new CacheException("Error while calculating graph", e);
} finally {
closeFile(file);
}
// Tags
List paths = graph.getPaths();
Iterator iter = paths.iterator();
while (iter.hasNext()) {
String path = (String) iter.next();
Branch branch = graph.getBranch(path);
if (branch.getNodes().size() == 1) {
Node firstNode = (Node) branch.getNodes().iterator().next();
if (firstNode.getSource() != null && firstNode.getChildCount() == 0) {
// therefore is a tag
if (firstNode.getSource() != null) {
firstNode.getSource().addTag(firstNode);
}
}
}
}
return graph;
}
use of org.tigris.subversion.svnclientadapter.ISVNLogMessage in project subclipse by subclipse.
the class GetLogsCommand method run.
/**
* 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);
// $NON-NLS-1$
monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100);
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();
}
}
use of org.tigris.subversion.svnclientadapter.ISVNLogMessage in project subclipse by subclipse.
the class ShowAnnotationOperation method getSingleEntry.
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);
}
}
use of org.tigris.subversion.svnclientadapter.ISVNLogMessage in project subclipse by subclipse.
the class Cache method writeChildren.
private void writeChildren(int level, boolean writingTempFile) throws IOException {
List nonWrittenChildren = getNonWrittenChildren();
// System.out.println("B. Children: " + nonWrittenChildren.size());
if (writingTempFile)
logMessagesTempRaf.writeInt(nonWrittenChildren.size());
else
logMessagesRaf.writeInt(nonWrittenChildren.size());
// for (Iterator it = children.iterator(); it.hasNext();) {
for (Iterator it = nonWrittenChildren.iterator(); it.hasNext(); ) {
ISVNLogMessage logMessage = (ISVNLogMessage) it.next();
writeLogMessage(logMessage, level, writingTempFile);
}
}
use of org.tigris.subversion.svnclientadapter.ISVNLogMessage in project subclipse by subclipse.
the class Cache method refresh.
public void refresh(List refreshedNodes, ISVNInfo info, IProgressMonitor monitor, int unitWorked) {
ISVNLogMessageCallback callback = new ISVNLogMessageCallback() {
public void singleMessage(ISVNLogMessage message) {
update(message, true);
}
};
revisionsTempFile = new File(root, "revisionsTemp");
logMessagesTempFile = new File(root, "logMessagesTemp");
revisionsTempFile.delete();
logMessagesTempFile.delete();
try {
revisionsTempFile.createNewFile();
logMessagesTempFile.createNewFile();
} catch (IOException e) {
Activator.handleError(e);
}
List revisions = new ArrayList();
Iterator iter = refreshedNodes.iterator();
while (iter.hasNext()) {
Node node = (Node) iter.next();
revisions.add(Long.toString(node.getRevision()));
}
startTempUpdate();
RandomAccessFile file = null;
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClient();
file = new RandomAccessFile(logMessagesFile, "r");
int revInt = new Long(getLatestRevision()).intValue();
while (file.getFilePointer() < file.length()) {
ISVNLogMessage lm = readNext(file, true);
level = 0;
int index = revisions.indexOf(lm.getRevision().toString());
if (index == -1) {
update(lm, true);
if (lm.hasChildren() && lm.getChildMessages() != null) {
updateChildren(lm, true);
}
monitor.worked(unitWorked / revInt);
} else {
Node updateNode = (Node) refreshedNodes.get(index);
SVNRevision updateRevision = new SVNRevision.Number(updateNode.getRevision());
client.getLogMessages(new SVNUrl(info.getRepository() + updateNode.getPath()), updateRevision, updateRevision, updateRevision, false, true, 0, true, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
monitor.worked(unitWorked);
// updateRevision = (ISVNLogMessage)refreshedMessages.get(index);
// monitor.worked(unitWorked);
}
if (monitor.isCanceled()) {
break;
}
}
} catch (Exception e) {
} finally {
closeFile(file);
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
finishTempUpdate();
if (monitor.isCanceled()) {
revisionsTempFile.delete();
logMessagesTempFile.delete();
return;
}
revisionsFile.delete();
logMessagesFile.delete();
revisionsTempFile.renameTo(revisionsFile);
logMessagesTempFile.renameTo(logMessagesFile);
}
Aggregations