use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter 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);
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class DeleteCacheAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
final ISVNRemoteFolder[] selectedFolders = getSelectedRemoteFolders();
error = null;
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClient();
info = client.getInfo(selectedFolders[0].getUrl());
} catch (Exception e) {
error = e;
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
if (error != null) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("DeleteCacheAction.title"), // $NON-NLS-1$
error.getMessage());
return;
}
String uuid = info.getUuid();
File f = Cache.getCacheDirectory(null);
f = new File(f, uuid);
if (!f.exists()) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), Policy.bind("DeleteCacheAction.title"), // $NON-NLS-1$ //$NON-NLS-2$
Policy.bind("DeleteCacheAction.noCache"));
return;
}
String[] url = { selectedFolders[0].getUrl().toString() };
if (!MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Policy.bind("DeleteCacheAction.title"), Policy.bind("DeleteCacheAction.confirm", url)))
// $NON-NLS-1$ //$NON-NLS-2$
return;
// $NON-NLS-1$
File revisionsFile = new File(f, "revisions");
if (!deleteFile(revisionsFile, true))
return;
// $NON-NLS-1$
File logMessagesFile = new File(f, "logMessages");
if (!deleteFile(logMessagesFile, true))
return;
// Just in case of a failed refresh
// $NON-NLS-1$
File revisionsTempFile = new File(f, "revisionsTemp");
deleteFile(revisionsTempFile, false);
// $NON-NLS-1$
File logMessagesTempFile = new File(f, "logMessagesTemp");
deleteFile(logMessagesTempFile, false);
deleteFile(f, true);
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class ResolveTreeConflictWizard method getLocalCopiedTo.
public ISVNStatus getLocalCopiedTo(boolean getAll) throws SVNException, SVNClientException {
String endsWithCheck = treeConflict.getConflictDescriptor().getSrcRightVersion().getPathInRepos();
IProject project = svnResource.getResource().getProject();
if (project != null) {
// $NON-NLS-1$ //$NON-NLS-2$
int index = endsWithCheck.indexOf("/" + project.getName() + "/");
if (index != -1)
endsWithCheck = endsWithCheck.substring(index);
}
if (copiedTo == null && !copiedToRetrieved) {
statuses = getStatuses(getAll);
ISVNClientAdapter svnClient = svnResource.getRepository().getSVNClient();
for (int i = 0; i < statuses.length; i++) {
if (statuses[i].isCopied() && statuses[i].getTextStatus().equals(SVNStatusKind.ADDED)) {
ISVNInfo info = svnClient.getInfoFromWorkingCopy(statuses[i].getFile());
if (info.getCopyUrl() != null) {
if ((svnResource.getUrl() != null && info.getCopyUrl().toString().equals(svnResource.getUrl().toString())) || (info.getCopyUrl().toString().endsWith(endsWithCheck))) {
copiedTo = statuses[i];
break;
}
}
}
}
svnResource.getRepository().returnSVNClient(svnClient);
}
copiedToRetrieved = true;
return copiedTo;
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class PropertyCompareLocalResourceNode method getProperties.
public void getProperties(boolean recursive) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
ISVNClientAdapter svnClient = null;
try {
svnClient = svnResource.getRepository().getSVNClient();
properties = svnClient.getProperties(resource.getLocation().toFile(), recursive);
} catch (Exception e) {
SVNUIPlugin.log(Status.ERROR, e.getMessage(), e);
} finally {
svnResource.getRepository().returnSVNClient(svnClient);
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class SVNFolderCompareEditorInput method prepareInput.
protected Object prepareInput(IProgressMonitor monitor) throws InterruptedException {
final boolean threeWay = ancestor != null;
if (right == null || left == null) {
// $NON-NLS-1$
setMessage(Policy.bind("SVNCompareEditorInput.different"));
return null;
}
initLabels();
final Object[] result = new Object[] { null };
ISVNClientAdapter svnClient = null;
try {
// do the diff
// $NON-NLS-1$
monitor.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 30);
IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
// $NON-NLS-1$
sub.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 100);
try {
svnClient = folder1.getRepository().getSVNClient();
SVNDiffSummary[] diffSummary = null;
if (folder1.getRepositoryRelativePath().equals(folder2.getRepositoryRelativePath()) && localResource1 != null) {
IResource resource1 = localResource1.getResource();
if (resource1 != null) {
ISVNLocalResource svnResource1 = SVNWorkspaceRoot.getSVNResourceFor(resource1);
if (svnResource1 != null) {
SVNRevision pegRevision = svnResource1.getRevision();
if (pegRevision != null) {
diffSummary = svnClient.diffSummarize(folder1.getUrl(), pegRevision, folder2.getRevision(), folder1.getRevision(), Depth.infinity, true);
}
}
} else {
diffSummary = svnClient.diffSummarize(folder1.getUrl(), SVNRevision.HEAD, folder2.getRevision(), folder1.getRevision(), Depth.infinity, true);
}
}
if (diffSummary == null)
diffSummary = svnClient.diffSummarize(folder1.getUrl(), folder1.getRevision(), folder2.getUrl(), folder2.getRevision(), Depth.infinity, true);
diffSummary = getDiffSummaryWithSubfolders(diffSummary);
left.setDiffSummary(diffSummary);
right.setDiffSummary(diffSummary);
left.setRoot(true);
right.setRoot(true);
result[0] = new SummaryDifferencer().findDifferences(threeWay, sub, null, ancestor, left, right);
} finally {
sub.done();
}
if (result[0] instanceof DiffNode) {
IDiffElement[] diffs = ((DiffNode) result[0]).getChildren();
if (diffs == null || diffs.length == 0) {
result[0] = null;
}
}
return result[0];
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getMessage());
} catch (Exception e) {
return e.getMessage();
} finally {
folder1.getRepository().returnSVNClient(svnClient);
monitor.done();
}
}
Aggregations