use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class SvnWizardCompareMultipleResourcesWithBranchTagPage method getCommonRoot.
private String getCommonRoot() {
ArrayList urlList = new ArrayList();
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
try {
String anUrl = svnResource.getStatus().getUrlString();
if (anUrl != null)
urlList.add(anUrl);
} catch (SVNException e1) {
}
}
urlStrings = new String[urlList.size()];
urlList.toArray(urlStrings);
if (urlStrings.length == 0)
return null;
String urlString = urlStrings[0];
if (urlStrings.length == 1)
return urlString;
String commonRoot = null;
tag1: for (int i = 0; i < urlString.length(); i++) {
String partialPath = urlString.substring(0, i + 1);
if (partialPath.endsWith("/")) {
// $NON-NLS-1$
for (int j = 1; j < urlStrings.length; j++) {
if (!urlStrings[j].startsWith(partialPath))
break tag1;
}
commonRoot = partialPath.substring(0, i);
}
}
compareResources = new CompareResource[resources.length];
for (int i = 0; i < resources.length; i++) {
compareResources[i] = new CompareResource(resources[i], urlStrings[i].substring(commonRoot.length() + 1));
}
return commonRoot;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class BaseFile method getAnnotations.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.ISVNRemoteFile#getAnnotations(org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision)
*/
public ISVNAnnotations getAnnotations(SVNRevision fromRevision, SVNRevision toRevision, boolean includeMergedRevisions, boolean ignoreMimeType) throws TeamException {
ISVNClientAdapter svnClient = getRepository().getSVNClient();
try {
SVNRevision pegRevision = null;
ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
if (localResource != null) {
pegRevision = localResource.getRevision();
}
return svnClient.annotate(localResourceStatus.getFile(), fromRevision, toRevision, pegRevision, ignoreMimeType, includeMergedRevisions);
} catch (SVNClientException e) {
throw new TeamException("Failed in BaseFile.getAnnotations()", e);
} finally {
getRepository().returnSVNClient(svnClient);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class MergeWizardBestPracticesPage method performChecks.
public void performChecks(boolean refreshPage) {
try {
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
needsChecks = false;
localMods = false;
switchedChildren = false;
mixedRevisions = false;
incompleteWorkingCopy = false;
localModsList = new ArrayList();
switchedChildrenList = new ArrayList();
mixedRevisionsList = new ArrayList();
incompleteList = new ArrayList();
IResource[] resources = ((MergeWizard) getWizard()).getResources();
if (resources == null)
return;
monitor.beginTask(Messages.MergeWizardBestPracticesPage_0, resources.length);
for (int i = 0; i < resources.length; i++) {
monitor.subTask(resources[i].getName());
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
ISVNClientAdapter svnClient = null;
try {
svnClient = svnResource.getRepository().getSVNClient();
File fileProject = new File(resources[i].getLocation().toString());
List incompleteInfoList = new ArrayList();
ISVNInfo[] infos = svnClient.getInfo(fileProject, true);
for (int j = 0; j < infos.length; j++) {
if (infos[j].getDepth() != Depth.infinity && infos[j].getDepth() != Depth.unknown) {
incompleteWorkingCopy = true;
incompleteInfoList.add(infos[j].getUrl().toString());
}
}
File file = new File(resources[i].getLocation().toString());
ISVNStatus status = svnClient.getSingleStatus(file);
highestRevision = status.getRevision().getNumber();
ISVNStatus[] statuses = svnClient.getStatus(file, true, true, false, true);
for (int j = 0; j < statuses.length; j++) {
if (statuses[j].getUrl() != null && incompleteInfoList.contains(statuses[j].getUrl().toString())) {
incompleteList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
}
if (statuses[j].getTextStatus().equals(SVNStatusKind.MODIFIED) | statuses[j].getPropStatus().equals(SVNStatusKind.MODIFIED)) {
localMods = true;
localModsList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
}
if (statuses[j].isSwitched()) {
switchedChildren = true;
switchedChildrenList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
}
if (!statuses[j].getTextStatus().equals(SVNStatusKind.EXTERNAL) && !statuses[j].isFileExternal() && statuses[j].getRevision() != null) {
if (!statuses[j].getRevision().equals(status.getRevision())) {
mixedRevisions = true;
if (!mixedRevisionsList.contains(resources[i]))
mixedRevisionsList.add(resources[i]);
if (statuses[j].getRevision().getNumber() > highestRevision) {
highestRevision = statuses[j].getRevision().getNumber();
}
}
}
}
} catch (Exception e) {
Activator.handleError(e);
} finally {
svnResource.getRepository().returnSVNClient(svnClient);
}
monitor.worked(1);
}
monitor.done();
}
});
} catch (Exception e) {
Activator.handleError(e);
}
if (refreshPage)
refreshPage(true, false);
if (localMods || switchedChildren || mixedRevisions || incompleteWorkingCopy) {
setMessage(Messages.MergeWizardBestPracticesPage_notReady);
setPageComplete(false);
} else {
setMessage(Messages.MergeWizardBestPracticesPage_ready);
setPageComplete(true);
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class MergeResultsView method createPartControl.
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.verticalSpacing = 2;
layout.marginWidth = 0;
layout.marginHeight = 2;
parent.setLayout(layout);
treeViewer = new TreeViewer(parent);
treeViewer.setLabelProvider(labelProvider);
treeViewer.setContentProvider(new MergeResultsViewContentProvider());
treeViewer.setUseHashlookup(true);
GridData layoutData = new GridData();
layoutData.grabExcessHorizontalSpace = true;
layoutData.grabExcessVerticalSpace = true;
layoutData.horizontalAlignment = GridData.FILL;
layoutData.verticalAlignment = GridData.FILL;
treeViewer.getControl().setLayoutData(layoutData);
treeViewer.setInput(this);
treeViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
treeConflict = null;
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Object selectedItem = selection.getFirstElement();
MergeResult mergeResult = null;
if (selectedItem instanceof AdaptableMergeResult)
mergeResult = (MergeResult) selectedItem;
if (selectedItem instanceof AdaptableMergeResultsFolder) {
MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) selectedItem;
mergeResult = mergeResultsFolder.getMergeResult();
}
if (mergeResult != null) {
if (mergeResult.getResource() instanceof IFile && mergeResult.isConflicted() && !mergeResult.isResolved()) {
editConflicts(mergeResult);
return;
}
if (mergeResult.getResource() instanceof IFile && mergeResult.hasTreeConflict() && !mergeResult.isTreeConflictResolved()) {
boolean addAddConflict = false;
if (mergeResult.getResource() != null && mergeResult.getResource().exists()) {
treeConflict = getTreeConflict(mergeResult.getResource());
if (treeConflict != null && treeConflict.getDescription() != null && treeConflict.getDescription().contains("local add") && treeConflict.getDescription().contains("incoming add")) {
// $NON-NLS-1$ //$NON-NLS-2$
addAddConflict = true;
}
if (!addAddConflict) {
openAction.run();
}
}
if (!addAddConflict) {
return;
}
}
if (!mergeResult.getAction().equals(MergeResult.ACTION_DELETE)) {
final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(mergeResult.getResource());
if (!localResource.exists()) {
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
try {
if (treeConflict != null) {
if (!localResource.isFolder()) {
SVNConflictDescriptor descriptor = treeConflict.getConflictDescriptor();
SVNConflictVersion rightVersion = descriptor.getSrcRightVersion();
try {
ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), new SVNUrl(rightVersion.getReposURL() + "/" + rightVersion.getPathInRepos()), new SVNRevision.Number(rightVersion.getPegRevision()));
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
CompareUI.openCompareEditorOnPage(compareInput, getSite().getPage());
} catch (Exception e) {
}
}
return;
}
CompareUI.openCompareEditorOnPage(new SVNLocalCompareInput(localResource, SVNRevision.BASE), getSite().getPage());
} catch (SVNException e) {
if (!e.operationInterrupted()) {
Activator.handleError(Messages.MergeResultsView_compareError, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
}
} catch (SVNClientException e) {
Activator.handleError(Messages.MergeResultsView_compareError, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
}
}
});
}
}
}
});
treeViewer.getTree().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean mergeOutputSelected = false;
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
if (iter.next() instanceof MergeOutput) {
mergeOutputSelected = true;
break;
}
}
removeAction.setEnabled(mergeOutputSelected);
}
});
createMenus();
createToolbar();
getSite().setSelectionProvider(treeViewer);
if (Activator.getDefault().getPreferenceStore().getBoolean(CONFLICTS_ONLY_PREFERENCE))
setContentDescription(Messages.MergeResultsView_conflictsMode);
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class ShowRemoteHistoryAction method getSelectedRemoteResources.
protected ISVNRemoteResource[] getSelectedRemoteResources() {
MergeOutput mergeOutput = null;
ISVNRemoteResource remoteResource = null;
Iterator iter = fSelection.iterator();
while (iter.hasNext()) {
Object object = iter.next();
if (object instanceof MergeResult) {
MergeResult mergeResult = (MergeResult) object;
IResource resource = mergeResult.getResource();
mergeOutput = mergeResult.getMergeOutput();
MergeOptions mergeOptions = mergeOutput.getMergeOptions();
SVNUrl svnUrl = mergeOptions.getFromUrl();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
String resourceSubString = resource.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
if (!resourceSubString.startsWith("/"))
// $NON-NLS-1$ //$NON-NLS-2$
resourceSubString = "/" + resourceSubString;
SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
resourceSubString.replaceAll("\\\\", "/"));
remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
} catch (Exception e) {
Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
}
break;
}
if (object instanceof MergeResultsFolder) {
MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) object;
IContainer folder = mergeResultsFolder.getFolder();
mergeOutput = mergeResultsFolder.getMergeOutput();
MergeOptions mergeOptions = mergeOutput.getMergeOptions();
SVNUrl svnUrl = mergeOptions.getFromUrl();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(folder);
try {
String resourceSubString = folder.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
if (!resourceSubString.startsWith("/"))
// $NON-NLS-1$ //$NON-NLS-2$
resourceSubString = "/" + resourceSubString;
SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
resourceSubString.replaceAll("\\\\", "/"));
remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
} catch (Exception e) {
Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
}
break;
}
}
if (remoteResource != null) {
ISVNRemoteResource[] selectedResource = { remoteResource };
SVNRevision.Number startRevision = null;
try {
startRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getLowerRevision()));
} catch (ParseException e) {
}
SVNRevision.Number endRevision = null;
if (mergeOutput.getUpperRevision() > 0) {
try {
endRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getUpperRevision()));
} catch (ParseException e) {
}
}
HistorySearchViewerFilter historySearchViewerFilter = new HistorySearchViewerFilter(null, null, null, null, true, startRevision, endRevision);
SVNHistoryPage.setHistorySearchViewerFilter(historySearchViewerFilter);
return selectedResource;
}
return new ISVNRemoteResource[0];
}
Aggregations