use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class GraphBackgroundTask method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
boolean error = false;
Cache cache = null;
monitor.beginTask("Calculating graph information", TOTAL_STEPS);
monitor.worked(SHORT_TASK_STEPS);
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClient();
ISVNInfo info;
if (resource == null)
info = client.getInfo(remoteResource.getUrl());
else {
if (resource.getRawLocation() == null)
info = client.getInfoFromWorkingCopy(resource.getLocation().toFile());
else
info = client.getInfoFromWorkingCopy(resource.getRawLocation().toFile());
if (info.getUuid() == null) {
info = client.getInfo(info.getUrl());
}
}
if (editor != null)
((RevisionGraphEditorInput) editor.getEditorInput()).setInfo(info);
long revision = info.getRevision().getNumber();
String path = info.getUrl().toString().substring(info.getRepository().toString().length());
monitor.setTaskName("Initializating cache");
cache = getCache(info.getUuid());
monitor.worked(SHORT_TASK_STEPS);
// update the cache
long latestRevisionStored = cache.getLatestRevision();
SVNRevision latest = null;
SVNRevision endRevision = null;
monitor.setTaskName("Connecting to the repository");
// TODO: try-catch this line and make it work off-line
long latestRevisionInRepository = client.getInfo(info.getRepository()).getLastChangedRevision().getNumber();
monitor.worked(SHORT_TASK_STEPS);
if (refreshRevision != null || refreshRevisions != null || latestRevisionInRepository > latestRevisionStored) {
if (refreshRevision == null) {
if (latestRevisionStored >= latestRevisionInRepository)
latest = new SVNRevision.Number(latestRevisionInRepository);
else
latest = new SVNRevision.Number(latestRevisionStored + 1);
} else {
latest = refreshRevision;
}
if (refreshRevision == null)
endRevision = SVNRevision.HEAD;
else
endRevision = refreshRevision;
try {
monitor.setTaskName("Retrieving revision history");
int unitWork;
if (refreshRevision == null && refreshRevisions == null)
unitWork = VERY_LONG_TASK / (int) (latestRevisionInRepository - latestRevisionStored);
else if (refreshRevisions != null)
unitWork = VERY_LONG_TASK / refreshRevisions.length;
else
unitWork = VERY_LONG_TASK;
if (refreshRevisions != null) {
if (monitor.isCanceled())
return;
monitor.setTaskName("Refreshing cache");
List refreshedNodes = new ArrayList();
for (int i = 0; i < refreshNodes.length; i++) {
if (refreshNodes[i].getAction() != 'D')
refreshedNodes.add(refreshNodes[i]);
}
cache.refresh(refreshedNodes, info, monitor, unitWork);
} else if (refreshRevision != null) {
if (monitor.isCanceled())
return;
monitor.setTaskName("Refreshing cache");
revision = refreshNode.getRevision();
path = refreshNode.getPath();
List refreshedNodes = new ArrayList();
refreshedNodes.add(refreshNode);
cache.refresh(refreshedNodes, info, monitor, unitWork);
}
if (getNewRevisions) {
CallbackUpdater callbackUpdater = new CallbackUpdater(cache, monitor, unitWork, client);
cache.startUpdate();
client.getLogMessages(info.getRepository(), latest, latest, endRevision, false, true, 0, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callbackUpdater);
cache.finishUpdate();
}
} catch (Exception e) {
Activator.handleError(e);
error = true;
Activator.showErrorDialog("Calculate Revision Graph Information", e, false);
}
} else {
monitor.worked(VERY_LONG_TASK);
}
if (editor != null) {
if (error == true || monitor.isCanceled()) {
if (refreshRevision == null && refreshRevisions == null) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = editor.getEditorSite().getWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
page.activate(editor);
page.closeEditor(editor, false);
}
});
}
} else {
updateView(monitor, cache, path, revision);
}
}
monitor.done();
} catch (Exception e) {
Activator.handleError(e);
Activator.showErrorDialog("Calculate Revision Graph Information", e, false);
return;
} finally {
if (cache != null)
cache.close();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class BranchTagAction method run.
public void run() {
BranchTagWizard wizard;
final IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
if (resource == null) {
ISVNRemoteResource[] resources = { remoteResource };
wizard = new BranchTagWizard(resources);
} else {
IResource[] resources = { resource };
wizard = new BranchTagWizard(resources);
}
wizard.setRevisionNumber(node.getRevision());
WizardDialog dialog = new ClosableWizardDialog(Display.getDefault().getActiveShell(), wizard);
if (dialog.open() == WizardDialog.OK) {
final SVNUrl sourceUrl = wizard.getUrl();
final SVNUrl destinationUrl = wizard.getToUrl();
final String message = wizard.getComment();
final SVNRevision revision = wizard.getRevision();
final boolean makeParents = wizard.isMakeParents();
final SVNUrl[] sourceUrls = wizard.getUrls();
final boolean createOnServer = wizard.isCreateOnServer();
final Alias newAlias = wizard.getNewAlias();
final boolean switchAfter = wizard.isSwitchAfterBranchTag();
try {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
if (resource == null) {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
} else {
IResource[] resources = { resource };
BranchTagOperation branchTagOperation = new BranchTagOperation(editor.getEditorSite().getPart(), resources, sourceUrls, destinationUrl, createOnServer, revision, message);
branchTagOperation.setMakeParents(makeParents);
branchTagOperation.setNewAlias(newAlias);
branchTagOperation.switchAfterTagBranchOperation(switchAfter);
branchTagOperation.run();
}
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
}
}
}
use of org.tigris.subversion.svnclientadapter.SVNRevision 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.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class SVNHistoryPage method getSwitchAction.
// get switch action (context menu)
private IAction getSwitchAction() {
if (switchAction == null) {
switchAction = new Action() {
public void run() {
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
IResource[] resources = { resource };
SvnWizardSwitchPage switchPage = new SvnWizardSwitchPage(resources, currentSelection.getRevision().getNumber());
SvnWizard wizard = new SvnWizard(switchPage);
SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.OK) {
SVNUrl[] svnUrls = switchPage.getUrls();
SVNRevision svnRevision = switchPage.getRevision();
SwitchOperation switchOperation = new SwitchOperation(getSite().getPage().getActivePart(), resources, svnUrls, svnRevision);
switchOperation.setDepth(switchPage.getDepth());
switchOperation.setSetDepth(switchPage.isSetDepth());
switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
switchOperation.setForce(switchPage.isForce());
switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
switchOperation.setConflictResolver(switchPage.getConflictResolver());
try {
switchOperation.run();
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), switchAction.getText(), e.getMessage());
}
}
}
}
}
};
}
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
switchAction.setText(Policy.bind("HistoryView.switchToRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + currentSelection.getRevision().getNumber()));
}
}
switchAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_SWITCH));
return switchAction;
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class SVNHistoryPage method getRevertChangesAction.
// get revert changes action (context menu)
private IAction getRevertChangesAction() {
revisionRanges = getRevisionRanges();
if (revertChangesAction == null) {
revertChangesAction = new Action() {
public void run() {
ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
final IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
if (!MessageDialog.openConfirm(getSite().getShell(), Policy.bind("HistoryView.revertRevision"), Policy.bind("HistoryView.confirmRevertRevision", // $NON-NLS-1$
resource.getFullPath().toString())))
return;
} else {
if (!MessageDialog.openConfirm(getSite().getShell(), Policy.bind("HistoryView.revertRevisions"), Policy.bind("HistoryView.confirmRevertRevisions", // $NON-NLS-1$
resource.getFullPath().toString())))
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ILogEntry firstElement = getFirstElement();
ILogEntry lastElement = getLastElement();
final IResource[] resources = { resource };
try {
final SVNUrl path1 = new SVNUrl(firstElement.getResource().getUrl() + "@HEAD");
final SVNUrl path2 = new SVNUrl(lastElement.getResource().getUrl() + "@HEAD");
for (int i = 0; i < revisionRanges.length; i++) {
final SVNRevision revision1 = revisionRanges[i].getFromRevision();
final SVNRevision revision2 = new SVNRevision.Number(((SVNRevision.Number) revisionRanges[i].getToRevision()).getNumber() - 1);
WorkspaceAction mergeAction = new WorkspaceAction() {
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
new MergeOperation(getSite().getPage().getActivePart(), resources, path1, revision1, path2, revision2).run();
}
};
mergeAction.run(null);
}
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), revertChangesAction.getText(), e.getMessage());
}
}
});
}
};
}
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
revertChangesAction.setText(Policy.bind("HistoryView.revertChangesFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + currentSelection.getRevision().getNumber()));
}
if (ss.size() > 1) {
revertChangesAction.setText(// $NON-NLS-1$
Policy.bind("HistoryView.revertChangesFromRevisions"));
}
}
revertChangesAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_MARKMERGED));
revertChangesAction.setEnabled(revertEnabled);
return revertChangesAction;
}
Aggregations