use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffDialogWC method okPressed.
protected void okPressed() {
success = true;
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
try {
if (toHeadButton.getSelection())
toRevision = SVNRevision.HEAD;
else {
int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
long toRevisionLong = toRevisionInt;
toRevision = new SVNRevision.Number(toRevisionLong);
}
toUrl = new SVNUrl(toUrlText.getText().trim());
File path = new File(resource.getLocation().toString());
svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
pegRevision = null;
if (toUrlText.getText().equals(selectedResourceUrl)) {
ISVNRemoteResource baseResource = svnResource.getBaseResource();
if (baseResource != null) {
pegRevision = baseResource.getLastChangedRevision();
}
}
if (pegRevision == null) {
pegRevision = toRevision;
}
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
ISVNInfo svnInfo = svnClient.getInfo(toUrl, toRevision, pegRevision);
SVNNodeKind nodeKind = svnInfo.getNodeKind();
if (resource instanceof IContainer) {
if (nodeKind.toInt() == SVNNodeKind.FILE.toInt()) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileToFolder"));
success = false;
return;
}
} else {
if (nodeKind.toInt() == SVNNodeKind.DIR.toInt()) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileToFolder"));
success = false;
return;
}
}
if (diffButton.getSelection()) {
diffToOutputFile = true;
file = new File(fileText.getText().trim());
if (file.exists()) {
if (!MessageDialog.openQuestion(getShell(), Policy.bind("HistoryView.showDifferences"), Policy.bind("HistoryView.overwriteOutfile", file.getName())))
return;
}
operation = new ShowDifferencesAsUnifiedDiffOperationWC(targetPart, path, toUrl, toRevision, file);
operation.setGraphicalCompare(true);
} else {
diffToOutputFile = false;
success = true;
}
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
success = false;
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
}
});
if (!success)
return;
toUrlText.saveUrl();
super.okPressed();
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class ShowRevisionsDialog method getShowDifferencesAsUnifiedDiffAction.
// get differences as unified diff action (context menu)
private IAction getShowDifferencesAsUnifiedDiffAction() {
if (showDifferencesAsUnifiedDiffAction == null) {
showDifferencesAsUnifiedDiffAction = new Action(Policy.bind("HistoryView.showDifferences"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
ISVNUIConstants.IMG_MENU_DIFF)) {
public void run() {
ISelection selection = treeHistoryViewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) selection;
ILogEntry currentSelection = (ILogEntry) ss.getFirstElement();
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
dialog.setText("Select Unified Diff Output File");
dialog.setFileName(// $NON-NLS-1$
"revision" + currentSelection.getRevision().getNumber() + ".diff");
String outFile = dialog.open();
if (outFile != null) {
final SVNUrl url = currentSelection.getResource().getUrl();
final SVNRevision oldUrlRevision = new SVNRevision.Number(currentSelection.getRevision().getNumber() - 1);
final SVNRevision newUrlRevision = currentSelection.getRevision();
final File file = new File(outFile);
if (file.exists()) {
if (!MessageDialog.openQuestion(getShell(), Policy.bind("HistoryView.showDifferences"), Policy.bind("HistoryView.overwriteOutfile", file.getName())))
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.diff(url, oldUrlRevision, newUrlRevision, file, true);
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
}
}
};
}
return showDifferencesAsUnifiedDiffAction;
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class SVNPropertyPage method getStatus.
private void getStatus() {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
try {
IResource resource = (IResource) getElement();
SVNTeamProvider svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
if (svnProvider == null)
return;
svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
if (svnResource == null)
return;
status = svnResource.getStatus();
if (status != null && !status.isIgnored()) {
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
urlCopiedFrom = info.getCopyUrl();
revision = svnResource.getRevision();
lockOwnerText = status.getLockOwner();
lockCommentText = status.getLockComment();
if (status.getLockCreationDate() != null)
lockDateText = status.getLockCreationDate().toString();
if (!status.isAdded()) {
try {
info = svnClient.getInfo(status.getUrl());
} catch (Exception e) {
}
}
// Get lock information from server if svn:needs-lock property is set
if (info != null && status.getLockOwner() == null && status.getUrlString() != null) {
ISVNProperty prop = svnResource.getSvnProperty("svn:needs-lock");
if (prop != null) {
lockOwnerText = info.getLockOwner();
if (info.getLockCreationDate() != null)
lockDateText = info.getLockCreationDate().toString();
lockCommentText = info.getLockComment();
}
}
}
} catch (Exception e) {
SVNUIPlugin.log(new Status(IStatus.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, "Property Exception", // $NON-NLS-1$
e));
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter 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.ISVNClientAdapter in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffOperation method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
ISVNClientAdapter client = null;
ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(fromUrl.toString());
if (repository != null)
client = repository.getSVNClient();
if (client == null)
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
try {
SVNRevision pegRevision = null;
if (fromUrl.toString().equals(toUrl.toString()) && localResource != null) {
if (localResource.getResource() == null)
pegRevision = SVNRevision.HEAD;
else {
IResource resource = localResource.getResource();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
pegRevision = svnResource.getRevision();
}
}
if (pegRevision == null)
client.diff(fromUrl, fromRevision, toUrl, toRevision, file, true);
else
client.diff(fromUrl, pegRevision, fromRevision, toRevision, file, true);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
monitor.done();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
Aggregations