use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class ImportCommand 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 {
final IProgressMonitor subPm = Policy.infiniteSubMonitorFor(monitor, 100);
ISVNClientAdapter svnClient = null;
try {
subPm.beginTask(null, Policy.INFINITE_PM_GUESS_FOR_SWITCH);
svnClient = folder.getRepository().getSVNClient();
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(subPm, svnClient));
svnClient.doImport(dir, folder.getUrl(), comment, recurse);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
folder.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation();
subPm.done();
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class LockResourcesCommand 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 {
final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
final File[] resourceFiles = new File[resources.length];
for (int i = 0; i < resources.length; i++) resourceFiles[i] = resources[i].getLocation().toFile();
try {
monitor.beginTask(null, 100);
svnClient.addNotifyListener(operationResourceCollector);
OperationManager.getInstance().beginOperation(svnClient);
svnClient.lock(resourceFiles, message, force);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
Set<IResource> operationResources = operationResourceCollector.getOperationResources();
OperationManager.getInstance().endOperation(true, operationResources, refreshLocal);
if (svnClient != null) {
svnClient.removeNotifyListener(operationResourceCollector);
root.getRepository().returnSVNClient(svnClient);
}
monitor.done();
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class MergeCommand method run.
public void run(IProgressMonitor monitor) throws SVNException {
ISVNClientAdapter svnClient = null;
try {
monitor.beginTask(null, 100);
svnClient = root.getRepository().getSVNClient();
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
monitor.subTask(resource.getName());
File file = resource.getLocation().toFile();
svnClient.merge(svnUrl1, svnRevision1, svnUrl2, svnRevision2, file, force, recurse, false, ignoreAncestry);
try {
// Refresh the resource after merge
resource.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e1) {
}
monitor.worked(100);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
root.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation();
monitor.done();
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class RevertResourcesCommand 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 {
final Set<IResource> propertiesOnlyFolders = new LinkedHashSet<IResource>();
// sort first, so that all children of a folder directly follow it in the array
Arrays.sort(resources, resourceComparator);
ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
try {
final OperationManager operationManager = OperationManager.getInstance();
operationManager.beginOperation(svnClient);
// local history first. Also remove unversioned resources.
if (recurse && resourcesToRevert != null) {
for (int i = 0; i < resourcesToRevert.length; i++) {
if (project == null || resourcesToRevert[i].getProject().equals(project)) {
try {
Util.saveLocalHistory(resourcesToRevert[i]);
} catch (CoreException e) {
SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
LocalResourceStatus status = SVNWorkspaceRoot.getSVNResourceFor(resourcesToRevert[i]).getStatus();
if (!(resourcesToRevert[i].getType() == IResource.FOLDER) || !status.isAdded()) {
if (!status.isManaged()) {
try {
resourcesToRevert[i].delete(true, monitor);
} catch (CoreException ex) {
throw SVNException.wrapException(ex);
}
}
}
}
}
}
for (int i = 0; i < resources.length; i++) {
LocalResourceStatus status = SVNWorkspaceRoot.getSVNResourceFor(resources[i]).getStatus();
// current as a base path.
if (resources[i].getType() == IResource.FOLDER && status.isAdded()) {
svnClient.revert(resources[i].getLocation().toFile(), true);
propertiesOnlyFolders.add(resources[i]);
monitor.worked(100);
// be refreshed.
try {
resources[i].accept(new IResourceVisitor() {
public boolean visit(IResource aResource) {
if (aResource.getType() == IResource.FOLDER) {
operationManager.onNotify(aResource.getLocation().toFile(), SVNNodeKind.UNKNOWN);
// This is necessary for folders, that are ignored after the revert
propertiesOnlyFolders.add(aResource);
}
return true;
}
}, IResource.DEPTH_INFINITE, false);
} catch (CoreException e) {
SVNProviderPlugin.log(Status.WARNING, "", e);
}
// If folder path has no ending / we can have problem where dir foobar will look like
// subdir of foo
String baseFullPath = resources[i].getFullPath().addTrailingSeparator().toString();
while (i < resources.length - 1 && resources[i + 1].getFullPath().toString().startsWith(baseFullPath)) {
monitor.worked(100);
i++;
}
} else {
if (!status.isManaged()) {
try {
resources[i].delete(true, monitor);
} catch (CoreException ex) {
throw SVNException.wrapException(ex);
}
} else {
if (!recurse) {
try {
Util.saveLocalHistory(resources[i]);
} catch (CoreException e) {
SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
File path = resources[i].getLocation().toFile();
svnClient.revert(path, recurse);
// notify the change. As workaround, do it manually.
if (resources[i].getType() != IResource.FILE) {
operationManager.onNotify(path, SVNNodeKind.UNKNOWN);
propertiesOnlyFolders.add(resources[i]);
}
monitor.worked(100);
}
}
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
root.getRepository().returnSVNClient(svnClient);
if (propertiesOnlyFolders.size() > 0) {
OperationManager.getInstance().endOperation(true, propertiesOnlyFolders);
} else {
OperationManager.getInstance().endOperation();
}
monitor.done();
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class ShareProjectCommand 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 {
// Determine if the repository is known
boolean alreadyExists = SVNProviderPlugin.getPlugin().getRepositories().isKnownRepository(location.getLocation(), false);
final ISVNClientAdapter svnClient = location.getSVNClient();
try {
// perform the workspace modifications in a runnable
SVNProviderPlugin.run(new ISVNRunnable() {
public void run(IProgressMonitor pm) throws SVNException {
String message;
if (comment == null)
// $NON-NLS-1$
message = Policy.bind("SVNProvider.initialImport");
else
message = comment;
try {
// create the remote dir
SVNUrl url = location.getUrl().appendPath(remoteDirName);
if (createDirectory)
svnClient.mkdir(url, true, message);
try {
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(pm, svnClient));
// checkout it so that we have .svn
// If directory already existed in repository, do recursive checkout.
svnClient.checkout(url, project.getLocation().toFile(), SVNRevision.HEAD, !createDirectory);
} finally {
OperationManager.getInstance().endOperation();
}
} catch (SVNClientException e) {
throw new SVNException("Error while creating module: " + e.getMessage(), e);
}
// SharingWizard.doesSVNDirectoryExist calls
// getStatus on the folder which populates the
// status cache
// Need to clear the cache so we can get the new
// hasRemote value
SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(project, true);
try {
// Register it with Team.
RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
} catch (TeamException e) {
throw new SVNException("Cannot register project with svn provider", e);
}
}
}, monitor);
} catch (SVNException e) {
// its cache
if (!alreadyExists)
SVNProviderPlugin.getPlugin().getRepositories().disposeRepository(location);
throw e;
} finally {
location.returnSVNClient(svnClient);
}
// Add the repository if it didn't exist already
if (!alreadyExists)
SVNProviderPlugin.getPlugin().getRepositories().addOrUpdateRepository(location);
}
Aggregations