Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 160329 Details for
Bug 300237
[Sync View][Apply Patch] Copying changes from right to left results in a conflict
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix v01
clipboard.txt (text/plain), 14.18 KB, created by
Tomasz Zarna
on 2010-02-26 11:34:43 EST
(
hide
)
Description:
Fix v01
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2010-02-26 11:34:43 EST
Size:
14.18 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.ui >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java,v >retrieving revision 1.5 >diff -u -r1.5 ApplyPatchModelCompareEditorInput.java >--- src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java 25 Feb 2010 11:05:10 -0000 1.5 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java 26 Feb 2010 16:32:27 -0000 >@@ -20,8 +20,7 @@ > import org.eclipse.jface.action.*; > import org.eclipse.jface.viewers.*; > import org.eclipse.team.internal.ui.*; >-import org.eclipse.team.internal.ui.mapping.ModelCompareEditorInput; >-import org.eclipse.team.internal.ui.mapping.ResourceMergeHandler; >+import org.eclipse.team.internal.ui.mapping.*; > import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; > import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant; > import org.eclipse.ui.IWorkbenchActionConstants; >@@ -38,7 +37,21 @@ > > protected void handleMenuAboutToShow(IMenuManager manager) { > StructuredSelection selection = new StructuredSelection(((IResourceProvider)getCompareInput()).getResource()); >- >+ final ResourceMarkAsMergedHandler markAsMergedHandler = new ResourceMarkAsMergedHandler(getSynchronizeConfiguration()); >+ markAsMergedHandler.updateEnablement(selection); >+ Action markAsMergedAction = new Action(TeamUIMessages.ModelCompareEditorInput_0) { >+ public void run() { >+ try { >+ markAsMergedHandler.execute(new ExecutionEvent()); >+ } catch (ExecutionException e) { >+ TeamUIPlugin.log(IStatus.ERROR, e.getMessage(), e); >+ } >+ } >+ >+ }; >+ Utils.initAction(markAsMergedAction, "action.markAsMerged."); //$NON-NLS-1$ >+ markAsMergedAction.setEnabled(markAsMergedAction.isEnabled()); >+ > final ResourceMergeHandler mergeHandler = new ResourceMergeHandler(getSynchronizeConfiguration(), false); > mergeHandler.updateEnablement(selection); > Action mergeAction = new Action(TeamUIMessages.ModelCompareEditorInput_1) { >@@ -54,6 +67,7 @@ > mergeAction.setEnabled(mergeAction.isEnabled()); > > manager.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator("merge")); //$NON-NLS-1$ >+ manager.insertAfter("merge", markAsMergedAction); //$NON-NLS-1$ > manager.insertAfter("merge", mergeAction); //$NON-NLS-1$ > } > >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java,v >retrieving revision 1.3 >diff -u -r1.3 ApplyPatchModelSynchronizeParticipant.java >--- src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java 24 Feb 2010 14:40:52 -0000 1.3 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java 26 Feb 2010 16:32:27 -0000 >@@ -63,9 +63,6 @@ > if (mergeActionId == SynchronizationActionProvider.OVERWRITE_ACTION_ID) { > // omit this action > return; >- } else if (mergeActionId == SynchronizationActionProvider.MARK_AS_MERGE_ACTION_ID) { >- // omit this action >- return; > } > super.addToContextMenu(mergeActionId, action, manager); > } >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java,v >retrieving revision 1.2 >diff -u -r1.2 ApplyPatchSubscriberMergeContext.java >--- src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java 26 Jan 2010 12:35:04 -0000 1.2 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java 26 Feb 2010 16:32:27 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.core.runtime.jobs.ISchedulingRule; > import org.eclipse.team.core.diff.IDiff; > import org.eclipse.team.core.mapping.ISynchronizationScopeManager; >+import org.eclipse.team.core.mapping.provider.ResourceDiffTree; > import org.eclipse.team.core.subscribers.Subscriber; > import org.eclipse.team.core.subscribers.SubscriberMergeContext; > >@@ -44,21 +45,32 @@ > > public void markAsMerged(IDiff node, boolean inSyncHint, > IProgressMonitor monitor) throws CoreException { >- IResource resource = getDiffTree().getResource(node); >- WorkspacePatcher patcher = ((ApplyPatchSubscriber) getSubscriber()) >- .getPatcher(); >+ ResourceDiffTree tree = (ResourceDiffTree)getDiffTree(); >+ IResource resource = tree.getResource(node); >+ WorkspacePatcher patcher = ((ApplyPatchSubscriber) getSubscriber()).getPatcher(); > Object object = PatchModelProvider.getPatchObject(resource, patcher); >- if (object instanceof FilePatch2) { >- FilePatch2 filePatch = (FilePatch2) object; >- FileDiffResult fileDiffResult = patcher.getDiffResult(filePatch); >- HunkResult[] hunkResults = fileDiffResult.getHunkResults(); >- for (int i = 0; i < hunkResults.length; i++) { >- // disable hunks that were merged >- if (hunkResults[i].isOK()) >- patcher.setEnabled(hunkResults[i].getHunk(), false); >+ try { >+ tree.beginInput(); >+ if (object instanceof FilePatch2) { >+ FilePatch2 filePatch = (FilePatch2) object; >+ FileDiffResult fileDiffResult = patcher.getDiffResult(filePatch); >+ HunkResult[] hunkResults = fileDiffResult.getHunkResults(); >+ for (int i = 0; i < hunkResults.length; i++) { >+ if (inSyncHint) { >+ // disable hunks that were merged >+ if (hunkResults[i].isOK()) >+ patcher.setEnabled(hunkResults[i].getHunk(), false); >+ } else { >+ patcher.setManuallyMerged(hunkResults[i].getHunk(), true); >+ } >+ } >+ } else { >+ patcher.setEnabled(object, false); >+ // TODO: mark as merged > } >- } else { >- patcher.setEnabled(object, false); >+ tree.remove(resource); >+ } finally { >+ tree.endInput(monitor); > } > } > >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java,v >retrieving revision 1.2 >diff -u -r1.2 ApplyPatchSynchronizationActionProvider.java >--- src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java 26 Jan 2010 12:35:04 -0000 1.2 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java 26 Feb 2010 16:32:27 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.team.internal.ui.synchronize.patch; > >+import org.eclipse.team.internal.ui.mapping.ResourceMarkAsMergedHandler; > import org.eclipse.team.ui.mapping.SynchronizationActionProvider; > import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; > >@@ -23,10 +24,12 @@ > protected void initialize() { > super.initialize(); > final ISynchronizePageConfiguration configuration = getSynchronizePageConfiguration(); >- // We provide custom handler that is disabled for hunks. >+ // Provide custom handler, disabled for hunks. > registerHandler(MERGE_ACTION_ID, new ApplyPatchMergeActionHandler( > configuration, false)); >- // 'Overwrite' and 'Mark as merged' actions are not shown, see >+ registerHandler(MARK_AS_MERGE_ACTION_ID, >+ new ResourceMarkAsMergedHandler(configuration)); >+ // 'Overwrite' action is not shown, see > // ApplyPatchModelSynchronizeParticipant.ApplyPatchModelSynchronizeParticipantActionGroup.addToContextMenu(String, > // Action, IMenuManager) > } >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java >--- src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java 26 Jan 2010 12:35:02 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,38 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.internal.ui.synchronize.patch; >- >-import org.eclipse.compare.internal.patch.PatchDiffNode; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerFilter; >- >-public class ExcludedPatchDiffNodesFilter extends ViewerFilter { >- >- private static ViewerFilter filter; >- >- public static ViewerFilter getInstance() { >- if (filter == null) >- filter = new ExcludedPatchDiffNodesFilter(); >- return filter; >- } >- >- public ExcludedPatchDiffNodesFilter() { >- super(); >- } >- >- public boolean select(Viewer viewer, Object parentElement, Object element) { >- if (element instanceof PatchDiffNode) { >- PatchDiffNode node = (PatchDiffNode) element; >- return node.isEnabled(); >- } >- return true; >- } >-} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java,v >retrieving revision 1.3 >diff -u -r1.3 PatchSyncContentProvider.java >--- src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java 10 Feb 2010 13:09:57 -0000 1.3 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java 26 Feb 2010 16:32:27 -0000 >@@ -10,18 +10,17 @@ > *******************************************************************************/ > package org.eclipse.team.internal.ui.synchronize.patch; > >-import org.eclipse.compare.internal.patch.HunkDiffNode; >-import org.eclipse.compare.internal.patch.PatchDiffNode; >+import org.eclipse.compare.internal.patch.*; > import org.eclipse.compare.structuremergeviewer.IDiffElement; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.mapping.*; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.jface.util.PropertyChangeEvent; >-import org.eclipse.jface.viewers.ITreeContentProvider; >-import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.*; > import org.eclipse.team.core.mapping.ISynchronizationContext; > import org.eclipse.team.core.mapping.ISynchronizationScope; >+import org.eclipse.team.core.subscribers.Subscriber; > import org.eclipse.team.internal.ui.TeamUIPlugin; > import org.eclipse.team.internal.ui.mapping.SynchronizationResourceMappingContext; > import org.eclipse.team.ui.mapping.SynchronizationContentProvider; >@@ -54,14 +53,17 @@ > } > > protected Object getModelRoot() { >+ return PatchModelProvider.getPatchWorkspace(getSubscriber()); >+ } >+ >+ private Subscriber getSubscriber() { > if (getContext() instanceof ApplyPatchSubscriberMergeContext) { > ApplyPatchSubscriberMergeContext context = (ApplyPatchSubscriberMergeContext) getContext(); >- return PatchModelProvider.getPatchWorkspace(context.getSubscriber()); >+ return context.getSubscriber(); > } >- // TODO: assertion? > return null; > } >- >+ > /* > * Copied from > * org.eclipse.team.examples.model.ui.mapping.ModelSyncContentProvider >@@ -94,7 +96,40 @@ > } > return false; > } >+ >+ private class ExcludedPatchDiffNodesFilter extends ViewerFilter { > >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if (element instanceof PatchDiffNode) { >+ PatchDiffNode node = (PatchDiffNode) element; >+ if (!node.isEnabled()) >+ return false; >+ if (node instanceof PatchFileDiffNode) { >+ // when at least one hunk is manually merged, hide the node >+ PatchFileDiffNode file = (PatchFileDiffNode) node; >+ IDiffElement[] children = file.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof HunkDiffNode) { >+ HunkDiffNode hunk = (HunkDiffNode) children[i]; >+ WorkspacePatcher patcher = ((ApplyPatchSubscriber)PatchSyncContentProvider.this.getSubscriber()).getPatcher(); >+ if (patcher.isManuallyMerged(hunk.getHunkResult().getHunk())) >+ return false; >+ } >+ } >+ } >+ } >+ return true; >+ } >+ } >+ >+ private ViewerFilter filter; >+ >+ public ViewerFilter getInstance() { >+ if (filter == null) >+ filter = new ExcludedPatchDiffNodesFilter(); >+ return filter; >+ } >+ > public void propertyChange(PropertyChangeEvent event) { > super.propertyChange(event); > if (event.getProperty().equals(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER)) { >@@ -115,20 +150,20 @@ > } > } > >- private static void addFilter(Viewer v) { >+ private void addFilter(Viewer v) { > if (v != null && v instanceof CommonViewer) { > CommonViewer cv = (CommonViewer) v; >- cv.addFilter(ExcludedPatchDiffNodesFilter.getInstance()); >+ cv.addFilter(getInstance()); > } > } > >- private static void removeFilter(Viewer v) { >+ private void removeFilter(Viewer v) { > if (v != null && v instanceof CommonViewer) { > CommonViewer cv = (CommonViewer) v; >- cv.removeFilter(ExcludedPatchDiffNodesFilter.getInstance()); >+ cv.removeFilter(getInstance()); > } > } >- >+ > public boolean hasChildren(final Object element) { > if (element instanceof HunkDiffNode) > return false;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 300237
:
160329
|
160330
|
160489