use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffDialog method okPressed.
protected void okPressed() {
success = true;
final File file = new File(fileText.getText().trim());
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() {
try {
SVNUrl fromUrl = null;
SVNUrl toUrl = null;
SVNRevision fromRevision;
SVNRevision toRevision;
if (fromHeadButton.getSelection())
fromRevision = SVNRevision.HEAD;
else {
int fromRevisionInt = Integer.parseInt(fromRevisionText.getText().trim());
long fromRevisionLong = fromRevisionInt;
fromRevision = new SVNRevision.Number(fromRevisionLong);
}
if (toHeadButton.getSelection())
toRevision = SVNRevision.HEAD;
else {
int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
long toRevisionLong = toRevisionInt;
toRevision = new SVNRevision.Number(toRevisionLong);
}
if (fromResource == remoteResources[0]) {
fromUrl = remoteResources[0].getUrl();
toUrl = remoteResources[1].getUrl();
} else {
fromUrl = remoteResources[1].getUrl();
toUrl = remoteResources[0].getUrl();
}
new ShowDifferencesAsUnifiedDiffOperation(targetPart, fromUrl, fromRevision, toUrl, toRevision, file).run();
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
success = false;
}
}
});
if (!success)
return;
super.okPressed();
}
use of org.tigris.subversion.svnclientadapter.SVNRevision 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.SVNRevision 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.SVNRevision 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);
}
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class UpdateSynchronizeOperation method getRevisionForUpdate.
/**
* This method returns the highest revision number in the set of items being updated or
* SVNRevision.HEAD if there are deleted items
*
* @param resources - the resources being updated
* @param set - the list of all selected items in synch view
* @return
*/
private SVNRevision getRevisionForUpdate(IResource[] resources, SyncInfoSet set) {
SVNRevision revision = null;
final SyncInfo[] syncInfos = set.getSyncInfos();
boolean useHEAD = false;
syncInfoLoop: for (int i = 0; i < syncInfos.length; i++) {
SVNStatusSyncInfo syncInfo = (SVNStatusSyncInfo) syncInfos[i];
resourceLoop: for (int j = 0; j < resources.length; j++) {
if (resources[j].equals(syncInfo.getLocal())) {
IResourceVariant remote = syncInfo.getRemote();
if (remote != null && remote instanceof ISVNRemoteResource) {
if (syncInfo.getRemoteResourceStatus() != null) {
if (syncInfo.getRemoteResourceStatus().getTextStatus() == SVNStatusKind.DELETED) {
// update contains deleted items
useHEAD = true;
break syncInfoLoop;
}
}
SVNRevision rev = ((ISVNRemoteResource) remote).getLastChangedRevision();
if (rev instanceof SVNRevision.Number) {
long nbr = ((SVNRevision.Number) rev).getNumber();
if (revision == null)
revision = rev;
else {
long revisionNumber = ((SVNRevision.Number) revision).getNumber();
if (nbr > revisionNumber)
revision = rev;
}
}
}
break resourceLoop;
}
}
}
if (revision == null || useHEAD)
revision = SVNRevision.HEAD;
return revision;
}
Aggregations