use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath 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.core.history.LogEntryChangePath in project subclipse by subclipse.
the class MergeWizardRevisionsPage method compareRevisions.
private void compareRevisions() {
IStructuredSelection sel = (IStructuredSelection) changePathsViewer.getSelection();
Object sel0 = sel.getFirstElement();
if (sel0 instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) sel0;
try {
if (!logEntryChangePath.getRemoteResource().isContainer()) {
ISVNRemoteResource left = logEntryChangePath.getRemoteResource();
compareInput = compareInputMap.get(left.getUrl().toString() + left.getRevision());
boolean run = compareInput == null;
if (compareInput == null) {
SVNRevision.Number selectedRevision = (SVNRevision.Number) left.getRevision();
SVNRevision.Number previousRevision = new SVNRevision.Number(selectedRevision.getNumber() - 1);
ISVNRemoteResource right = new RemoteFile(left.getRepository(), left.getUrl(), previousRevision);
compareInput = new SVNCompareEditorInput(new ResourceEditionNode(left), new ResourceEditionNode(right));
compareInputMap.put(left.getUrl().toString() + left.getRevision(), compareInput);
}
setCompareInput(compareInput, run);
showComparePane(true);
}
} catch (Exception e) {
MessageDialog.openError(getShell(), Messages.MergeWizardRevisionsPage_5, e.getMessage());
}
}
}
use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.
the class MergeWizardUnblockRevisionsPage method compareRevisions.
private void compareRevisions() {
IStructuredSelection sel = (IStructuredSelection) changePathsViewer.getSelection();
Object sel0 = sel.getFirstElement();
if (sel0 instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) sel0;
try {
if (!logEntryChangePath.getRemoteResource().isContainer()) {
ISVNRemoteResource left = logEntryChangePath.getRemoteResource();
compareInput = compareInputMap.get(left.getUrl().toString() + left.getRevision());
boolean run = compareInput == null;
if (compareInput == null) {
SVNRevision.Number selectedRevision = (SVNRevision.Number) left.getRevision();
SVNRevision.Number previousRevision = new SVNRevision.Number(selectedRevision.getNumber() - 1);
ISVNRemoteResource right = new RemoteFile(left.getRepository(), left.getUrl(), previousRevision);
compareInput = new SVNCompareEditorInput(new ResourceEditionNode(left), new ResourceEditionNode(right));
compareInputMap.put(left.getUrl().toString() + left.getRevision(), compareInput);
}
setCompareInput(compareInput, run);
showComparePane(true);
}
} catch (Exception e) {
MessageDialog.openError(getShell(), Messages.MergeWizardRevisionsPage_5, e.getMessage());
}
}
}
use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.
the class Util method getUrlForRevision.
public static SVNUrl getUrlForRevision(ISVNRemoteResource resource, SVNRevision.Number revision, IProgressMonitor pm) throws SVNException {
SVNUrl url = resource.getUrl();
SVNRevision revisionStart = new SVNRevision.Number(revision.getNumber());
GetLogsCommand getLogsCommand = new GetLogsCommand(resource, SVNRevision.HEAD, revisionStart, SVNRevision.HEAD, false, 0, null, true);
getLogsCommand.run(pm);
ILogEntry[] logEntries = getLogsCommand.getLogEntries();
String path = resource.getRepositoryRelativePath().replaceAll("%20", " ");
for (int i = logEntries.length - 1; i > -1; i--) {
ILogEntry logEntry = logEntries[i];
if (!logEntry.getRevision().equals(revision)) {
LogEntryChangePath[] changePaths = logEntry.getLogEntryChangePaths();
for (LogEntryChangePath changePath : changePaths) {
if (changePath.getPath().equals(path) && changePath.getCopySrcPath() != null) {
try {
path = changePath.getCopySrcPath();
url = new SVNUrl(resource.getRepository().getRepositoryRoot().toString() + changePath.getCopySrcPath());
} catch (MalformedURLException e) {
}
}
}
}
}
return url;
}
use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.
the class SVNHistoryPage method getCreateTagFromRevisionChangedPathAction.
private IAction getCreateTagFromRevisionChangedPathAction() {
if (createTagFromRevisionChangedPathAction == null) {
createTagFromRevisionChangedPathAction = new // $NON-NLS-1$
Action() {
public void run() {
SVNRevision selectedRevision = null;
ISelection selection = changePathsViewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection sel = (IStructuredSelection) selection;
ISVNRemoteResource remoteResource = null;
if (sel.getFirstElement() instanceof LogEntryChangePath) {
try {
remoteResource = ((LogEntryChangePath) sel.getFirstElement()).getRemoteResource();
selectedRevision = remoteResource.getRevision();
} catch (SVNException e) {
}
} else if (sel.getFirstElement() instanceof HistoryFolder) {
HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
Object[] children = historyFolder.getChildren();
if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
LogEntryChangePath changePath = (LogEntryChangePath) children[0];
try {
remoteResource = changePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath());
selectedRevision = getSelectedRevision();
} catch (SVNException e) {
}
}
}
if (remoteResource == null)
return;
ISVNRemoteResource[] remoteResources = { remoteResource };
BranchTagWizard wizard = new BranchTagWizard(remoteResources);
wizard.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
WizardDialog dialog = new ClosableWizardDialog(getSite().getShell(), 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();
try {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
e.getMessage());
}
}
// SvnWizardBranchTagPage branchTagPage = new
// SvnWizardBranchTagPage(remoteResource);
//
// branchTagPage.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
// SvnWizard wizard = new SvnWizard(branchTagPage);
// SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(),
// wizard);
// wizard.setParentDialog(dialog);
// if (!(dialog.open() == SvnWizardDialog.OK)) return;
// final SVNUrl sourceUrl = branchTagPage.getUrl();
// final SVNUrl destinationUrl = branchTagPage.getToUrl();
// final String message = branchTagPage.getComment();
// final SVNRevision revision = branchTagPage.getRevision();
// final boolean makeParents = branchTagPage.isMakeParents();
// try {
// BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
// public void run() {
// try {
// ISVNClientAdapter client =
// SVNProviderPlugin.getPlugin().getSVNClientManager().createSVNClient();
// client.copy(sourceUrl, destinationUrl, message, revision,
// makeParents);
// } catch(Exception e) {
// MessageDialog.openError(getSite().getShell(),
// Policy.bind("HistoryView.createTagFromRevision"), e
// .getMessage());
// }
// }
// });
// } catch(Exception e) {
// MessageDialog.openError(getSite().getShell(),
// Policy.bind("HistoryView.createTagFromRevision"), e
// .getMessage());
// }
}
};
}
ISelection selection = changePathsViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
SVNRevision selectedRevision = null;
if (sel.size() == 1) {
// ISVNRemoteResource remoteResource = null;
if (sel.getFirstElement() instanceof LogEntryChangePath && ((LogEntryChangePath) sel.getFirstElement()).getAction() != 'D') {
// try {
// remoteResource = ((LogEntryChangePath)sel.getFirstElement()).getRemoteResource();
selectedRevision = ((LogEntryChangePath) sel.getFirstElement()).getRevision();
// selectedRevision = remoteResource.getRevision();
// } catch (SVNException e) {}
} else if (sel.getFirstElement() instanceof HistoryFolder) {
HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
Object[] children = historyFolder.getChildren();
if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
selectedRevision = getSelectedRevision();
}
}
createTagFromRevisionChangedPathAction.setEnabled(selectedRevision != null);
if (selectedRevision == null) {
createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + ((LogEntryChangePath) sel.getFirstElement()).getRevision()));
} else {
createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + selectedRevision));
}
}
}
createTagFromRevisionChangedPathAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_BRANCHTAG));
return createTagFromRevisionChangedPathAction;
}
Aggregations