Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java226
1 files changed, 113 insertions, 113 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java
index f30286846..5a29fe4ea 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java
@@ -79,11 +79,11 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
* @param type the type of synchronization (ONE_WAY or TWO_WAY)
* @param deltaTree the sync info tree that contains all out-of-sync resources
*/
- protected MergeContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree deltaTree) {
- super(manager, type, deltaTree);
- }
+ protected MergeContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree deltaTree) {
+ super(manager, type, deltaTree);
+ }
- @Override
+ @Override
public void reject(final IDiff[] diffs, IProgressMonitor monitor) throws CoreException {
run(monitor1 -> {
for (int i = 0; i < diffs.length; i++) {
@@ -91,9 +91,9 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
reject(node, monitor1);
}
}, getMergeRule(diffs), IResource.NONE, monitor);
- }
+ }
- @Override
+ @Override
public void markAsMerged(final IDiff[] nodes, final boolean inSyncHint, IProgressMonitor monitor) throws CoreException {
run(monitor1 -> {
for (int i = 0; i < nodes.length; i++) {
@@ -101,9 +101,9 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
markAsMerged(node, inSyncHint, monitor1);
}
}, getMergeRule(nodes), IResource.NONE, monitor);
- }
+ }
- @Override
+ @Override
public IStatus merge(final IDiff[] deltas, final boolean force, IProgressMonitor monitor) throws CoreException {
final List<IFile> failedFiles = new ArrayList<>();
run(monitor1 -> {
@@ -129,7 +129,7 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
} else {
return new MergeStatus(TeamPlugin.ID, Messages.MergeContext_0, failedFiles.toArray(new IFile[failedFiles.size()]));
}
- }
+ }
@Override
public IStatus merge(IDiff diff, boolean ignoreLocalChanges, IProgressMonitor monitor) throws CoreException {
@@ -156,30 +156,30 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
}
return Status.OK_STATUS;
}
- if (diff instanceof IThreeWayDiff && !ignoreLocalChanges && getMergeType() == THREE_WAY) {
+ if (diff instanceof IThreeWayDiff && !ignoreLocalChanges && getMergeType() == THREE_WAY) {
IThreeWayDiff twDelta = (IThreeWayDiff) diff;
- int direction = twDelta.getDirection();
- if (direction == IThreeWayDiff.OUTGOING) {
- // There's nothing to do so return OK
- return Status.OK_STATUS;
- }
- if (direction == IThreeWayDiff.INCOMING) {
- // Just copy the stream since there are no conflicts
- performReplace(diff, monitor);
- return Status.OK_STATUS;
- }
+ int direction = twDelta.getDirection();
+ if (direction == IThreeWayDiff.OUTGOING) {
+ // There's nothing to do so return OK
+ return Status.OK_STATUS;
+ }
+ if (direction == IThreeWayDiff.INCOMING) {
+ // Just copy the stream since there are no conflicts
+ performReplace(diff, monitor);
+ return Status.OK_STATUS;
+ }
// direction == SyncInfo.CONFLICTING
- int type = twDelta.getKind();
- if (type == IDiff.REMOVE) {
- makeInSync(diff, monitor);
- return Status.OK_STATUS;
- }
+ int type = twDelta.getKind();
+ if (type == IDiff.REMOVE) {
+ makeInSync(diff, monitor);
+ return Status.OK_STATUS;
+ }
// type == SyncInfo.CHANGE
IResourceDiff remoteChange = (IResourceDiff)twDelta.getRemoteChange();
IFileRevision remote = null;
- if (remoteChange != null) {
- remote = remoteChange.getAfterState();
- }
+ if (remoteChange != null) {
+ remote = remoteChange.getAfterState();
+ }
if (remote == null || !getLocalFile(diff).exists()) {
// Nothing we can do so return a conflict status
// TODO: Should we handle the case where the local and remote have the same contents for a conflicting addition?
@@ -187,11 +187,11 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
}
// We have a conflict, a local, base and remote so we can do
// a three-way merge
- return performThreeWayMerge(twDelta, monitor);
- } else {
- performReplace(diff, monitor);
- return Status.OK_STATUS;
- }
+ return performThreeWayMerge(twDelta, monitor);
+ } else {
+ performReplace(diff, monitor);
+ return Status.OK_STATUS;
+ }
}
@@ -236,70 +236,70 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
status = new MergeStatus(status.getPlugin(), status.getMessage(), new IFile[]{file});
}
result[0] = status;
- } finally {
- disposeTempOutputStream(file, os);
- }
- monitor1.done();
+ } finally {
+ disposeTempOutputStream(file, os);
+ }
+ monitor1.done();
}, getMergeRule(diff), IWorkspace.AVOID_UPDATE, monitor);
return result[0];
}
- private void disposeTempOutputStream(IFile file, OutputStream output) {
- if (output instanceof ByteArrayOutputStream)
- return;
- // We created a temporary file so we need to clean it up
- try {
- // First make sure the output stream is closed
- // so that file deletion will not fail because of that.
- if (output != null)
- output.close();
- } catch (IOException e) {
- // Ignore
- }
- File tmpFile = getTempFile(file);
- if (tmpFile.exists())
- tmpFile.delete();
- }
+ private void disposeTempOutputStream(IFile file, OutputStream output) {
+ if (output instanceof ByteArrayOutputStream)
+ return;
+ // We created a temporary file so we need to clean it up
+ try {
+ // First make sure the output stream is closed
+ // so that file deletion will not fail because of that.
+ if (output != null)
+ output.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ File tmpFile = getTempFile(file);
+ if (tmpFile.exists())
+ tmpFile.delete();
+ }
- private OutputStream getTempOutputStream(IFile file) throws CoreException {
- File tmpFile = getTempFile(file);
- if (tmpFile.exists())
- tmpFile.delete();
- File parent = tmpFile.getParentFile();
- if (!parent.exists())
- parent.mkdirs();
- try {
- return new BufferedOutputStream(new FileOutputStream(tmpFile));
- } catch (FileNotFoundException e) {
- TeamPlugin.log(IStatus.ERROR, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e); //$NON-NLS-1$
- return new ByteArrayOutputStream();
- }
- }
+ private OutputStream getTempOutputStream(IFile file) throws CoreException {
+ File tmpFile = getTempFile(file);
+ if (tmpFile.exists())
+ tmpFile.delete();
+ File parent = tmpFile.getParentFile();
+ if (!parent.exists())
+ parent.mkdirs();
+ try {
+ return new BufferedOutputStream(new FileOutputStream(tmpFile));
+ } catch (FileNotFoundException e) {
+ TeamPlugin.log(IStatus.ERROR, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e); //$NON-NLS-1$
+ return new ByteArrayOutputStream();
+ }
+ }
- private InputStream getTempInputStream(IFile file, OutputStream output) throws CoreException {
- if (output instanceof ByteArrayOutputStream) {
- ByteArrayOutputStream baos = (ByteArrayOutputStream) output;
- return new ByteArrayInputStream(baos.toByteArray());
- }
- // We created a temporary file so we need to open an input stream on it
- try {
- // First make sure the output stream is closed
- if (output != null)
- output.close();
- } catch (IOException e) {
- // Ignore
- }
- File tmpFile = getTempFile(file);
- try {
- return new BufferedInputStream(new FileInputStream(tmpFile));
- } catch (FileNotFoundException e) {
- throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IMergeStatus.INTERNAL_ERROR, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e));
- }
- }
+ private InputStream getTempInputStream(IFile file, OutputStream output) throws CoreException {
+ if (output instanceof ByteArrayOutputStream) {
+ ByteArrayOutputStream baos = (ByteArrayOutputStream) output;
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
+ // We created a temporary file so we need to open an input stream on it
+ try {
+ // First make sure the output stream is closed
+ if (output != null)
+ output.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ File tmpFile = getTempFile(file);
+ try {
+ return new BufferedInputStream(new FileInputStream(tmpFile));
+ } catch (FileNotFoundException e) {
+ throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IMergeStatus.INTERNAL_ERROR, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e));
+ }
+ }
- private File getTempFile(IFile file) {
- return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ private File getTempFile(IFile file) {
+ return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
private IFile getLocalFile(IDiff delta) {
return ResourcesPlugin.getWorkspace().getRoot().getFile(delta.getPath());
@@ -321,31 +321,31 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
* a progress monitor
* @throws CoreException
*/
- protected void performReplace(final IDiff diff, IProgressMonitor monitor) throws CoreException {
- IResourceDiff d;
- IFile file = getLocalFile(diff);
- IFileRevision remote = null;
- if (diff instanceof IResourceDiff) {
- d = (IResourceDiff) diff;
- remote = d.getAfterState();
- } else {
- d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange();
- if (d != null)
- remote = d.getAfterState();
- }
- if (d == null) {
- d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange();
- if (d != null)
- remote = d.getBeforeState();
- }
+ protected void performReplace(final IDiff diff, IProgressMonitor monitor) throws CoreException {
+ IResourceDiff d;
+ IFile file = getLocalFile(diff);
+ IFileRevision remote = null;
+ if (diff instanceof IResourceDiff) {
+ d = (IResourceDiff) diff;
+ remote = d.getAfterState();
+ } else {
+ d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange();
+ if (d != null)
+ remote = d.getAfterState();
+ }
+ if (d == null) {
+ d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange();
+ if (d != null)
+ remote = d.getBeforeState();
+ }
- // Only perform the replace if a local or remote change was found
- if (d != null) {
- performReplace(diff, file, remote, monitor);
- }
+ // Only perform the replace if a local or remote change was found
+ if (d != null) {
+ performReplace(diff, file, remote, monitor);
+ }
}
- /**
+ /**
* Method that is invoked from
* {@link #performReplace(IDiff, IProgressMonitor)} after the local has been
* changed to match the remote. Subclasses may override
@@ -361,7 +361,7 @@ public abstract class MergeContext extends SynchronizationContext implements IMe
* a progress monitor
* @throws CoreException
*/
- protected abstract void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException;
+ protected abstract void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException;
private void performReplace(final IDiff diff, final IFile file, final IFileRevision remote, IProgressMonitor monitor) throws CoreException {
run(monitor1 -> {

Back to the top