Search in sources :

Example 1 with MergeResultsView

use of com.collabnet.subversion.merge.views.MergeResultsView in project subclipse by subclipse.

the class MergeOperation method execute.

protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    monitor.beginTask(getTaskName(), mergedResources.length);
    ArrayList mergeOutputs = new ArrayList();
    for (int i = 0; i < mergedResources.length; i++) {
        try {
            monitor.subTask(mergedResources[i].getName());
            incompleteOutput = null;
            if (mergeOutput == null) {
                incompleteOutput = MergeOutput.getIncompleteMerge(mergedResources[i], svnUrls1[i].toString(), svnUrls2[i].toString());
            }
            if (incompleteOutput == null)
                command = new MergeCommand(mergedResources[i], svnUrls1[i], svnRevision1, svnUrls2[i], svnRevision2, revisions, mergeOutput);
            else {
                if (incompleteOutput.hasUnresolvedConflicts()) {
                    unresolvedConflicts = true;
                    break;
                }
                command = new MergeCommand(mergedResources[i], svnUrls1[i], svnRevision1, svnUrls2[i], svnRevision2, revisions, incompleteOutput);
            }
            command.setPart(getPart());
            command.setForce(force);
            command.setIgnoreAncestry(ignoreAncestry);
            command.setDepth(depth);
            command.setTextConflictHandling(textConflictHandling);
            command.setBinaryConflictHandling(binaryConflictHandling);
            command.setPropertyConflictHandling(propertyConflictHandling);
            command.setTreeConflictHandling(treeConflictHandling);
            command.setRecordOnly(recordOnly);
            command.run(Policy.subMonitorFor(monitor, 1000));
            monitor.worked(1);
            if (recordOnly) {
                MergeOutput mergeOutput = command.getMergeOutput();
                MergeSummaryResult[] summaryResults = { new MergeSummaryResult(MergeSummaryResult.PROPERTY, "Updated", "1") };
                // $NON-NLS-1$ //$NON-NLS-2$
                mergeOutput.setMergeSummaryResults(summaryResults);
                MergeResult[] mergeResults = { new AdaptableMergeResult(" ", "U", " ", mergedResources[i].getLocation().toString(), false) };
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                mergeOutput.setMergeResults(mergeResults);
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(mergedResources[i]);
                if (svnResource != null) {
                    svnResource.refreshStatus();
                }
            }
        } catch (SVNException e) {
            if (e.operationInterrupted()) {
                showCancelledMessage();
            } else {
                collectStatus(e.getStatus());
            }
            abnormalEnd = true;
        }
        MergeOutput mergeOutput = command.getMergeOutput();
        mergeOutputs.add(mergeOutput);
        if (command.isMergeAborted()) {
            mergeOutput.setIncomplete(true);
            mergeOutput.setNormalEnd(true);
            mergeOutput.store();
            abortedMergeOutput = mergeOutput;
            MergeResultsView view = MergeResultsView.getView();
            if (view != null)
                view.refreshAsync(mergeOutput);
            break;
        } else {
            mergeOutput.setIncomplete(false);
            if (!recordOnly && !abnormalEnd) {
                mergeOutput.setNormalEnd(true);
                mergeOutput.store();
                MergeResultsView view = MergeResultsView.getView();
                if (view != null)
                    view.refreshAsync(mergeOutput);
            }
        }
    }
    if (recordOnly) {
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                DialogWizard dialogWizard = new DialogWizard(DialogWizard.COMMIT_MERGEINFO_PROPERTY);
                dialogWizard.setUnblock(unblock);
                MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
                if (dialog.open() == MergeWizardDialog.CANCEL)
                    return;
                CommitAction commitAction = new CommitAction();
                commitAction.setSelectedResources(mergedResources);
                commitAction.run(null);
            }
        });
    } else {
        final MergeOutput[] mergeOutputArray = new MergeOutput[mergeOutputs.size()];
        mergeOutputs.toArray(mergeOutputArray);
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                if (unresolvedConflicts) {
                    DialogWizard dialogWizard = new DialogWizard(DialogWizard.UNRESOLVED_CONFLICTS);
                    dialogWizard.setMergeOutput(incompleteOutput);
                    MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
                    dialog.open();
                } else {
                    if (command.isMergeAborted()) {
                        DialogWizard dialogWizard = new DialogWizard(DialogWizard.MERGE_ABORTED);
                        dialogWizard.setMergeOutput(abortedMergeOutput);
                        dialogWizard.setErrorMessage(command.getErrorMessage());
                        MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
                        dialog.open();
                    }
                }
                if (mergeOutputArray.length > 0 && !abnormalEnd) {
                    DialogWizard dialogWizard = new DialogWizard(DialogWizard.SUMMARY);
                    dialogWizard.setMergeOutputs(mergeOutputArray);
                    dialogWizard.setResumed(resumed);
                    MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
                    dialog.open();
                }
            }
        });
    }
    monitor.done();
}
Also used : ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) MergeResultsView(com.collabnet.subversion.merge.views.MergeResultsView) DialogWizard(com.collabnet.subversion.merge.wizards.DialogWizard) MergeWizardDialog(com.collabnet.subversion.merge.wizards.MergeWizardDialog) CommitAction(org.tigris.subversion.subclipse.ui.actions.CommitAction)

Aggregations

MergeResultsView (com.collabnet.subversion.merge.views.MergeResultsView)1 DialogWizard (com.collabnet.subversion.merge.wizards.DialogWizard)1 MergeWizardDialog (com.collabnet.subversion.merge.wizards.MergeWizardDialog)1 ArrayList (java.util.ArrayList)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 CommitAction (org.tigris.subversion.subclipse.ui.actions.CommitAction)1