use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class GetLogsCommand method run.
/**
* execute the command
*
* @param aMonitor
* @throws SVNException
*/
public void run(IProgressMonitor aMonitor) throws SVNException {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
logEntries = null;
IProgressMonitor monitor = Policy.monitorFor(aMonitor);
// $NON-NLS-1$
monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100);
ISVNLogMessage[] logMessages;
try {
if (callback == null) {
logMessages = remoteResource.getLogMessages(pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions);
} else {
repository = remoteResource.getRepository();
svnClient = repository.getSVNClient();
if (remoteResource instanceof BaseResource) {
boolean logMessagesRetrieved = false;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(remoteResource.getResource());
if (svnResource != null) {
LocalResourceStatus status = svnResource.getStatus();
if (status != null && status.isCopied()) {
ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
SVNUrl copiedFromUrl = info.getCopyUrl();
if (copiedFromUrl != null) {
svnClient.getLogMessages(copiedFromUrl, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
logMessagesRetrieved = true;
GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(remoteResource.getRepository(), copiedFromUrl, SVNRevision.HEAD);
getRemoteResourceCommand.run(null);
remoteResource = getRemoteResourceCommand.getRemoteResource();
}
}
}
if (!logMessagesRetrieved)
svnClient.getLogMessages(((BaseResource) remoteResource).getFile(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
} else {
svnClient.getLogMessages(remoteResource.getUrl(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
}
logMessages = callback.getLogMessages();
}
if (remoteResource.isFolder()) {
logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFolder) remoteResource, logMessages, getTags(logMessages));
} else {
logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFile) remoteResource, logMessages, getTags(logMessages), getUrls(logMessages));
}
} catch (Exception e) {
throw SVNException.wrapException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
monitor.done();
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNRepositoryLocation method getRemoteFile.
/*
* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.ISVNRepositoryLocation#getRemoteFile(org.tigris.subversion.svnclientadapter.SVNUrl)
*/
public ISVNRemoteFile getRemoteFile(SVNUrl url) throws SVNException {
ISVNClientAdapter svnClient = getSVNClient();
ISVNInfo info = null;
try {
if (this.getRepositoryRoot().equals(url))
return new RemoteFile(this, url, SVNRevision.HEAD);
else
info = svnClient.getInfo(url, SVNRevision.HEAD, SVNRevision.HEAD);
} catch (SVNClientException e) {
throw new SVNException("Can't get latest remote resource for " + url);
}
if (// no remote file
info == null)
// no remote file
return null;
else {
return new RemoteFile(// we don't know its parent
null, this, url, SVNRevision.HEAD, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNHistoryPage method getGetContentsAction.
// get contents Action (context menu)
private IAction getGetContentsAction() {
if (getContentsAction == null) {
getContentsAction = getContextMenuAction(Policy.bind("HistoryView.getContentsAction"), new // $NON-NLS-1$
IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) selection;
ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
monitor.beginTask(null, 100);
try {
if (remoteFile != null) {
if (confirmOverwrite()) {
if (remoteFile instanceof RemoteResource) {
if (resource != null) {
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
((RemoteResource) remoteFile).setPegRevision(localResource.getRevision());
} else {
((RemoteResource) remoteFile).setPegRevision(SVNRevision.HEAD);
}
}
InputStream in = ((IResourceVariant) remoteFile).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
IFile file = (IFile) resource;
file.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
}
}
} catch (TeamException e) {
throw new CoreException(e.getStatus());
} finally {
monitor.done();
}
}
});
PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION);
}
return getContentsAction;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class SVNHistoryPage method getUpdateToRevisionAction.
// update to the selected revision (context menu)
private IAction getUpdateToRevisionAction() {
if (updateToRevisionAction == null) {
updateToRevisionAction = getContextMenuAction(Policy.bind("HistoryView.getRevisionAction"), new // $NON-NLS-1$
IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) selection;
ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
try {
if (remoteFile != null) {
if (confirmOverwrite()) {
IFile file = (IFile) resource;
new ReplaceOperation(getSite().getPage().getActivePart(), file, remoteFile.getLastChangedRevision()).run(monitor);
historyTableProvider.setRemoteResource(remoteFile);
historyTableProvider.setProjectProperties(ProjectProperties.getProjectProperties(resource));
Display.getDefault().asyncExec(new Runnable() {
public void run() {
tableHistoryViewer.refresh();
}
});
}
}
} catch (InvocationTargetException e) {
throw new CoreException(new SVNStatus(IStatus.ERROR, 0, e.getMessage()));
} catch (InterruptedException e) {
// Cancelled by user
}
}
});
PlatformUI.getWorkbench().getHelpSystem().setHelp(updateToRevisionAction, IHelpContextIds.GET_FILE_REVISION_ACTION);
}
return updateToRevisionAction;
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.
the class RepositoriesView method handleDoubleClick.
/**
* The mouse has been double-clicked in the tree, perform appropriate behaviour.
*/
private void handleDoubleClick(DoubleClickEvent e) {
// Only act on single selection
ISelection selection = e.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structured = (IStructuredSelection) selection;
if (structured.size() == 1) {
Object first = structured.getFirstElement();
if (first instanceof ISVNRemoteFile) {
// It's a file, open it.
openAction.selectionChanged(null, selection);
openAction.run(null);
} else {
// Try to expand/contract
treeViewer.setExpandedState(first, !treeViewer.getExpandedState(first));
}
}
}
}
Aggregations