use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.
the class FileModificationManager method autoShareProjectIfSVNWorkingCopy.
private void autoShareProjectIfSVNWorkingCopy(IProject project) {
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClient();
SVNProviderPlugin.disableConsoleLogging();
ISVNInfo info = client.getInfoFromWorkingCopy(project.getLocation().toFile());
if (info != null && info.getRepository() != null) {
SVNTeamProviderType.getAutoShareJob().share(project);
}
} catch (Exception e) {
} finally {
SVNProviderPlugin.enableConsoleLogging();
if (client != null) {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
}
use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.
the class GraphBackgroundTask method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
boolean error = false;
Cache cache = null;
monitor.beginTask("Calculating graph information", TOTAL_STEPS);
monitor.worked(SHORT_TASK_STEPS);
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClient();
ISVNInfo info;
if (resource == null)
info = client.getInfo(remoteResource.getUrl());
else {
if (resource.getRawLocation() == null)
info = client.getInfoFromWorkingCopy(resource.getLocation().toFile());
else
info = client.getInfoFromWorkingCopy(resource.getRawLocation().toFile());
if (info.getUuid() == null) {
info = client.getInfo(info.getUrl());
}
}
if (editor != null)
((RevisionGraphEditorInput) editor.getEditorInput()).setInfo(info);
long revision = info.getRevision().getNumber();
String path = info.getUrl().toString().substring(info.getRepository().toString().length());
monitor.setTaskName("Initializating cache");
cache = getCache(info.getUuid());
monitor.worked(SHORT_TASK_STEPS);
// update the cache
long latestRevisionStored = cache.getLatestRevision();
SVNRevision latest = null;
SVNRevision endRevision = null;
monitor.setTaskName("Connecting to the repository");
// TODO: try-catch this line and make it work off-line
long latestRevisionInRepository = client.getInfo(info.getRepository()).getLastChangedRevision().getNumber();
monitor.worked(SHORT_TASK_STEPS);
if (refreshRevision != null || refreshRevisions != null || latestRevisionInRepository > latestRevisionStored) {
if (refreshRevision == null) {
if (latestRevisionStored >= latestRevisionInRepository)
latest = new SVNRevision.Number(latestRevisionInRepository);
else
latest = new SVNRevision.Number(latestRevisionStored + 1);
} else {
latest = refreshRevision;
}
if (refreshRevision == null)
endRevision = SVNRevision.HEAD;
else
endRevision = refreshRevision;
try {
monitor.setTaskName("Retrieving revision history");
int unitWork;
if (refreshRevision == null && refreshRevisions == null)
unitWork = VERY_LONG_TASK / (int) (latestRevisionInRepository - latestRevisionStored);
else if (refreshRevisions != null)
unitWork = VERY_LONG_TASK / refreshRevisions.length;
else
unitWork = VERY_LONG_TASK;
if (refreshRevisions != null) {
if (monitor.isCanceled())
return;
monitor.setTaskName("Refreshing cache");
List refreshedNodes = new ArrayList();
for (int i = 0; i < refreshNodes.length; i++) {
if (refreshNodes[i].getAction() != 'D')
refreshedNodes.add(refreshNodes[i]);
}
cache.refresh(refreshedNodes, info, monitor, unitWork);
} else if (refreshRevision != null) {
if (monitor.isCanceled())
return;
monitor.setTaskName("Refreshing cache");
revision = refreshNode.getRevision();
path = refreshNode.getPath();
List refreshedNodes = new ArrayList();
refreshedNodes.add(refreshNode);
cache.refresh(refreshedNodes, info, monitor, unitWork);
}
if (getNewRevisions) {
CallbackUpdater callbackUpdater = new CallbackUpdater(cache, monitor, unitWork, client);
cache.startUpdate();
client.getLogMessages(info.getRepository(), latest, latest, endRevision, false, true, 0, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callbackUpdater);
cache.finishUpdate();
}
} catch (Exception e) {
Activator.handleError(e);
error = true;
Activator.showErrorDialog("Calculate Revision Graph Information", e, false);
}
} else {
monitor.worked(VERY_LONG_TASK);
}
if (editor != null) {
if (error == true || monitor.isCanceled()) {
if (refreshRevision == null && refreshRevisions == null) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = editor.getEditorSite().getWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
page.activate(editor);
page.closeEditor(editor, false);
}
});
}
} else {
updateView(monitor, cache, path, revision);
}
}
monitor.done();
} catch (Exception e) {
Activator.handleError(e);
Activator.showErrorDialog("Calculate Revision Graph Information", e, false);
return;
} finally {
if (cache != null)
cache.close();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.
the class StatusCacheManager method getResourceRevision.
/**
* The cached statuses do not provide revision numbers anymore. This method is the only place how
* to query for the revision of the resource explicitely.
*
* @param resource
* @return
* @throws SVNException
*/
public SVNRevision getResourceRevision(ISVNLocalResource resource) throws SVNException {
if (resource == null)
return null;
GetInfoCommand command = new GetInfoCommand(resource);
command.run(null);
final ISVNInfo info = command.getInfo();
return (info != null) ? info.getRevision() : null;
}
use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.
the class StatusCacheManager method getURL.
// getStatuses returns null URL for svn:externals folder. This will
// get the URL using svn info command on the local resource
private String getURL(ISVNStatus status) {
String url = status.getUrlString();
if (url == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED) && !(status.getTextStatus() == SVNStatusKind.IGNORED)) {
ISVNClientAdapter svnClient = null;
try {
svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
SVNProviderPlugin.disableConsoleLogging();
ISVNInfo info = svnClient.getInfoFromWorkingCopy(status.getFile());
SVNUrl svnurl = info.getUrl();
url = (svnurl != null) ? svnurl.toString() : null;
} catch (SVNException e) {
} catch (SVNClientException e) {
} finally {
SVNProviderPlugin.enableConsoleLogging();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
}
}
return url;
}
use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.
the class CompareRevisionsAction method run.
public void run() {
RevisionGraphEditorInput input = (RevisionGraphEditorInput) editor.getEditorInput();
boolean isFolder = (input.getResource() != null && input.getResource().getType() != IResource.FILE) || (input.getRemoteResource() != null && input.getRemoteResource().isFolder());
ISVNInfo info = input.getInfo();
try {
ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
ISVNRemoteResource remoteResource1;
ISVNRemoteResource remoteResource2;
if (isFolder) {
remoteResource1 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
remoteResource2 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
} else {
remoteResource1 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
remoteResource2 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
}
ISVNRemoteResource[] selectedResources = { remoteResource1, remoteResource2 };
DifferencesDialog dialog = new DifferencesDialog(Display.getDefault().getActiveShell(), null, selectedResources, editor.getEditorSite().getPart());
dialog.setFromRevision(Long.toString(node1.getRevision()));
dialog.setToRevision(Long.toString(node2.getRevision()));
dialog.open();
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Compare Revisions", e.getMessage());
}
}
Aggregations