use of org.tigris.subversion.svnclientadapter.ISVNNotifyListener 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.svnclientadapter.ISVNNotifyListener in project subclipse by subclipse.
the class PeekStatusCommand method execute.
public void execute() throws SVNException {
ISVNClientAdapter client = null;
ISVNNotifyListener revisionListener = new ISVNNotifyListener() {
public void setCommand(int command) {
}
public void logCommandLine(String commandLine) {
}
public void logMessage(String message) {
}
public void logError(String message) {
}
public void logRevision(long aRevision, String path) {
PeekStatusCommand.this.revision = new SVNRevision.Number(aRevision);
}
public void logCompleted(String message) {
}
public void onNotify(File path, SVNNodeKind kind) {
}
};
try {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.addNotifyListener(revisionListener);
File file;
if (resource != null)
file = resource.getLocation().toFile();
else
file = path.toFile();
status = null;
ISVNStatus[] statuses = client.getStatus(file, false, true, false);
for (int i = 0; i < statuses.length; i++) {
if (file.equals(statuses[i].getFile())) {
status = statuses[i];
if (status.getUrl() == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED))
info = client.getInfo(status.getFile());
break;
}
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
if (client != null) {
client.removeNotifyListener(revisionListener);
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
}
use of org.tigris.subversion.svnclientadapter.ISVNNotifyListener in project subclipse by subclipse.
the class StatusCommand method execute.
protected void execute(final ISVNClientAdapter client, final IProgressMonitor monitor) throws SVNClientException {
ISVNNotifyListener revisionListener = new ISVNNotifyListener() {
public void setCommand(int command) {
}
public void logCommandLine(String commandLine) {
}
public void logMessage(String message) {
}
public void logError(String message) {
}
public void logRevision(long aRevision, String path) {
StatusCommand.this.revisions.add(new RevisionsCache(aRevision, path));
if (StatusCommand.this.revisions.size() > 1) {
Collections.sort(StatusCommand.this.revisions);
}
}
public void logCompleted(String message) {
}
public void onNotify(File path, SVNNodeKind kind) {
}
};
try {
client.addNotifyListener(revisionListener);
if (callback != null && callback instanceof CancelableSVNStatusCallback) {
((CancelableSVNStatusCallback) callback).setSvnClient(client);
}
statuses = client.getStatus(file, descend, getAll, contactServer, false, callback);
} finally {
client.removeNotifyListener(revisionListener);
}
}
Aggregations