use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class RevisionDetailsAction method run.
public void run() {
remoteResource = null;
logEntry = null;
includeTags = SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_SHOW_TAGS_IN_REMOTE);
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
try {
RevisionGraphEditorInput input = (RevisionGraphEditorInput) editor.getEditorInput();
ISVNInfo info = input.getInfo();
ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
remoteResource = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node.getPath()), new SVNRevision.Number(node.getRevision()));
AliasManager tagManager = null;
if (includeTags)
tagManager = new AliasManager(remoteResource.getUrl());
SVNRevision pegRevision = new SVNRevision.Number(node.getRevision());
SVNRevision revisionStart = new SVNRevision.Number(node.getRevision());
SVNRevision revisionEnd = new SVNRevision.Number(node.getRevision());
GetLogsCommand logCmd = new GetLogsCommand(remoteResource, pegRevision, revisionStart, revisionEnd, false, 0, tagManager, true);
logCmd.run(null);
ILogEntry[] logEntries = logCmd.getLogEntries();
if (logEntries != null && logEntries.length > 0) {
logEntry = logEntries[0];
}
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Revision Info", e.getMessage());
}
}
});
if (logEntry != null) {
ShowRevisionsDialog dialog = new ShowRevisionsDialog(Display.getDefault().getActiveShell(), logEntry, remoteResource, includeTags, null);
dialog.setTitle("Revision Info");
dialog.setSelectFirst(true);
dialog.open();
}
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class Cache method refresh.
public void refresh(List refreshedNodes, ISVNInfo info, IProgressMonitor monitor, int unitWorked) {
ISVNLogMessageCallback callback = new ISVNLogMessageCallback() {
public void singleMessage(ISVNLogMessage message) {
update(message, true);
}
};
revisionsTempFile = new File(root, "revisionsTemp");
logMessagesTempFile = new File(root, "logMessagesTemp");
revisionsTempFile.delete();
logMessagesTempFile.delete();
try {
revisionsTempFile.createNewFile();
logMessagesTempFile.createNewFile();
} catch (IOException e) {
Activator.handleError(e);
}
List revisions = new ArrayList();
Iterator iter = refreshedNodes.iterator();
while (iter.hasNext()) {
Node node = (Node) iter.next();
revisions.add(Long.toString(node.getRevision()));
}
startTempUpdate();
RandomAccessFile file = null;
ISVNClientAdapter client = null;
try {
client = SVNProviderPlugin.getPlugin().getSVNClient();
file = new RandomAccessFile(logMessagesFile, "r");
int revInt = new Long(getLatestRevision()).intValue();
while (file.getFilePointer() < file.length()) {
ISVNLogMessage lm = readNext(file, true);
level = 0;
int index = revisions.indexOf(lm.getRevision().toString());
if (index == -1) {
update(lm, true);
if (lm.hasChildren() && lm.getChildMessages() != null) {
updateChildren(lm, true);
}
monitor.worked(unitWorked / revInt);
} else {
Node updateNode = (Node) refreshedNodes.get(index);
SVNRevision updateRevision = new SVNRevision.Number(updateNode.getRevision());
client.getLogMessages(new SVNUrl(info.getRepository() + updateNode.getPath()), updateRevision, updateRevision, updateRevision, false, true, 0, true, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
monitor.worked(unitWorked);
// updateRevision = (ISVNLogMessage)refreshedMessages.get(index);
// monitor.worked(unitWorked);
}
if (monitor.isCanceled()) {
break;
}
}
} catch (Exception e) {
} finally {
closeFile(file);
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
finishTempUpdate();
if (monitor.isCanceled()) {
revisionsTempFile.delete();
logMessagesTempFile.delete();
return;
}
revisionsFile.delete();
logMessagesFile.delete();
revisionsTempFile.renameTo(revisionsFile);
logMessagesTempFile.renameTo(logMessagesFile);
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class Util method getUrlForRevision.
public static SVNUrl getUrlForRevision(ISVNRemoteResource resource, SVNRevision.Number revision, IProgressMonitor pm) throws SVNException {
SVNUrl url = resource.getUrl();
SVNRevision revisionStart = new SVNRevision.Number(revision.getNumber());
GetLogsCommand getLogsCommand = new GetLogsCommand(resource, SVNRevision.HEAD, revisionStart, SVNRevision.HEAD, false, 0, null, true);
getLogsCommand.run(pm);
ILogEntry[] logEntries = getLogsCommand.getLogEntries();
String path = resource.getRepositoryRelativePath().replaceAll("%20", " ");
for (int i = logEntries.length - 1; i > -1; i--) {
ILogEntry logEntry = logEntries[i];
if (!logEntry.getRevision().equals(revision)) {
LogEntryChangePath[] changePaths = logEntry.getLogEntryChangePaths();
for (LogEntryChangePath changePath : changePaths) {
if (changePath.getPath().equals(path) && changePath.getCopySrcPath() != null) {
try {
path = changePath.getCopySrcPath();
url = new SVNUrl(resource.getRepository().getRepositoryRoot().toString() + changePath.getCopySrcPath());
} catch (MalformedURLException e) {
}
}
}
}
}
return url;
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class ResolveTreeConflictWizard method performFinish.
public boolean performFinish() {
if (mainPage.getReplace()) {
mergeException = null;
try {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
try {
svnClient = svnResource.getRepository().getSVNClient();
File file = svnResource.getResource().getLocation().toFile();
svnClient.remove(new File[] { file }, true);
SVNUrl url = new SVNUrl(treeConflict.getConflictDescriptor().getSrcRightVersion().getReposURL() + "/" + treeConflict.getConflictDescriptor().getSrcRightVersion().getPathInRepos());
SVNRevision revision;
int index = treeConflict.getConflictDescriptor().getSrcRightVersion().toString().lastIndexOf(// $NON-NLS-1$
"@");
if (index == -1) {
revision = SVNRevision.HEAD;
} else {
long number = Long.parseLong(treeConflict.getConflictDescriptor().getSrcRightVersion().toString().substring(index + 1));
revision = new SVNRevision.Number(number);
}
svnClient.copy(url, file, revision);
} catch (Exception e) {
mergeException = e;
}
}
});
if (mergeException != null) {
SVNUIPlugin.log(IStatus.ERROR, mergeException.getMessage(), mergeException);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_2, mergeException.getMessage());
return false;
}
svnResource.getResource().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_2, e.getMessage());
return false;
}
return true;
}
compare = mainPage.getCompare();
if (mainPage.getMergeFromRepository()) {
try {
final SVNUrl url = new SVNUrl(mainPage.getMergeFromUrl());
SVNRevision revision1;
if (treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision() == treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision())
revision1 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision() - 1);
else
revision1 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision());
final SVNRevision revision2 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision());
if (treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision() == treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision())
revision1 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision() - 1);
final IResource mergeTarget = mainPage.getMergeTarget();
final SVNRevision rev1 = revision1;
svnClient = svnResource.getRepository().getSVNClient();
mergeException = null;
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
try {
mergePath = mergeTarget.getLocation().toFile();
svnClient.merge(url, rev1, url, revision2, mergePath, true, false, false, true);
try {
// Refresh the resource after merge
if (mergeTarget.getParent() != null)
mergeTarget.getParent().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
else
mergeTarget.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e1) {
}
} catch (Exception e) {
mergeException = e;
}
}
});
if (mergeException != null) {
SVNUIPlugin.log(IStatus.ERROR, mergeException.getMessage(), mergeException);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_mergeError, mergeException.getMessage());
return false;
}
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_mergeError, e.getMessage());
return false;
} finally {
svnResource.getRepository().returnSVNClient(svnClient);
}
}
if (mainPage.getCompare()) {
if (mainPage.getCompareResource2() == null) {
ISVNLocalResource svnCompareResource = mainPage.getSvnCompareResource();
if (svnCompareResource == null)
svnCompareResource = svnResource;
ISVNRemoteResource remoteResource = mainPage.getRemoteResource();
try {
// $NON-NLS-1$ //$NON-NLS-2$
File file = File.createTempFile("revision", ".diff");
file.deleteOnExit();
File path = new File(svnCompareResource.getResource().getLocation().toString());
SVNUrl toUrl = remoteResource.getUrl();
SVNRevision toRevision = remoteResource.getRevision();
ShowDifferencesAsUnifiedDiffOperationWC operation = new ShowDifferencesAsUnifiedDiffOperationWC(targetPart, path, toUrl, toRevision, file);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(svnCompareResource, remoteResource);
compareInput.setDiffOperation(operation);
CompareUI.openCompareEditorOnPage(compareInput, targetPart.getSite().getPage());
CompareCloseListener closeListener = new CompareCloseListener(Messages.ResolveTreeConflictWizard_compare + svnCompareResource.getName() + // $NON-NLS-1$
" <workspace>");
targetPart.getSite().getPage().addPartListener(closeListener);
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_compareError, e.getMessage());
return false;
}
} else {
ISelection selection = new IStructuredSelection() {
public Object getFirstElement() {
return mainPage.getCompareResource1();
}
public Iterator iterator() {
return toList().iterator();
}
public int size() {
return 2;
}
public Object[] toArray() {
IResource[] compareResources = { mainPage.getCompareResource1(), mainPage.getCompareResource2() };
return compareResources;
}
public List toList() {
List compareList = new ArrayList();
compareList.add(mainPage.getCompareResource1());
compareList.add(mainPage.getCompareResource2());
return compareList;
}
public boolean isEmpty() {
return false;
}
};
CompareAction compareAction = new CompareAction();
compareAction.setActivePart(null, targetPart);
IAction action = new Action() {
};
compareAction.selectionChanged(action, selection);
compareAction.run(selection);
CompareCloseListener closeListener = new CompareCloseListener(Messages.ResolveTreeConflictWizard_compare2 + mainPage.getCompareResource1().getName() + "' - '" + mainPage.getCompareResource2().getName() + // $NON-NLS-1$ //$NON-NLS-2$
"')");
targetPart.getSite().getPage().addPartListener(closeListener);
}
}
if (mainPage.getRevertResource() != null) {
revertException = null;
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
try {
IResource[] revertResources = { mainPage.getRevertResource() };
RevertResourcesCommand revertCommand = new RevertResourcesCommand(svnResource.getWorkspaceRoot(), revertResources);
revertCommand.run(new NullProgressMonitor());
} catch (Exception e) {
revertException = e;
}
}
});
if (revertException != null) {
SVNUIPlugin.log(IStatus.ERROR, revertException.getMessage(), revertException);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_revertError, revertException.getMessage());
return false;
}
}
if (mainPage.getDeleteResource() != null) {
try {
mainPage.getDeleteResource().delete(true, new NullProgressMonitor());
} catch (CoreException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_deleteError, e.getMessage());
return false;
}
}
if (mainPage.getMarkResolved() || mainPage.refreshConflicts()) {
try {
if (mainPage.getMarkResolved()) {
IResource[] resolvedResources = { treeConflict.getResource() };
ResolveOperation resolveOperation = new ResolveOperation(targetPart, resolvedResources, ISVNConflictResolver.Choice.chooseMerged) {
protected boolean canRunAsJob() {
return false;
}
};
resolveOperation.run();
}
if (mainPage.refreshConflicts()) {
IResource[] refreshResources = { svnResource.getResource() };
TreeConflictsView.refresh(refreshResources);
}
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
MessageDialog.openError(getShell(), Messages.ResolveTreeConflictWizard_markResolvedError, e.getMessage());
return false;
}
}
return true;
}
use of org.tigris.subversion.svnclientadapter.SVNRevision in project subclipse by subclipse.
the class ResolveTreeConflictWizardMainPage method getRemoteResource.
private void getRemoteResource(ResolveTreeConflictWizard wizard, final SVNTreeConflict treeConflict) {
ISVNRepositoryLocation repository = wizard.getSvnResource().getRepository();
SVNRevision revision = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision());
try {
SVNUrl url = new SVNUrl(treeConflict.getConflictDescriptor().getSrcRightVersion().getReposURL() + "/" + treeConflict.getConflictDescriptor().getSrcRightVersion().getPathInRepos());
GetRemoteResourceCommand command = new GetRemoteResourceCommand(repository, url, revision);
command.run(new NullProgressMonitor());
remoteResource = command.getRemoteResource();
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
Aggregations