use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class SVNWorkspaceRoot method getProjectName.
/**
* get the project name for the remote folder. The name is either the name of the remote folder or
* the name in .project if this file exists.
*
* @param folder
* @param monitor
* @return
*/
public static String getProjectName(ISVNRemoteFolder folder, IProgressMonitor monitor) throws Exception {
ISVNClientAdapter client = folder.getRepository().getSVNClient();
try {
client.getNotificationHandler().disableLog();
String result = folder.getName();
InputStream is = client.getContent(folder.getUrl().appendPath(".project"), SVNRevision.HEAD);
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
org.w3c.dom.Document doc = db.parse(is);
is.close();
NodeList nl = doc.getDocumentElement().getChildNodes();
for (int j = 0; j < nl.getLength(); ++j) {
Node child = nl.item(j);
if (child instanceof Element && "name".equals(child.getNodeName())) {
Node grandChild = child.getFirstChild();
if (grandChild instanceof Text)
result = ((Text) grandChild).getData();
}
}
return result;
} catch (Exception e) {
throw e;
} finally {
if (client != null) {
client.getNotificationHandler().enableLog();
folder.getRepository().returnSVNClient(client);
}
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter 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.ISVNClientAdapter 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.ISVNClientAdapter 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.ISVNClientAdapter in project subclipse by subclipse.
the class BranchTagAction method run.
public void run() {
BranchTagWizard wizard;
final IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
if (resource == null) {
ISVNRemoteResource[] resources = { remoteResource };
wizard = new BranchTagWizard(resources);
} else {
IResource[] resources = { resource };
wizard = new BranchTagWizard(resources);
}
wizard.setRevisionNumber(node.getRevision());
WizardDialog dialog = new ClosableWizardDialog(Display.getDefault().getActiveShell(), wizard);
if (dialog.open() == WizardDialog.OK) {
final SVNUrl sourceUrl = wizard.getUrl();
final SVNUrl destinationUrl = wizard.getToUrl();
final String message = wizard.getComment();
final SVNRevision revision = wizard.getRevision();
final boolean makeParents = wizard.isMakeParents();
final SVNUrl[] sourceUrls = wizard.getUrls();
final boolean createOnServer = wizard.isCreateOnServer();
final Alias newAlias = wizard.getNewAlias();
final boolean switchAfter = wizard.isSwitchAfterBranchTag();
try {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
if (resource == null) {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
} else {
IResource[] resources = { resource };
BranchTagOperation branchTagOperation = new BranchTagOperation(editor.getEditorSite().getPart(), resources, sourceUrls, destinationUrl, createOnServer, revision, message);
branchTagOperation.setMakeParents(makeParents);
branchTagOperation.setNewAlias(newAlias);
branchTagOperation.switchAfterTagBranchOperation(switchAfter);
branchTagOperation.run();
}
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
}
}
}
Aggregations