use of com.collabnet.subversion.merge.actions.MergeEditConflictsAction in project subclipse by subclipse.
the class MergeResultsView method editConflicts.
private void editConflicts(MergeResult mergeResult) {
IFile resource = (IFile) mergeResult.getResource();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
File conflictNewFile = svnResource.getStatus().getConflictNew();
File conflictOldFile = svnResource.getStatus().getConflictOld();
File conflictWorkingFile = svnResource.getStatus().getConflictWorking();
File mergedFile = new File(resource.getLocation().toString());
if (conflictWorkingFile == null) {
EditConflictsAction editConflictsAction = new EditConflictsAction(resource);
editConflictsAction.run(null);
} else {
MergeEditConflictsAction editConflictsAction = new MergeEditConflictsAction(conflictNewFile, conflictOldFile, conflictWorkingFile, mergedFile, resource.getName(), null);
editConflictsAction.setMergeResult(mergeResult);
editConflictsAction.run(null);
}
} catch (Exception e) {
}
}
use of com.collabnet.subversion.merge.actions.MergeEditConflictsAction in project subclipse by subclipse.
the class SVNConflictResolver method getConflictResolution.
private ConflictResolution getConflictResolution(final SVNConflictDescriptor descrip) {
wait = false;
dialogWizard = null;
ConflictResolution conflictResolution = null;
if (descrip.isTreeConflict() && applyToAllTreeConflictResolution != null) {
conflictResolution = new ConflictResolution(descrip, applyToAllTreeConflictResolution.getResolution());
} else if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property && applyToAllPropertyResolution != null)
conflictResolution = new ConflictResolution(descrip, applyToAllPropertyResolution.getResolution());
else if (descrip.isBinary() && applyToAllBinaryResolution != null)
conflictResolution = new ConflictResolution(descrip, applyToAllBinaryResolution.getResolution());
else if (descrip.getConflictKind() != SVNConflictDescriptor.Kind.property && !descrip.isBinary() && applyToAllTextResolution != null)
conflictResolution = new ConflictResolution(descrip, applyToAllTextResolution.getResolution());
if (conflictResolution == null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
dialogWizard = new DialogWizard(DialogWizard.CONFLICT_HANDLING);
dialogWizard.setConflictDescriptor(descrip);
dialogWizard.setResources(new IResource[] { resource });
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
}
});
while (dialogWizard == null || dialogWizard.getConflictResolution() == null) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// we're still waiting...
}
}
conflictResolution = dialogWizard.getConflictResolution();
if (conflictResolution.isApplyToAll()) {
if (descrip.isTreeConflict()) {
applyToAllTreeConflictResolution = conflictResolution;
} else if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property)
applyToAllPropertyResolution = conflictResolution;
else if (descrip.isBinary())
applyToAllBinaryResolution = conflictResolution;
else
applyToAllTextResolution = conflictResolution;
}
}
try {
if (conflictResolution.getResolution() == ConflictResolution.FILE_EDITOR) {
finished = false;
// resolved = false;
workingTempFile = null;
File pathFile = new File(descrip.getPath());
mergedFile = new File(descrip.getMergedPath());
try {
workingTempFile = createTempFile(pathFile);
copyFile(mergedFile, workingTempFile);
} catch (IOException e) {
e.printStackTrace();
}
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(workingTempFile.getAbsolutePath()));
final IWorkbenchPage page = part.getSite().getPage();
final IEditorInput editorInput = new ExternalFileEditorInput(fileStore);
final String editorId = getEditorId(fileStore);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
// final IEditorPart editorPart = IDE.openEditorOnFileStore(page,
// fileStore);
final IEditorPart editorPart = page.openEditor(editorInput, editorId);
if (editorPart == null) {
resolution = ISVNConflictResolver.Choice.postpone;
// resolved = false;
finished = true;
// finishEditing();
} else {
IPartListener2 closeListener = new IPartListener2() {
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == editorPart) {
finishEditing(descrip);
}
}
public void partActivated(IWorkbenchPartReference partRef) {
}
public void partBroughtToTop(IWorkbenchPartReference partRef) {
}
public void partDeactivated(IWorkbenchPartReference partRef) {
}
public void partHidden(IWorkbenchPartReference partRef) {
}
public void partInputChanged(IWorkbenchPartReference partRef) {
}
public void partOpened(IWorkbenchPartReference partRef) {
}
public void partVisible(IWorkbenchPartReference partRef) {
}
};
page.addPartListener(closeListener);
}
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
while (!finished) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
conflictResolution = new ConflictResolution(descrip, resolution);
if (!conflictResolution.isResolved()) {
if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property)
applyToAllPropertyResolution = null;
else if (descrip.isBinary())
applyToAllBinaryResolution = null;
else
applyToAllTextResolution = null;
}
}
if (conflictResolution.getResolution() == ConflictResolution.CONFLICT_EDITOR) {
File pathFile = new File(descrip.getPath());
File conflictNewFile = new File(descrip.getTheirPath());
File conflictWorkingFile = new File(descrip.getMyPath());
if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property && descrip.getMergedPath() == null) {
try {
final String theirValue = getPropertyValue(conflictNewFile);
final String myValue = getPropertyValue(conflictWorkingFile);
dialogWizard = null;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
dialogWizard = new DialogWizard(DialogWizard.PROPERTY_VALUE_SELECTION);
dialogWizard.setConflictDescriptor(descrip);
dialogWizard.setMyValue(myValue);
dialogWizard.setIncomingValue(theirValue);
dialogWizard.setResources(new IResource[] { resource });
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard);
dialog.open();
}
});
while (dialogWizard == null || dialogWizard.getValueToUse() == null) {
}
String valueToUse = dialogWizard.getValueToUse();
if (!dialogWizard.isConflictResolved()) {
conflictResolution = new ConflictResolution(descrip, ISVNConflictResolver.Choice.postpone);
return conflictResolution;
} else {
mergeTempFile = createTempFile(pathFile);
setPropertyValue(mergeTempFile, valueToUse);
conflictResolution = new ConflictResolution(descrip, ISVNConflictResolver.Choice.chooseMerged);
conflictResolution.setMergedPath(mergeTempFile.getAbsolutePath());
return conflictResolution;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
workingTempFile = null;
mergeTempFile = null;
File mergedFile;
if (descrip.getMergedPath() == null) {
mergedFile = new File(descrip.getPath());
} else {
mergedFile = new File(descrip.getMergedPath());
}
try {
workingTempFile = createTempFile(pathFile);
copyFile(conflictWorkingFile, workingTempFile);
mergeTempFile = createTempFile(pathFile);
copyFile(mergedFile, mergeTempFile);
} catch (IOException e) {
e.printStackTrace();
}
File conflictOldFile = new File(descrip.getBasePath());
final MergeEditConflictsAction editConflictsAction = new MergeEditConflictsAction(conflictNewFile, conflictOldFile, workingTempFile, mergedFile, pathFile.getName(), descrip);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
editConflictsAction.run(null);
}
});
while (editConflictsAction.getMergeConflictsCompareInput() == null || !editConflictsAction.getMergeConflictsCompareInput().isFinished()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
if (editConflictsAction.getMergeConflictsCompareInput().isResolved()) {
// conflictResolution = new ConflictResolution(descrip,
// ISVNConflictResolver.Result.resolved);
conflictResolution = new ConflictResolution(descrip, editConflictsAction.getMergeConflictsCompareInput().getResolution());
} else {
// conflictResolution = new ConflictResolution(descrip,
// ISVNConflictResolver.Result.conflicted);
conflictResolution = new ConflictResolution(descrip, editConflictsAction.getMergeConflictsCompareInput().getResolution());
if (descrip.getConflictKind() == SVNConflictDescriptor.Kind.property)
applyToAllPropertyResolution = null;
else if (descrip.isBinary())
applyToAllBinaryResolution = null;
else
applyToAllTextResolution = null;
try {
copyFile(mergeTempFile, mergedFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (final RuntimeException re) {
conflictResolution = new ConflictResolution(descrip, ISVNConflictResolver.Choice.postpone);
wait = true;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Activator.handleError(Messages.SVNConflictResolver_handleConflictError, re);
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.SVNConflictResolver_handleConflict, Messages.SVNConflictResolver_conflictNotHandled + re.getLocalizedMessage() + Messages.SVNConflictResolver_resolveLater);
re.printStackTrace();
wait = false;
}
});
}
while (wait) {
}
return conflictResolution;
}
Aggregations