use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class BranchTagWizard method updateTagsProperty.
private void updateTagsProperty(SVNUrl toUrl) {
ISVNClientAdapter svnClient = null;
try {
if (resources.length > 1)
return;
ISVNProperty property = null;
// $NON-NLS-1$
property = repositoryPage.getSvnResource().getSvnProperty("subclipse:tags");
if (property == null)
return;
newAlias = new Alias();
// $NON-NLS-1$
newAlias.setBranch(toUrl.toString().toUpperCase().indexOf("TAGS") == -1);
String relativePath = toUrl.toString().substring(repositoryPage.getSvnResource().getRepository().getUrl().toString().length());
newAlias.setRelativePath(relativePath);
SVNRevision revision = null;
if (copyPage.revisionButton.getSelection())
revision = SVNRevision.getRevision(copyPage.getRevision());
else {
svnClient = repositoryPage.getSvnResource().getRepository().getSVNClient();
ISVNInfo svnInfo = svnClient.getInfo(repositoryPage.getUrl());
revision = SVNRevision.getRevision(svnInfo.getRevision().toString());
}
newAlias.setRevision(Integer.parseInt(revision.toString()));
newAlias.setName(toUrl.getLastPathSegment());
BranchTagPropertyUpdateDialog dialog = new BranchTagPropertyUpdateDialog(getShell(), getResource(), newAlias, // $NON-NLS-1$
"BranchTagPropertyUpdateDialog");
if (dialog.open() == BranchTagPropertyUpdateDialog.OK)
newAlias = dialog.getNewAlias();
else
newAlias = null;
} catch (Exception e) {
} finally {
if (svnClient != null) {
repositoryPage.getSvnResource().getRepository().returnSVNClient(svnClient);
}
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class ResolveSynchronizeOperation method run.
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
boolean folderSelected = false;
propertyConflicts = false;
textConflicts = false;
treeConflicts = false;
canceled = false;
final IResource[] resources = set.getResources();
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IContainer) {
folderSelected = true;
break;
}
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 (folderSelected) {
selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
} else {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (propertyConflicts && !textConflicts) {
String message;
if (resources.length > 1)
// $NON-NLS-1$
message = Policy.bind("ResolveAction.confirmMultiple");
else
message = Policy.bind("ResolveAction.confirm", // $NON-NLS-1$
resources[0].getName());
if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), message)) {
// $NON-NLS-1$
canceled = true;
return;
}
selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
} else {
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) {
canceled = true;
return;
}
selectedResolution = markResolvedPage.getResolution();
}
}
});
}
if (canceled)
return;
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InvocationTargetException {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
try {
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
svnClient.resolve(resources[i].getLocation().toFile(), selectedResolution);
repository.returnSVNClient(svnClient);
repository = null;
svnClient = null;
// for some reason, just refreshing the file won't cut it.
resources[i].getParent().refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} catch (SVNClientException e) {
throw new InvocationTargetException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class UnversionedCustomProperty method getSvnRevisionProperties.
public static ISVNProperty[] getSvnRevisionProperties(final SVNUrl url, final SVNRevision revision, final SVNRevision peg, final boolean customOnly) throws SVNException {
ISVNClientAdapter svnClient = null;
try {
svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
SVNProviderPlugin.disableConsoleLogging();
ISVNProperty[] props = svnClient.getRevProperties(url, (SVNRevision.Number) revision);
if (customOnly)
return stripNonCustom(props);
return props;
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
SVNProviderPlugin.enableConsoleLogging();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class CopyAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
final IResource[] resources = getSelectedResources();
final IProject project = resources[0].getProject();
ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), project, false, // $NON-NLS-1$
Policy.bind("CopyAction.selectionLabel"));
if (dialog.open() == ContainerSelectionDialog.CANCEL)
return;
Object[] result = dialog.getResult();
if (result == null || result.length == 0)
return;
final Path path = (Path) result[0];
IProject selectedProject;
File target = null;
if (path.segmentCount() == 1) {
selectedProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.toString());
target = selectedProject.getLocation().toFile();
} else {
IFile targetFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
selectedProject = targetFile.getProject();
target = targetFile.getLocation().toFile();
}
final IProject targetProject = selectedProject;
final File destPath = target;
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
ISVNRepositoryLocation repository = null;
try {
ISVNLocalResource svnTargetResource = SVNWorkspaceRoot.getSVNResourceFor(targetProject);
for (int i = 0; i < resources.length; i++) {
final IResource resource = resources[i];
if (client == null) {
repository = SVNWorkspaceRoot.getSVNResourceFor(resources[i]).getRepository();
client = repository.getSVNClient();
}
File checkFile = new File(destPath.getPath() + File.separator + resource.getName());
File srcPath = new File(resource.getLocation().toString());
File newDestPath = new File(destPath.getPath() + File.separator + resource.getName());
if (checkFile.exists()) {
IInputValidator inputValidator = new IInputValidator() {
public String isValid(String newText) {
if (newText.equals(resource.getName()))
// $NON-NLS-1$
return Policy.bind("CopyAction.nameConflictSame");
return null;
}
};
InputDialog inputDialog = new InputDialog(getShell(), Policy.bind("CopyAction.nameConflictTitle"), Policy.bind("CopyAction.nameConflictMessage", resource.getName()), "Copy of " + resource.getName(), // $NON-NLS-1$
inputValidator);
if (inputDialog.open() == InputDialog.CANCEL)
return;
String newName = inputDialog.getValue();
if (newName == null || newName.trim().length() == 0)
return;
newDestPath = new File(destPath.getPath() + File.separator + newName);
}
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
boolean sameRepository = svnTargetResource != null && svnTargetResource.getRepository() != null && svnTargetResource.getRepository().getLocation().equals(svnResource.getRepository().getLocation());
if (sameRepository)
client.copy(srcPath, newDestPath);
else
client.doExport(srcPath, newDestPath, true);
SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
}
targetProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("CopyAction.copy"), // $NON-NLS-1$
e.getMessage());
} finally {
if (repository != null) {
repository.returnSVNClient(client);
}
}
}
});
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class EditPropertyConflictsAction method execute.
protected void execute(final IAction action) throws InvocationTargetException, InterruptedException {
error = null;
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
IResource resource = getSelectedResources()[0];
svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
ISVNClientAdapter client = null;
try {
conflictSummary = PropertyConflict.getConflictSummary(svnResource);
propertyConflicts = PropertyConflict.getPropertyConflicts(svnResource);
client = svnResource.getRepository().getSVNClient();
remoteProperties = client.getProperties(svnResource.getUrl(), svnResource.getRevision(), svnResource.getRevision());
} catch (Exception e) {
error = e;
} finally {
svnResource.getRepository().returnSVNClient(client);
}
}
});
if (error != null) {
handle(error);
return;
}
EditPropertyConflictsWizard wizard = new EditPropertyConflictsWizard(svnResource, conflictSummary, propertyConflicts, remoteProperties, getTargetPart());
WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
"EditPropertyConflicts");
dialog.open();
}
Aggregations