use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class EditConflictsAction method execute.
/*
* (non-Javadoc)
*
* @see org.tigris.subversion.subclipse.ui.actions.SVNAction#execute(org.eclipse.jface.action.IAction)
*/
protected void execute(final IAction action) throws InvocationTargetException, InterruptedException {
IFile resource;
if (selectedResource == null)
resource = (IFile) getSelectedResources()[0];
else
resource = selectedResource;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
IFile conflictNewFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictNew());
IFile conflictOldFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictOld());
IFile conflictWorkingFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictWorking());
if (conflictWorkingFile == null) {
conflictWorkingFile = resource;
}
MergeFileAssociation mergeFileAssociation = null;
try {
mergeFileAssociation = SVNUIPlugin.getPlugin().getMergeFileAssociation(resource.getName());
} catch (BackingStoreException e) {
mergeFileAssociation = new MergeFileAssociation();
}
if (mergeFileAssociation.getType() == MergeFileAssociation.BUILT_IN) {
editConflictsInternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile);
} else if (mergeFileAssociation.getType() == MergeFileAssociation.DEFAULT_EXTERNAL) {
IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
String mergeProgramLocation = preferenceStore.getString(ISVNUIConstants.PREF_MERGE_PROGRAM_LOCATION);
String mergeProgramParameters = preferenceStore.getString(ISVNUIConstants.PREF_MERGE_PROGRAM_PARAMETERS);
editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile, mergeProgramLocation, mergeProgramParameters);
} else {
editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile, mergeFileAssociation.getMergeProgram(), mergeFileAssociation.getParameters());
}
} catch (Exception e) {
exception = e;
}
if (exception != null) {
throw new InvocationTargetException(exception);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class GenerateDiffFileAction method getUnaddedResources.
private IResource[] getUnaddedResources(List resources, IProgressMonitor iProgressMonitor) throws SVNException {
final List unadded = new ArrayList();
final SVNException[] exception = new SVNException[] { null };
for (Iterator iter = resources.iterator(); iter.hasNext(); ) {
IResource resource = (IResource) iter.next();
if (resource.exists()) {
// visit each resource deeply
try {
resource.accept(new IResourceVisitor() {
public boolean visit(IResource aResource) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(aResource);
// skip ignored resources and their children
try {
if (svnResource.isIgnored())
return false;
// visit the children of shared resources
if (svnResource.isManaged())
return true;
if ((aResource.getType() == IResource.FOLDER) && // don't traverse into symlink folders
isSymLink(aResource))
return false;
} catch (SVNException e) {
exception[0] = e;
}
// file/folder is unshared so record it
unadded.add(aResource);
return aResource.getType() == IResource.FOLDER;
}
}, IResource.DEPTH_INFINITE, false);
} catch (CoreException e) {
throw SVNException.wrapException(e);
}
if (exception[0] != null)
throw exception[0];
}
}
return (IResource[]) unadded.toArray(new IResource[unadded.size()]);
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ResolveActionWithChoices method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
boolean folderSelected = false;
boolean propertyConflicts = false;
boolean textConflicts = false;
boolean treeConflicts = false;
boolean treeConflictDialogShown = false;
IResource[] resources = getSelectedResources();
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IContainer) {
folderSelected = true;
}
if (!propertyConflicts || !textConflicts || !treeConflicts) {
ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
try {
LocalResourceStatus status = resource.getStatus();
if (status != null && status.isPropConflicted())
propertyConflicts = true;
if (status != null && status.isTextConflicted())
textConflicts = true;
if (status != null && status.hasTreeConflict())
treeConflicts = true;
} catch (SVNException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
if (resources.length == 1 && treeConflicts && !propertyConflicts && !textConflicts) {
treeConflict = getTreeConflict(resources[0]);
if (treeConflict != null) {
ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, getTargetPart());
WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
"ResolveTreeConflict");
if (dialog.open() != WizardDialog.OK)
return;
treeConflictDialogShown = true;
}
}
if (resources.length > 1 && treeConflicts) {
if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), Policy.bind("ResolveAction.confirmTreeConflicts")))
// $NON-NLS-1$ //$NON-NLS-2$
return;
setResolution(ISVNConflictResolver.Choice.chooseMerged);
} else if (!treeConflictDialogShown) {
SvnWizardMarkResolvedPage markResolvedPage = new SvnWizardMarkResolvedPage(resources);
markResolvedPage.setPropertyConflicts(propertyConflicts);
markResolvedPage.setTreeConflicts(treeConflicts);
SvnWizard wizard = new SvnWizard(markResolvedPage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.CANCEL)
return;
setResolution(markResolvedPage.getResolution());
}
if (!treeConflictDialogShown)
super.execute(action);
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class SVNMoveDeleteHook method moveFile.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.team.IMoveDeleteHook#moveFile(org.eclipse.core.resources.team.IResourceTree,
* org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile,
* int, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor) {
if (SVNWorkspaceRoot.isLinkedResource(source))
return false;
try {
RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
if (repositoryProvider == null || // target is not SVN project
!(repositoryProvider instanceof SVNTeamProvider))
return false;
ISVNLocalFile resource = new LocalFile(source);
// pass
if (!resource.isManaged())
return false;
ISVNRepositoryLocation sourceRepository = resource.getRepository();
ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
ISVNRepositoryLocation targetRepository = parent.getRepository();
if (!sourceRepository.equals(targetRepository)) {
return false;
}
monitor.beginTask(null, 1000);
try {
OperationManager.getInstance().beginOperation(svnClient);
// see bug #15
if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
if (parent != null)
parent.refreshStatus();
}
// force is set to true because when we rename (refactor) a
// java class, the file is modified before being moved
// A modified file cannot be moved without force
svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
// movedFile must be done before endOperation because
// destination file must not already exist in the workspace
// resource tree.
tree.movedFile(source, destination);
destination.refreshLocal(IResource.DEPTH_ZERO, monitor);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} catch (TeamException e) {
throw SVNException.wrapException(e);
} catch (CoreException e) {
throw SVNException.wrapException(e);
} finally {
resource.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation(false, null, false);
}
} catch (SVNException e) {
tree.failed(e.getStatus());
} finally {
monitor.done();
}
return true;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class SVNMoveDeleteHook method moveFolder.
public boolean moveFolder(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor) {
if (SVNWorkspaceRoot.isLinkedResource(source))
return false;
try {
ISVNLocalFolder resource = new LocalFolder(source);
if (!resource.isManaged())
return false;
RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
if (repositoryProvider == null || // target is not SVN project
!(repositoryProvider instanceof SVNTeamProvider))
return false;
ISVNRepositoryLocation sourceRepository = resource.getRepository();
ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
ISVNRepositoryLocation targetRepository = parent.getRepository();
if (!sourceRepository.equals(targetRepository)) {
return false;
}
monitor.beginTask(null, 1000);
ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
try {
OperationManager.getInstance().beginOperation(svnClient);
// see bug #15
if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
if (parent != null)
parent.refreshStatus();
}
svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
tree.movedFolderSubtree(source, destination);
destination.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} catch (CoreException e) {
throw SVNException.wrapException(e);
} finally {
resource.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation(false);
}
} catch (SVNException e) {
tree.failed(e.getStatus());
} finally {
monitor.done();
}
return true;
}
Aggregations