use of org.tigris.subversion.subclipse.core.SVNTeamProvider 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;
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class GenerateDiffFileOperation method run.
/**
* @see IRunnableWithProgress#run(IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws InvocationTargetException {
ISVNClientAdapter svnClient = null;
ISVNRepositoryLocation repository = null;
try {
// $NON-NLS-1$
monitor.beginTask("", 500);
// $NON-NLS-1$
monitor.setTaskName(Policy.bind("GenerateSVNDiff.working"));
OutputStream os;
if (toClipboard) {
os = new ByteArrayOutputStream();
} else {
os = new FileOutputStream(outputFile);
}
// $NON-NLS-1$ //$NON-NLS-2$
File tmpFile = File.createTempFile("sub", "");
tmpFile.deleteOnExit();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
newFiles = new ArrayList();
if (unaddedResources.length > 0) {
// });
for (int i = 0; i < unaddedResources.length; i++) newFiles.add(unaddedResources[i]);
if (newFiles.size() > 0) {
try {
// associate the resources with their respective RepositoryProvider
Hashtable table = getProviderMapping((IResource[]) newFiles.toArray(new IResource[newFiles.size()]));
Set keySet = table.keySet();
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {
IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 100);
SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
List list = (List) table.get(provider);
IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
provider.add(providerResources, IResource.DEPTH_INFINITE, subMonitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
}
}
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
try {
monitor.worked(100);
File[] files = getVersionedFiles();
if (selectedResources == null)
svnClient.diff(files, tmpFile, recursive);
else {
if (eclipseFormat) {
HashSet includedResources = new HashSet();
includedResources.addAll(Arrays.asList(unaddedResources));
includedResources.addAll(Arrays.asList(resources));
createEclipsePatch((IResource[]) includedResources.toArray(new IResource[0]), tmpFile, recursive);
} else {
File relativeToPath = null;
if (projectRelative) {
relativeToPath = selectedResources[0].getProject().getLocation().toFile();
} else {
relativeToPath = getRelativeToPath();
if (relativeToPath.isFile()) {
relativeToPath = relativeToPath.getParentFile();
}
}
svnClient.createPatch(files, relativeToPath, tmpFile, recursive);
}
}
monitor.worked(300);
InputStream is = new FileInputStream(tmpFile);
byte[] buffer = new byte[30000];
int length;
while ((length = is.read(buffer)) != -1) {
os.write(buffer, 0, length);
}
is.close();
} finally {
os.close();
}
if (newFiles.size() > 0) {
for (int i = 0; i < newFiles.size(); i++) {
IResource resource = (IResource) newFiles.get(i);
try {
SVNWorkspaceRoot.getSVNResourceFor(resource).revert();
} catch (Exception e) {
}
}
}
boolean emptyDiff = false;
if (toClipboard) {
final ByteArrayOutputStream baos = (ByteArrayOutputStream) os;
if (baos.size() == 0) {
emptyDiff = true;
} else {
Display.getDefault().syncExec(new Runnable() {
public void run() {
TextTransfer plainTextTransfer = TextTransfer.getInstance();
Clipboard clipboard = new Clipboard(shell.getDisplay());
clipboard.setContents(new String[] { baos.toString() }, new Transfer[] { plainTextTransfer });
clipboard.dispose();
}
});
}
} else {
if (outputFile.length() == 0) {
emptyDiff = true;
outputFile.delete();
}
}
// check for empty diff and report
if (emptyDiff) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(shell, // $NON-NLS-1$
Policy.bind("GenerateSVNDiff.noDiffsFoundTitle"), // $NON-NLS-1$
Policy.bind("GenerateSVNDiff.noDiffsFoundMsg"));
}
});
}
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
monitor.done();
}
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class RelocateWizard method setSharedProjects.
private void setSharedProjects() {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
ArrayList shared = new ArrayList();
for (int i = 0; i < projects.length; i++) {
RepositoryProvider teamProvider = RepositoryProvider.getProvider(projects[i], SVNProviderPlugin.getTypeId());
if (teamProvider != null) {
try {
SVNTeamProvider svnProvider = (SVNTeamProvider) teamProvider;
if (svnProvider.getSVNWorkspaceRoot().getRepository().equals(repository))
shared.add(projects[i]);
} catch (Exception e) {
}
}
}
sharedProjects = new IProject[shared.size()];
shared.toArray(sharedProjects);
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class RepositoryManager method commit.
/**
* Commit the given resources to their associated providers.
*
* @param resources the resources to commit
* @param monitor the progress monitor
*/
public void commit(IResource[] resources, String comment, boolean keepLocks, IProgressMonitor monitor) throws TeamException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
Map table = getProviderMapping(resources);
Set keySet = table.keySet();
// $NON-NLS-1$
monitor.beginTask("", keySet.size() * 1000);
// $NON-NLS-1$
monitor.setTaskName(Policy.bind("RepositoryManager.committing"));
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
List list = (List) table.get(provider);
IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
provider.checkin(providerResources, comment, keepLocks, IResource.DEPTH_INFINITE, subMonitor);
}
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class AddSynchronizeOperation method run.
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
resources = set.getResources();
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
addIgnoredResources = promptForAddOfIgnored(resources);
}
});
if (!addIgnoredResources)
return;
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InvocationTargetException {
try {
// associate the resources with their respective RepositoryProvider
Hashtable table = getProviderMapping(resources);
Set keySet = table.keySet();
// $NON-NLS-1$
monitor.beginTask("", keySet.size() * 1000);
// $NON-NLS-1$
monitor.setTaskName(Policy.bind("AddAction.adding"));
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {
IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 1000);
SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
List list = (List) table.get(provider);
IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
provider.add(providerResources, IResource.DEPTH_INFINITE, subMonitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
}, true, /* cancelable */
PROGRESS_BUSYCURSOR);
}
Aggregations