use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class MergeCommand method run.
public void run(IProgressMonitor monitor) throws SVNException {
mergeAborted = false;
MergeListener mergeListener = null;
ISVNClientAdapter svnClient = null;
ISVNRepositoryLocation repository = null;
try {
monitor.beginTask(null, 100);
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
SVNConflictResolver conflictResolver = new SVNConflictResolver(resource, textConflictHandling, binaryConflictHandling, propertyConflictHandling, treeConflictHandling);
conflictResolver.setPart(part);
svnClient.addConflictResolutionCallback(conflictResolver);
MergeOptions mergeOptions = new MergeOptions();
mergeOptions.setFromUrl(svnUrl1);
mergeOptions.setFromRevision(svnRevision1);
mergeOptions.setToUrl(svnUrl2);
mergeOptions.setToRevision(svnRevision2);
mergeOptions.setRevisions(revisions);
mergeOptions.setForce(force);
mergeOptions.setIgnoreAncestry(ignoreAncestry);
mergeOptions.setDepth(depth);
mergeListener = new MergeListener(resource, mergeOptions, conflictResolver, mergeOutput);
svnClient.addNotifyListener(mergeListener);
svnClient.addNotifyListener(operationResourceCollector);
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor));
monitor.subTask(resource.getName());
File file = resource.getLocation().toFile();
if (revisions == null) {
svnClient.merge(svnUrl1, svnRevision1, svnUrl2, svnRevision2, file, force, depth, false, ignoreAncestry, recordOnly);
} else {
SVNUrlWithPegRevision svnUrlWithPegRevision = new SVNUrlWithPegRevision(svnUrl1);
SVNRevision pegRevision = svnUrlWithPegRevision.getPegRevision();
if (pegRevision == null)
pegRevision = SVNRevision.HEAD;
svnClient.merge(svnUrlWithPegRevision.getUrl(), pegRevision, revisions, file, force, depth, ignoreAncestry, false, recordOnly);
}
monitor.worked(100);
} catch (SVNClientException e) {
if (e.getAprError() == SVNClientException.MERGE_CONFLICT) {
mergeAborted = true;
errorMessage = // $NON-NLS-1$ //$NON-NLS-2$
e.getCause().getLocalizedMessage().replaceAll("\n", " ");
} else
throw SVNException.wrapException(e);
} finally {
if (mergeListener != null)
mergeOutput = mergeListener.getMergeOutput();
Set<IResource> operationResources = operationResourceCollector.getOperationResources();
OperationManager.getInstance().endOperation(true, operationResources);
monitor.done();
svnClient.removeNotifyListener(mergeListener);
svnClient.removeNotifyListener(operationResourceCollector);
svnClient.addConflictResolutionCallback(null);
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class BranchTagWizardCopyPage method showLog.
private void showLog() {
ISVNRemoteResource remoteResource = null;
if (((BranchTagWizard) getWizard()).multipleSelections()) {
ISVNRepositoryLocation repository = null;
if (resource == null)
repository = this.remoteResource.getRepository();
else
repository = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository();
try {
remoteResource = repository.getRemoteFile(new SVNUrl(((BranchTagWizard) getWizard()).getCommonRoot()));
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
} else {
if (resource == null)
remoteResource = this.remoteResource;
else {
try {
remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getRemoteFile(((BranchTagWizard) getWizard()).getUrl());
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + ((BranchTagWizard) getWizard()).getUrlText());
return;
}
}
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
setPageComplete(canFinish());
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class BranchTagWizardCopyPage method getSvnExternalsProperties.
private boolean getSvnExternalsProperties() {
List<SVNExternal> externalsList = new ArrayList<SVNExternal>();
ISVNClientAdapter svnClient = null;
ISVNRepositoryLocation repository = null;
try {
repository = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository();
svnClient = repository.getSVNClient();
IResource[] resources = ((BranchTagWizard) getWizard()).getResources();
for (IResource res : resources) {
ISVNProperty[] properties = svnClient.getProperties(res.getLocation().toFile(), true);
for (ISVNProperty property : properties) {
if (property.getName().equals(Policy.bind("BranchTagWizardCopyPage.8"))) {
// $NON-NLS-1$
// $NON-NLS-1$
String[] propertyLines = property.getValue().split("\\n");
for (String propertyLine : propertyLines) {
SVNExternal svnExternal = new SVNExternal(property.getFile(), propertyLine);
externalsList.add(svnExternal);
}
}
}
}
} catch (Exception e) {
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
svnExternals = new SVNExternal[externalsList.size()];
externalsList.toArray(svnExternals);
return externalsList.size() > 0;
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class CheckoutWizardSelectionPage method refreshViewerNode.
protected void refreshViewerNode() {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object object = iter.next();
if (object instanceof ISVNRepositoryLocation)
((ISVNRepositoryLocation) object).refreshRootFolder();
if (object instanceof ISVNRemoteFolder)
((ISVNRemoteFolder) object).refresh();
treeViewer.refresh(object);
}
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class CheckoutWizardSelectionPage method createControl.
public void createControl(Composite parent) {
Composite outerContainer = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
outerContainer.setLayout(layout);
outerContainer.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
treeViewer = new TreeViewer(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
RepositoryContentProvider contentProvider = new RepositoryContentProvider();
treeViewer.setContentProvider(contentProvider);
treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
treeViewer.setLabelProvider(new WorkbenchLabelProvider());
treeViewer.setInput(repositoryLocation);
GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
data.heightHint = LIST_HEIGHT_HINT;
data.widthHint = LIST_WIDTH_HINT;
treeViewer.getControl().setLayoutData(data);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
CheckoutWizard wizard = (CheckoutWizard) getWizard();
ArrayList folderArray = new ArrayList();
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object object = iter.next();
if (object instanceof ISVNRemoteFolder || object instanceof ISVNRepositoryLocation) {
if (object instanceof ISVNRepositoryLocation)
folderArray.add(((ISVNRepositoryLocation) object).getRootFolder());
else
folderArray.add(object);
}
}
ISVNRemoteFolder[] remoteFolders = new ISVNRemoteFolder[folderArray.size()];
folderArray.toArray(remoteFolders);
wizard.setRemoteFolders(remoteFolders);
setPageComplete(!treeViewer.getSelection().isEmpty());
}
});
final Action refreshAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
ISVNUIConstants.IMG_REFRESH)) {
public void run() {
refreshViewerNode();
}
};
MenuManager menuMgr = new MenuManager();
Tree tree = treeViewer.getTree();
Menu menu = menuMgr.createContextMenu(tree);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(refreshAction);
}
});
menuMgr.setRemoveAllWhenShown(true);
tree.setMenu(menu);
// $NON-NLS-1$
setMessage(Policy.bind("CheckoutWizardSelectionPage.text"));
setControl(outerContainer);
}
Aggregations