use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class GenerateDiffFileSynchronizeOperation method run.
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IResource[] resources = set.getResources();
HashMap statusMap = new HashMap();
unaddedList = new ArrayList();
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
SyncInfo syncInfo = set.getSyncInfo(resources[i]);
SVNStatusKind statusKind = null;
try {
if (!svnResource.isManaged()) {
statusKind = SVNStatusKind.UNVERSIONED;
} else {
switch(SyncInfo.getChange(syncInfo.getKind())) {
case SyncInfo.ADDITION:
statusKind = SVNStatusKind.ADDED;
break;
case SyncInfo.DELETION:
statusKind = SVNStatusKind.DELETED;
break;
case SyncInfo.CONFLICTING:
statusKind = SVNStatusKind.CONFLICTED;
break;
default:
statusKind = SVNStatusKind.MODIFIED;
break;
}
}
statusMap.put(resources[i], statusKind);
if (!svnResource.isManaged() && !svnResource.isIgnored())
unaddedList.add(resources[i]);
} catch (SVNException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
ArrayList dedupedList = new ArrayList();
Iterator iter = unaddedList.iterator();
while (iter.hasNext()) {
IResource resource = (IResource) iter.next();
if (!isDupe(resource))
dedupedList.add(resource);
}
IResource[] unversionedResources = new IResource[dedupedList.size()];
dedupedList.toArray(unversionedResources);
GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(new StructuredSelection(resources), unversionedResources, statusMap);
// $NON-NLS-1$
wizard.setWindowTitle(Policy.bind("GenerateSVNDiff.title"));
wizard.setSelectedResources(selectedResources);
// final WizardDialog dialog = new WizardDialog(getShell(), wizard);
// dialog.setMinimumPageSize(350, 250);
final WizardDialog dialog = new WizardDialogWithPersistedLocation(getShell(), wizard, // $NON-NLS-1$
"GenerateDiffFileWizard");
dialog.setMinimumPageSize(350, 250);
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
dialog.open();
}
});
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffOperation method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
ISVNClientAdapter client = null;
ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(fromUrl.toString());
if (repository != null)
client = repository.getSVNClient();
if (client == null)
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
try {
SVNRevision pegRevision = null;
if (fromUrl.toString().equals(toUrl.toString()) && localResource != null) {
if (localResource.getResource() == null)
pegRevision = SVNRevision.HEAD;
else {
IResource resource = localResource.getResource();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
pegRevision = svnResource.getRevision();
}
}
if (pegRevision == null)
client.diff(fromUrl, fromRevision, toUrl, toRevision, file, true);
else
client.diff(fromUrl, pegRevision, fromRevision, toRevision, file, true);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
monitor.done();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class BranchTagOperation method updateBranchTagProperty.
private void updateBranchTagProperty(IResource resource) {
AliasManager aliasManager = new AliasManager(resource, false);
Alias[] branchAliases = aliasManager.getBranches();
Alias[] tagAliases = aliasManager.getTags();
StringBuffer propertyValue = new StringBuffer();
for (int i = 0; i < branchAliases.length; i++) {
if (branchAliases[i].getRevision() > 0) {
// $NON-NLS-1$
if (propertyValue.length() > 0)
propertyValue.append("\n");
Alias branch = branchAliases[i];
// $NON-NLS-1$
propertyValue.append(branch.getRevision() + "," + branch.getName());
if (branch.getRelativePath() != null)
// $NON-NLS-1$
propertyValue.append("," + branch.getRelativePath());
if (// $NON-NLS-1$
branch.isBranch())
// $NON-NLS-1$
propertyValue.append(",branch");
else
// $NON-NLS-1$
propertyValue.append(",tag");
}
}
for (int i = 0; i < tagAliases.length; i++) {
if (tagAliases[i].getRevision() > 0) {
// $NON-NLS-1$
if (propertyValue.length() > 0)
propertyValue.append("\n");
Alias tag = tagAliases[i];
// $NON-NLS-1$
propertyValue.append(tag.getRevision() + "," + tag.getName());
if (tag.getRelativePath() != null)
// $NON-NLS-1$
propertyValue.append("," + tag.getRelativePath());
if (// $NON-NLS-1$
tag.isBranch())
// $NON-NLS-1$
propertyValue.append(",branch");
else
// $NON-NLS-1$
propertyValue.append(",tag");
}
}
// $NON-NLS-1$
if (propertyValue.length() > 0)
propertyValue.append("\n");
propertyValue.append(newAlias.getRevision() + "," + newAlias.getName() + "," + // $NON-NLS-1$ //$NON-NLS-2$
newAlias.getRelativePath());
if (// $NON-NLS-1$
newAlias.isBranch())
// $NON-NLS-1$
propertyValue.append(",branch");
else
// $NON-NLS-1$
propertyValue.append(",tag");
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
// $NON-NLS-1$
svnResource.setSvnProperty("subclipse:tags", propertyValue.toString(), false);
} catch (SVNException e) {
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ProjectProperties method getProjectProperties.
private static ProjectProperties getProjectProperties(File file, ISVNLocalResource svnResource) throws SVNException {
if (file == null)
return null;
ISVNLocalResource parent = svnResource;
while (parent != null) {
if (parent.exists() && parent.isManaged() && !parent.getStatusFromCache().isDeleted()) {
break;
}
parent = parent.getParent();
}
if (parent == null || !parent.exists() || !parent.isManaged() || parent.getStatusFromCache().isDeleted()) {
return null;
}
String message = null;
String logregex = null;
String label = null;
String url = null;
boolean number = false;
boolean warnifnoissue = false;
boolean append = true;
ISVNProperty[] bugtraqProperties = parent.getPropertiesIncludingInherited(false, true, propertyFilterList);
for (ISVNProperty prop : bugtraqProperties) {
if (prop.getName().equals("bugtraq:message")) {
message = prop.getValue();
} else if (prop.getName().equals("bugtraq:logregex")) {
logregex = prop.getValue();
} else if (prop.getName().equals("bugtraq:label")) {
label = prop.getValue();
} else if (prop.getName().equals("bugtraq:url")) {
url = resolveUrl(prop.getValue(), svnResource);
} else if (prop.getName().equals("bugtraq:number")) {
number = prop.getValue().equalsIgnoreCase("true");
} else if (prop.getName().equals("bugtraq:warnifnoissue")) {
warnifnoissue = prop.getValue().equalsIgnoreCase("true");
} else if (prop.getName().equals("bugtraq:append")) {
append = prop.getValue().equalsIgnoreCase("true");
}
}
ProjectProperties projectProperties = null;
if (message != null || logregex != null) {
projectProperties = new ProjectProperties();
projectProperties.setMessage(message);
projectProperties.setLogregex(logregex);
if (label != null) {
projectProperties.setLabel(label);
}
projectProperties.setUrl(url);
projectProperties.setNumber(number);
projectProperties.setWarnIfNoIssue(warnifnoissue);
projectProperties.setAppend(append);
}
return projectProperties;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class CommitOperation method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
postCommitError = null;
monitor.beginTask(null, resourcesToAdd.length + resourcesToDelete.length + resourcesToCommit.length);
try {
svnClient = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
if (resourcesToAdd.length > 0) {
Map<SVNTeamProvider, List<IResource>> table = getProviderMapping(resourcesToAdd);
if (table.get(null) != null) {
throw new SVNException(// $NON-NLS-1$
Policy.bind("RepositoryManager.addErrorNotAssociated"));
}
Set<SVNTeamProvider> keySet = table.keySet();
for (SVNTeamProvider provider : keySet) {
List<IResource> list = table.get(provider);
IResource[] providerResources = list.toArray(new IResource[list.size()]);
provider.add(providerResources, IResource.DEPTH_ZERO, Policy.subMonitorFor(monitor, resourcesToAdd.length));
}
}
if (resourcesToDelete.length > 0) {
// use an adapter that will log to console
ISVNClientAdapter svnDeleteClient = null;
try {
Map<SVNTeamProvider, List<IResource>> table = getProviderMapping(resourcesToDelete);
if (table.get(null) != null) {
throw new SVNException(// $NON-NLS-1$
Policy.bind("RepositoryManager.addErrorNotAssociated"));
}
Set<SVNTeamProvider> keySet = table.keySet();
for (SVNTeamProvider provider : keySet) {
List<IResource> list = table.get(provider);
File[] files = new File[list.size()];
int i = 0;
for (IResource resource : list) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
if (svnDeleteClient == null)
svnDeleteClient = svnResource.getRepository().getSVNClient();
files[i] = svnResource.getFile();
i++;
}
svnDeleteClient.remove(files, true);
}
} catch (SVNClientException e) {
throw new TeamException(e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnDeleteClient);
}
}
setAtomicCommitMode();
Map<ProjectAndRepository, List<IResource>> table = getCommitProviderMapping(resourcesToCommit);
Set<ProjectAndRepository> keySet = table.keySet();
for (ProjectAndRepository mapKey : keySet) {
SVNTeamProvider provider = mapKey.getTeamProvider();
List<IResource> list = table.get(mapKey);
IResource[] providerResources = new IResource[list.size()];
list.toArray(providerResources);
postCommitError = provider.checkin(providerResources, commitComment, keepLocks, IResource.DEPTH_ZERO, Policy.subMonitorFor(monitor, providerResources.length));
for (IResource providerResource : providerResources) {
if (!providerResource.exists()) {
SVNProviderPlugin.getPlugin().getStatusCacheManager().removeStatus(providerResource);
}
}
if (postCommitError != null) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("CommitDialog.title"), postCommitError);
}
});
}
}
} catch (TeamException e) {
throw SVNException.wrapException(e);
} finally {
monitor.done();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
// refresh the Synch view
SVNProviderPlugin.broadcastModificationStateChanges(resourcesToCommit);
}
}
Aggregations