use of org.tigris.subversion.svnclientadapter.SVNRevision 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);
}
}
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class DifferencesDialog method diff.
private void diff() {
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);
}
fromUrl = new SVNUrl(fromUrlText.getText().trim());
toUrl = new SVNUrl(toUrlText.getText().trim());
ShowDifferencesAsUnifiedDiffOperation operation = new ShowDifferencesAsUnifiedDiffOperation(targetPart, fromUrl, fromRevision, toUrl, toRevision, file);
operation.setLocalResource(remoteResources[0]);
operation.run();
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
success = false;
}
}
});
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class HistoryDialog method getNextLogEntries.
private void getNextLogEntries() {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
try {
if (remoteResource == null) {
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
if (localResource != null && !localResource.getStatus().isAdded() && localResource.getStatus().isManaged()) {
remoteResource = localResource.getBaseResource();
}
}
if (remoteResource != null) {
SVNRevision pegRevision = remoteResource.getRevision();
SVNRevision revisionEnd = new SVNRevision.Number(0);
boolean stopOnCopy = store.getBoolean(ISVNUIConstants.PREF_STOP_ON_COPY);
int entriesToFetch = store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH);
long limit = entriesToFetch;
ILogEntry[] nextEntries = getLogEntries(remoteResource, pegRevision, revisionStart, revisionEnd, stopOnCopy, limit + 1, tagManager);
long entriesLength = nextEntries.length;
if (entriesLength > limit) {
ILogEntry[] fetchedEntries = new ILogEntry[nextEntries.length - 1];
for (int i = 0; i < nextEntries.length - 1; i++) fetchedEntries[i] = nextEntries[i];
getNextButton.setEnabled(true);
} else
getNextButton.setEnabled(false);
ArrayList entryArray = new ArrayList();
if (entries == null)
entries = new ILogEntry[0];
for (int i = 0; i < entries.length; i++) entryArray.add(entries[i]);
for (int i = 0; i < nextEntries.length; i++) entryArray.add(nextEntries[i]);
entries = new ILogEntry[entryArray.size()];
entryArray.toArray(entries);
if (entries.length > 0) {
ILogEntry lastEntry = entries[entries.length - 1];
long lastEntryNumber = lastEntry.getRevision().getNumber();
revisionStart = new SVNRevision.Number(lastEntryNumber - 1);
}
}
} catch (TeamException e) {
SVNUIPlugin.openError(Display.getCurrent().getActiveShell(), null, null, e);
}
}
});
ISelection selection = tableHistoryViewer.getSelection();
tableHistoryViewer.refresh();
tableHistoryViewer.setSelection(selection);
}
Aggregations