use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class ResourceEditionNode method matchLocalResource.
private SVNLocalResourceNode matchLocalResource(ISVNRemoteResource remoteNode) {
if (localResource == null)
return null;
ISVNRemoteResource baseFolder = remoteNode;
if (baseFolder.getParent() != null) {
baseFolder = baseFolder.getParent();
}
Object[] lrn = localResource.getChildren();
String remotePath = remoteNode.getRepositoryRelativePath();
remotePath = remotePath.replaceAll(baseFolder.getRepositoryRelativePath(), "");
for (int i = 0; i < lrn.length; i++) {
String localPath = ((SVNLocalResourceNode) lrn[i]).getResource().getFullPath().toString();
localPath = localPath.substring(localResource.getResource().getFullPath().toString().length());
if (localPath.equals(remotePath)) {
return (SVNLocalResourceNode) lrn[i];
}
}
return null;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class ResourceEditionNode method getChildren.
/**
* Enumerate children of this node (if any).
*
* @see IStructureComparator#getChildren
*/
public Object[] getChildren() {
if (children == null) {
children = new ResourceEditionNode[0];
ISVNLocalResource mylocalResource = null;
if (localResource instanceof SVNLocalResourceNode) {
mylocalResource = ((SVNLocalResourceNode) localResource).getLocalResource();
try {
if (!mylocalResource.isDirty() && mylocalResource.getResource().getProjectRelativePath().toString().equals(getRemoteResource().getProjectRelativePath()) && mylocalResource.getStatus().getLastChangedRevision().equals(getRemoteResource().getLastChangedRevision())) {
return children;
}
} catch (CoreException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
if (resource != null) {
try {
SVNUIPlugin.runWithProgress(null, true, /* cancelable */
new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
ISVNRemoteResource[] members = resource.members(monitor);
List<ResourceEditionNode> nonHiddenChildren = new ArrayList<ResourceEditionNode>();
for (int i = 0; i < members.length; i++) {
if (!ignoreHiddenChanges || members[i].getResource() == null || !Util.isHidden(members[i].getResource(), false)) {
ResourceEditionNode child = new ResourceEditionNode(members[i], pegRevision);
SVNLocalResourceNode localNode = matchLocalResource((ISVNRemoteResource) members[i]);
if (localNode != null) {
child.setLocalResource(localNode);
localNode.setRemoteResource(child);
try {
child.setCharset(localNode.getCharset());
} catch (CoreException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
nonHiddenChildren.add(child);
}
}
children = new ResourceEditionNode[nonHiddenChildren.size()];
nonHiddenChildren.toArray(children);
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InterruptedException e) {
// operation canceled
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t instanceof TeamException) {
SVNUIPlugin.log(((TeamException) t).getStatus());
}
}
}
}
return children;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class RevisionAwareDifferencer method compareStatusAndRevisions.
/**
* Compares two nodes to determine if they are equal. Returns NODE_EQUAL of they are the same,
* NODE_NOT_EQUAL if they are different, and NODE_UNKNOWN if comparison was not possible.
*/
protected int compareStatusAndRevisions(Object left, Object right) {
ISVNLocalResource localResource = null;
if (left instanceof SVNLocalResourceNode) {
localResource = ((SVNLocalResourceNode) left).getLocalResource();
}
ISVNRemoteResource edition = null;
if (right instanceof ResourceEditionNode)
edition = ((ResourceEditionNode) right).getRemoteResource();
if (localResource == null || edition == null) {
return NODE_UNKNOWN;
}
// if they're both non-files, they're the same
if (localResource.isFolder() && edition.isContainer()) {
return NODE_EQUAL;
}
// if they have different types, they're different
if (localResource.isFolder() != edition.isContainer()) {
return NODE_NOT_EQUAL;
}
String leftLocation = localResource.getRepository().getLocation();
String rightLocation = edition.getRepository().getLocation();
if (!leftLocation.equals(rightLocation)) {
return NODE_UNKNOWN;
}
LocalResourceStatus localStatus = null;
try {
localStatus = localResource.getStatus();
if (localStatus == null) {
return NODE_UNKNOWN;
}
if (!localResource.isDirty() && localResource.getResource().getProjectRelativePath().toString().equals(edition.getProjectRelativePath()) && localStatus.getLastChangedRevision().equals(edition.getLastChangedRevision())) {
return NODE_EQUAL;
}
if (!localResource.isDirty() && !localResource.isFolder()) {
if (changedResources == null && diffFiles != null) {
parseDiffs();
}
if (changedResources == null) {
for (int i = 0; i < diffSummary.length; i++) {
if (localResource.getResource().getProjectRelativePath().toString().equals(projectRelativePath) || localResource.getResource().getProjectRelativePath().toString().equals(projectRelativePath + diffSummary[i].getPath())) {
return NODE_NOT_EQUAL;
}
}
return NODE_EQUAL;
}
if (changedResources.contains(localResource.getResource().getLocation().toString())) {
return NODE_NOT_EQUAL;
}
return NODE_EQUAL;
}
} catch (SVNException e) {
return NODE_UNKNOWN;
}
return NODE_UNKNOWN;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class SVNCompareRevisionsInput method initializeActions.
/**
* initialize the actions : - getContentsAction : get the contents for the selected revision -
* getRevisionAction : updates to the given revision
*/
private void initializeActions() {
getContentsAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.getContentsAction"), // $NON-NLS-1$
null) {
public void run() {
try {
new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
ResourceEditionNode right = (ResourceEditionNode) node.getRight();
ISVNRemoteResource edition = right.getRemoteResource();
// actually want to change the base.
try {
monitor.beginTask(null, 100);
InputStream in = ((IResourceVariant) edition).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
resource.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
} catch (TeamException e) {
throw new InvocationTargetException(e);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
});
} catch (InterruptedException e) {
// Do nothing
return;
} catch (InvocationTargetException e) {
handle(e);
}
// recompute the labels on the viewer
updateCurrentEdition();
viewer.refresh();
}
};
getRevisionAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.getRevisionAction"), // $NON-NLS-1$
null) {
public void run() {
try {
new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation(null) {
protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
ResourceEditionNode right = (ResourceEditionNode) node.getRight();
final ISVNRemoteFile edition = (ISVNRemoteFile) right.getRemoteResource();
new UpdateOperation(null, resource, edition.getLastChangedRevision()).run(monitor);
// recompute the labels on the viewer
getHistoryTableProvider().setRemoteResource(edition);
viewer.refresh();
}
});
} catch (InterruptedException e) {
// Do nothing
return;
} catch (InvocationTargetException e) {
handle(e);
}
}
};
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class SvnWizardSwitchPage method showLog.
protected void showLog() {
ISVNRemoteResource remoteResource = null;
try {
remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]).getRepository().getRemoteFile(new SVNUrl(urlCombo.getText()));
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
urlCombo.getText());
return;
}
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
setPageComplete(canFinish());
}
Aggregations