use of org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction in project subclipse by subclipse.
the class SVNHistoryPage method getCompareWithPreviousChangedPathAction.
private IAction getCompareWithPreviousChangedPathAction() {
if (compareWithPreviousChangedPathAction == null) {
compareWithPreviousChangedPathAction = new Action() {
public void run() {
CompareRemoteResourcesAction delegate = new CompareRemoteResourcesAction();
delegate.init(this);
ISVNRemoteResource remoteResource1 = null;
Object firstSelection = ((IStructuredSelection) changePathsViewer.getSelection()).getFirstElement();
if (firstSelection instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) firstSelection;
try {
remoteResource1 = logEntryChangePath.getRemoteResource();
} catch (SVNException e1) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e1, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
return;
}
} else if (firstSelection instanceof HistoryFolder) {
HistoryFolder historyFolder = (HistoryFolder) firstSelection;
Object[] children = historyFolder.getChildren();
if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) children[0];
try {
SVNUrl svnUrl = logEntryChangePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath()).getUrl();
SVNRevision.Number selectedRevision = (SVNRevision.Number) getSelectedRevision();
remoteResource1 = new RemoteFolder(null, logEntryChangePath.getLogEntry().getRemoteResource().getRepository(), svnUrl, selectedRevision, selectedRevision, null, null);
} catch (Exception e) {
}
}
}
if (remoteResource1 == null) {
return;
}
int from = Integer.parseInt(remoteResource1.getRevision().toString());
from--;
String to = Integer.toString(from);
SVNRevision toRevision = null;
try {
toRevision = SVNRevision.getRevision(to);
} catch (ParseException e) {
}
ISVNRemoteResource[] remoteResources = new ISVNRemoteResource[2];
ISVNRemoteResource remoteResource2;
if (firstSelection instanceof HistoryFolder || remoteResource1.getResource() instanceof IContainer) {
remoteResource2 = new RemoteFolder(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
} else {
remoteResource2 = new RemoteFile(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
}
remoteResources[0] = remoteResource1;
remoteResources[1] = remoteResource2;
delegate.selectionChanged(this, new StructuredSelection(remoteResources));
delegate.setRemoteResources(remoteResources);
delegate.setLocalResource(remoteResource1.getResource());
delegate.setLocalResources(remoteResources);
SVNRevision[] pegRevisions = { remoteResource1.getRevision() };
delegate.setPegRevisions(pegRevisions);
delegate.run(this);
}
};
}
return compareWithPreviousChangedPathAction;
}
use of org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction in project subclipse by subclipse.
the class DifferencesDialog method compare.
private void compare() {
if (fromResource instanceof ISVNRemoteResource && toResource != null && toResource instanceof ISVNRemoteResource) {
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);
}
try {
fromUrl = new SVNUrl(fromUrlText.getText().trim());
toUrl = new SVNUrl(toUrlText.getText().trim());
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("DifferencesDialog.compare"), e.getMessage());
success = false;
return;
}
ISVNRemoteResource resource1 = null;
SVNRevision.Number lastChangedRevision1 = null;
ISVNRemoteResource resource2 = null;
SVNRevision.Number lastChangedRevision2 = null;
if (fromRevision instanceof SVNRevision.Number) {
lastChangedRevision1 = (SVNRevision.Number) fromRevision;
} else {
lastChangedRevision1 = ((ISVNRemoteResource) remoteResources[0]).getLastChangedRevision();
}
if (fromResource.isFolder()) {
resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
if (!fromUrl.equals(fromResource.getUrl())) {
try {
resource1.members(null);
} catch (TeamException e) {
resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
}
}
} else {
resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
if (!fromUrl.equals(fromResource.getUrl())) {
IStorage storage = null;
try {
storage = resource1.getStorage(null);
} catch (TeamException e) {
}
if (storage == null) {
resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
}
}
}
if (fromRevision instanceof SVNRevision.Number) {
if (usePegRevision && resource1 instanceof RemoteResource) {
((RemoteResource) resource1).setPegRevision(fromRevision);
}
}
if (toRevision instanceof SVNRevision.Number) {
lastChangedRevision2 = (SVNRevision.Number) toRevision;
} else {
lastChangedRevision2 = ((ISVNRemoteResource) remoteResources[1]).getLastChangedRevision();
}
if (toResource.isFolder()) {
resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
if (!toUrl.equals(toResource.getUrl())) {
try {
resource2.members(null);
} catch (TeamException e) {
resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
}
}
} else {
resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
if (!toUrl.equals(toResource.getUrl())) {
IStorage storage = null;
try {
storage = resource2.getStorage(null);
} catch (TeamException e) {
}
if (storage == null) {
resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
}
}
}
if (toRevision instanceof SVNRevision.Number) {
if (usePegRevision && resource2 instanceof RemoteResource) {
((RemoteResource) resource2).setPegRevision(toRevision);
}
}
ISVNRemoteResource[] remotes = { resource1, resource2 };
CompareRemoteResourcesAction compareAction = new CompareRemoteResourcesAction();
compareAction.setLocalResource(localResource);
compareAction.setRemoteResources(remotes);
compareAction.setPegRevisions(pegRevisions);
compareAction.setLocalResources(remoteResources);
try {
compareAction.execute(null);
} catch (InvocationTargetException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
} catch (InterruptedException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
Aggregations