use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.
the class WorkspaceAction method getModifiedResources.
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
final List modified = new ArrayList();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// get adds, deletes, updates and property updates.
GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
command.run(iProgressMonitor);
ISVNStatus[] statuses = command.getStatuses();
for (int j = 0; j < statuses.length; j++) {
if (SVNStatusUtils.isReadyForRevert(statuses[j]) || !SVNStatusUtils.isManaged(statuses[j])) {
IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
if (currentResource != null)
modified.add(currentResource);
}
}
}
return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.
the class CommitAction method getModifiedResources.
/**
* get the modified and unadded resources in resources parameter
*/
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
boolean ignoreHiddenChanges = SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_HIDDEN_CHANGES);
IResource[] allResources = getSelectedResources(true);
List allSelections = new ArrayList();
for (int i = 0; i < allResources.length; i++) allSelections.add(allResources[i]);
List conflictFiles = new ArrayList();
final List modified = new ArrayList();
List unversionedFolders = new ArrayList();
hasUnaddedResources = false;
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// This check is for when the action is called with unmanaged resources
if (svnResource.getRepository() == null) {
continue;
}
// if only one resource selected, get url. Commit dialog displays this.
if (resources.length == 1) {
url = svnResource.getStatus().getUrlString();
if ((url == null) || (resource.getType() == IResource.FILE))
url = Util.getParentUrl(svnResource);
}
boolean descend = true;
if (resource instanceof IContainer) {
outer: for (int j = 0; j < allResources.length; j++) {
if (allResources[j] == resource)
continue;
IContainer parent = allResources[j].getParent();
while (parent != null) {
if (parent.equals(resource)) {
descend = false;
break outer;
}
parent = parent.getParent();
}
}
}
// get adds, deletes, updates and property updates.
GetStatusCommand command = new GetStatusCommand(svnResource, descend, false);
command.run(iProgressMonitor);
ISVNStatus[] statuses = command.getStatuses();
boolean switched = false;
for (int j = 0; j < statuses.length; j++) {
if (SVNStatusUtils.isReadyForCommit(statuses[j]) || SVNStatusUtils.isMissing(statuses[j])) {
IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
if (currentResource != null && (descend == true || allSelections.contains(currentResource))) {
SVNProviderPlugin.getPlugin().getStatusCacheManager().updateCache(currentResource, statuses[j]);
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
if (!localResource.isIgnored()) {
if (!SVNStatusUtils.isManaged(statuses[j])) {
if (!Util.isHidden(currentResource)) {
hasUnaddedResources = true;
if ((currentResource.getType() != IResource.FILE) && !isSymLink(currentResource))
unversionedFolders.add(currentResource);
else {
if (!modified.contains(currentResource)) {
modified.add(currentResource);
if (currentResource instanceof IContainer)
statusMap.put(currentResource, statuses[j].getPropStatus());
else
statusMap.put(currentResource, statuses[j].getTextStatus());
}
}
}
} else if (!ignoreHiddenChanges || !Util.isHidden(currentResource)) {
if (!modified.contains(currentResource)) {
if (statuses[j].isSwitched()) {
switched = true;
url = statuses[j].getUrlString();
}
modified.add(currentResource);
if (currentResource instanceof IContainer)
statusMap.put(currentResource, statuses[j].getPropStatus());
else {
statusMap.put(currentResource, statuses[j].getTextStatus());
if (SVNStatusUtils.isTextConflicted(statuses[j])) {
IFile conflictNewFile = (IFile) File2Resource.getResource(statuses[j].getConflictNew());
if (conflictNewFile != null)
conflictFiles.add(conflictNewFile);
IFile conflictOldFile = (IFile) File2Resource.getResource(statuses[j].getConflictOld());
if (conflictOldFile != null)
conflictFiles.add(conflictOldFile);
IFile conflictWorkingFile = (IFile) File2Resource.getResource(statuses[j].getConflictWorking());
if (conflictWorkingFile != null)
conflictFiles.add(conflictWorkingFile);
}
}
}
}
}
}
}
}
if (switched && modified.size() > 1) {
url = null;
}
}
IResource[] unaddedResources = getUnaddedResources(unversionedFolders, iProgressMonitor);
for (int i = 0; i < unaddedResources.length; i++) if (!modified.contains(unaddedResources[i]))
modified.add(unaddedResources[i]);
Iterator iter = conflictFiles.iterator();
while (iter.hasNext()) {
IFile conflictFile = (IFile) iter.next();
modified.remove(conflictFile);
statusMap.remove(conflictFile);
}
return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.
the class BaseFolder method getMembers.
/* (non-Javadoc)
* TODO This should use the synchronization information instead of hitting the WC
* @see org.tigris.subversion.subclipse.core.resources.RemoteFolder#getMembers(org.eclipse.core.runtime.IProgressMonitor)
*/
protected ISVNRemoteResource[] getMembers(IProgressMonitor monitor) throws SVNException {
final IProgressMonitor progress = Policy.monitorFor(monitor);
// $NON-NLS-1$
progress.beginTask(Policy.bind("RemoteFolder.getMembers"), 100);
try {
GetStatusCommand c = new GetStatusCommand(localResourceStatus.getRepository(), resource, false, true);
c.run(monitor);
LocalResourceStatus[] statuses = c.getLocalResourceStatuses();
List<BaseResource> baseChildren = new ArrayList<BaseResource>(statuses.length);
for (LocalResourceStatus status : statuses) {
if (localResourceStatus.getFile().equals(status.getFile())) {
continue;
}
// Don't create base entries for files that aren't managed yet
if (!status.hasRemote()) {
continue;
}
// The folders itself is not its own child, all direct children are
if (status.getUrlString() != null && !status.getUrlString().equals(localResourceStatus.getUrlString())) {
BaseResource member = BaseResource.from(SVNWorkspaceRoot.getResourceFor(resource, status), status);
member.setParent(this);
baseChildren.add(member);
}
}
return (ISVNRemoteResource[]) baseChildren.toArray(new ISVNRemoteResource[baseChildren.size()]);
} catch (CoreException e) {
throw new SVNException(new SVNStatus(IStatus.ERROR, SVNStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", // $NON-NLS-1$
getRepositoryRelativePath())));
} finally {
progress.done();
}
}
use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.
the class ResolveTreeConflictWizard method getStatuses.
private ISVNStatus[] getStatuses(boolean getAll) throws SVNException {
if (statuses == null) {
IProject project = treeConflict.getResource().getProject();
if (project == null)
return new ISVNStatus[0];
ISVNLocalResource svnProject = SVNWorkspaceRoot.getSVNResourceFor(project);
GetStatusCommand command = new GetStatusCommand(svnProject, true, getAll);
command.run(new NullProgressMonitor());
statuses = command.getStatuses();
}
return statuses;
}
use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.
the class RevertAction method getModifiedResources.
/**
* get the modified resources in resources parameter
*/
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
boolean ignoreHiddenChanges = SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_HIDDEN_CHANGES);
// if only one resource selected, get url. Revert dialog displays this.
if (resources.length == 1) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
url = svnResource.getStatus().getUrlString();
if ((url == null) || (resources[0].getType() == IResource.FILE))
url = Util.getParentUrl(svnResource);
}
ArrayList conflictFiles = new ArrayList();
final List modified = new ArrayList();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// get adds, deletes, updates and property updates.
GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
command.run(iProgressMonitor);
ISVNStatus[] statuses = command.getStatuses();
for (int j = 0; j < statuses.length; j++) {
if (statuses[j].isFileExternal() || SVNStatusKind.EXTERNAL.equals(statuses[j].getTextStatus())) {
includesExternals = true;
}
boolean isManaged = SVNStatusUtils.isManaged(statuses[j]);
if (SVNStatusUtils.isReadyForRevert(statuses[j]) || !isManaged) {
IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
if (currentResource != null) {
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
if (!localResource.isIgnored()) {
if (isManaged || !Util.isSpecialEclipseFile(currentResource)) {
boolean hidden = Util.isHidden(currentResource);
if (ignoreHiddenChanges && hidden) {
resourcesHidden = true;
}
if ((!ignoreHiddenChanges && isManaged) || !hidden) {
modified.add(currentResource);
if (currentResource instanceof IContainer)
statusMap.put(currentResource, statuses[j].getPropStatus());
else {
statusMap.put(currentResource, statuses[j].getTextStatus());
if (SVNStatusUtils.isTextConflicted(statuses[j])) {
IFile conflictNewFile = (IFile) File2Resource.getResource(statuses[j].getConflictNew());
if (conflictNewFile != null)
conflictFiles.add(conflictNewFile);
IFile conflictOldFile = (IFile) File2Resource.getResource(statuses[j].getConflictOld());
if (conflictOldFile != null)
conflictFiles.add(conflictOldFile);
IFile conflictWorkingFile = (IFile) File2Resource.getResource(statuses[j].getConflictWorking());
if (conflictWorkingFile != null)
conflictFiles.add(conflictWorkingFile);
}
}
}
}
}
}
}
}
}
Iterator iter = conflictFiles.iterator();
while (iter.hasNext()) {
IFile conflictFile = (IFile) iter.next();
modified.remove(conflictFile);
statusMap.remove(conflictFile);
}
return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
Aggregations