use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class SVNMoveDeleteHook method getDeferFileDelete.
// Get the DeferFileDelete Property for selected resource.
private boolean getDeferFileDelete(IResource resource) {
ISVNProperty property = null;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
ISVNLocalResource parent = svnResource;
try {
while (parent != null) {
if (parent.isManaged()) {
break;
}
parent = parent.getParent();
}
if (parent == null || !parent.isManaged()) {
return false;
}
ISVNProperty[] deferFileDeleteProperties = parent.getPropertiesIncludingInherited(false, true, deferFileDeleteFilterList);
if (deferFileDeleteProperties != null && deferFileDeleteProperties.length > 0) {
return deferFileDeleteProperties[0].getValue().equalsIgnoreCase("true");
}
} catch (SVNException e) {
return false;
}
return false;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class RevertResourceManager method processResources.
/**
* Revert previously deleted resources that are added again. When a file is reverted, it's parent
* directories are also reverted. When new files are added in folders that are scheduled for
* deletion, the parent folder tree is reverted.
*
* @param resources
*/
private ISVNLocalResource[] processResources(IResourceDelta[] resources) throws CoreException {
List<ISVNLocalResource> revertedResources = new ArrayList<ISVNLocalResource>();
for (IResourceDelta resourceDelta : resources) {
IResource resource = resourceDelta.getResource();
if (resource.getType() == IResource.FILE) {
ISVNLocalFile res = SVNWorkspaceRoot.getSVNFileFor((IFile) resource);
if (res.getFile().exists()) {
boolean deleted;
if (resourceDelta.getKind() == IResourceDelta.ADDED)
deleted = res.getStatusFromCache().isDeleted();
else {
deleted = SVNMoveDeleteHook.isDeleted((IFile) resource);
if (deleted)
SVNMoveDeleteHook.removeFromDeletedFileList((IFile) resource);
}
if (deleted) {
revertedResources.add(res);
}
ISVNLocalFolder parentFolder = res.getParent();
while (parentFolder != null) {
if (parentFolder.getStatusFromCache().isDeleted() && !parentFolder.getResource().exists() && !revertedResources.contains(parentFolder)) {
revertedResources.add(parentFolder);
} else {
break;
}
if (parentFolder.getParent() == null) {
break;
}
parentFolder = parentFolder.getParent();
}
}
}
}
return (ISVNLocalResource[]) revertedResources.toArray(new ISVNLocalResource[revertedResources.size()]);
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ViewGraphAction method execute.
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
IResource[] resources = getSelectedResources();
try {
if (resources.length > 0) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
ISVNRemoteResource remoteResource = svnResource.getBaseResource();
if (remoteResource != null) {
String repoPath = remoteResource.getRepositoryRelativePath();
if (repoPath == null || repoPath.length() == 0) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("ViewGraphAction.0"), // $NON-NLS-1$ //$NON-NLS-2$
Policy.bind("ViewGraphAction.1"));
return;
}
}
// IEditorPart part =
getTargetPage().openEditor(new RevisionGraphEditorInput(resources[0]), // $NON-NLS-1$
"org.tigris.subversion.subclipse.graph.editors.revisionGraphEditor");
}
} catch (Exception e) {
Activator.handleError(e);
Activator.showErrorDialog(getErrorTitle(), e);
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class CheckinResourcesCommand method run.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws SVNException {
commitError = false;
postCommitError = null;
final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
try {
// Prepare the parents list
// we will Auto-commit parents if they are not already commited
List<IContainer> parentsList = new ArrayList<IContainer>();
List<IProject> projectList = new ArrayList<IProject>();
for (IResource currentResource : resources) {
IProject project = currentResource.getProject();
if (!projectList.contains(project)) {
projectList.add(project);
}
IContainer parent = currentResource.getParent();
ISVNLocalResource svnParentResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && !svnParentResource.hasRemote()) {
if (!inCommitList(parent))
parentsList.add(parent);
parent = parent.getParent();
svnParentResource = svnParentResource.getParent();
}
}
// convert parents and resources to an array of File
int parents = parentsList.size();
// change commit to non-recursive!!
if (parents > 0)
depth = IResource.DEPTH_ZERO;
final File[] resourceFiles = new File[parents + resources.length];
for (int i = 0; i < parents; i++) {
resourceFiles[i] = ((IResource) parentsList.get(i)).getLocation().toFile();
}
for (int i = 0, j = parents; i < resources.length; i++, j++) {
resourceFiles[j] = resources[i].getLocation().toFile();
}
IProject[] projects = new IProject[projectList.size()];
projectList.toArray(projects);
ISchedulingRule rule = MultiRule.combine(projects);
SVNProviderPlugin.run(new ISVNRunnable() {
public void run(final IProgressMonitor pm) throws SVNException {
try {
notifyListener = new ISVNNotifyListener() {
public void logCommandLine(String commandLine) {
}
public void logCompleted(String message) {
}
public void logError(String message) {
}
public void logMessage(String message) {
if (message.startsWith("Transmitting file data"))
pm.subTask(message);
}
public void logRevision(long revision, String path) {
}
public void onNotify(File path, SVNNodeKind kind) {
}
public void setCommand(int command) {
}
};
pm.beginTask(null, resourceFiles.length);
pm.setTaskName("Checking in...");
svnClient.addNotifyListener(operationResourceCollector);
svnClient.addNotifyListener(notifyListener);
// then the resources the user has requested to commit
if (svnClient.canCommitAcrossWC())
svnClient.commitAcrossWC(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks, true);
else
svnClient.commit(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks);
postCommitError = svnClient.getPostCommitError();
} catch (SVNClientException e) {
commitError = true;
throw SVNException.wrapException(e);
} finally {
pm.done();
if (svnClient != null) {
svnClient.removeNotifyListener(operationResourceCollector);
svnClient.removeNotifyListener(notifyListener);
root.getRepository().returnSVNClient(svnClient);
}
}
}
}, rule, Policy.monitorFor(monitor));
} finally {
OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources(), !commitError);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class GetLogsCommand method run.
/**
* execute the command
*
* @param aMonitor
* @throws SVNException
*/
public void run(IProgressMonitor aMonitor) throws SVNException {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
logEntries = null;
IProgressMonitor monitor = Policy.monitorFor(aMonitor);
// $NON-NLS-1$
monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100);
ISVNLogMessage[] logMessages;
try {
if (callback == null) {
logMessages = remoteResource.getLogMessages(pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions);
} else {
repository = remoteResource.getRepository();
svnClient = repository.getSVNClient();
if (remoteResource instanceof BaseResource) {
boolean logMessagesRetrieved = false;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(remoteResource.getResource());
if (svnResource != null) {
LocalResourceStatus status = svnResource.getStatus();
if (status != null && status.isCopied()) {
ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
SVNUrl copiedFromUrl = info.getCopyUrl();
if (copiedFromUrl != null) {
svnClient.getLogMessages(copiedFromUrl, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
logMessagesRetrieved = true;
GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(remoteResource.getRepository(), copiedFromUrl, SVNRevision.HEAD);
getRemoteResourceCommand.run(null);
remoteResource = getRemoteResourceCommand.getRemoteResource();
}
}
}
if (!logMessagesRetrieved)
svnClient.getLogMessages(((BaseResource) remoteResource).getFile(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
} else {
svnClient.getLogMessages(remoteResource.getUrl(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
}
logMessages = callback.getLogMessages();
}
if (remoteResource.isFolder()) {
logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFolder) remoteResource, logMessages, getTags(logMessages));
} else {
logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFile) remoteResource, logMessages, getTags(logMessages), getUrls(logMessages));
}
} catch (Exception e) {
throw SVNException.wrapException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
monitor.done();
}
}
Aggregations