Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Apply patch in Sync view

Revision as of 08:44, 15 January 2010 by Tomasz.Zarna.pl.ibm.com (Talk | contribs) (Context menu)

Problem

Provide an alternative way of applying patches. Desired behavior, which could in future replace the current one, is to use the Synchronize View to display content of a patch, resolve potential conflicts and apply the patch eventually. This way while the comparison is being done, other features of Eclipse are available to use, we are not bounded to the current Apply Patch wizard.

This is tracked by bug 236169.

Solution

The proposed solution consist of several parts:

  • Subscriber - a subscriber implementation that provides synchronization between local resources to be patched and their in-memory representation with changes from the patch applied. As the result of it's nature, the subscriber does not contact any remote server. It's a three-way comparison, all changes from the patch are treated as incoming.
  • SyncInfo - sync info node is returned to resources that would be affected by the patch. The direction of the sync info node can be either incoming or conflicting (for unmatched changes).
  • IResourceVariant - represents local resource with changes from the patch
  • ModelProvider - provider for Patch logical model
    • model objects - PatchDiffNodes are used as model objects: PatchProjectDiffNode for projects in the patch, PatchFileDiffNode for files and HunkDiffNode for hunks. PatchDiffNode implements ICompareInput so it can be used as input to a two-way or three-way compare viewer.
    • ResourceMappings - each model object is accompanied by resource mapping. Resource mapping for a hunk object returns traversal containing the IFile affected by the hunk.
  • org.eclipse.team.ui.synchronizeWizards extension point - used to register a synchronize participant creation wizard. In the proposed solution a subclass of PatchWizard is used. An extra page is added where user can decide to preview patch in the Synchronize view, so when 'Finish' button is pressed the participant is refreshed and the result is displayed in the Synchronize view.
  • org.eclipse.team.ui.synchronizeParticipants extension point - sublass of ModelSynchronizeParticipant
  • org.eclipse.ui.navigator.navigatorContent extension point - provides a content and label provider used by a navigator content service in the Synchronize View when model aware synchronization takes place
    • content provider - a content provider that implements IPipelinedTreeContentProvider so contributions provided by an "upstream" extension (resourceContent) can be replaced with Patch model objects
    • label provider - a label provider decorating Patch model objects with probel labeling and image
  • org.eclipse.team.ui.teamContentProviders - associates the patch model provider with the patch navigator content provider
  • org.eclipse.core.runtime.adapters - allows to declaratively register adapter factory which supports different adapters including IResourceMapping (used by the model provider), IWorkbenchAdapter (required by label provider) and others

Tasks

Note.png
Overall progress
34% (22/64)


Required changes are grouped in the following areas:

Synchronize participant, subscriber

  • Ok green.gif Add synchronize participant + subscriber
  • Ok green.gif IResourceVariant implementation should return patched files when asked for Storage
  • Persistable, intitialized on startup; remember which hunks have been applied; remember patch options set
  • Pinnable
  • Progress.gif Listen to workspace changes, reapply all hunks for a file when needed using the patch options already set
  • Ok green.gif bug: Applying a change should remove it from the sync view - change state to 'in sync' bug 298923
  • Make sure non-workspace patches can be applied via Sync view as well bug 298923
  • Close (ask to close) participant when all hunks have been applied, so it won't bother about forthcoming resource changes (deltas)

Synchronize wizard

  • Ok green.gif Apply Patch sync participant/wizard should be available in the Synchronize wizard

Synchronize wizard - participant page (work in progress)

  • Ok green.gif Embed apply patch wizard into synchronize wizard so patch (input) can be selected
  • Setting bounds for a nested wizard is an issue, see bug 297470
  • Ok green.gif Add a page to the new wizard where user can select how the patch should be applied (traditionally, preview in the wizard or in Sync view)
  • Add more options to the new wizard page, see bug 198149
    • Synchronize resources modified by the patch
    • Add affected resources to a Change set bug 117298
    • Add affected resource to a Working Set

New page in the apply patch wizard (mockup)

  • Ok green.gif Provide a proper icon for the participant bug 298923
  • Ok green.gif Provide valid description for the participant bug 298923

Model Provider

  • Ok green.gif Model objects for hunks
  • Ok green.gif Don't block other model providers to participate in synchronization (applying patch)
  • Ok green.gif Other model providers do not display hunks

Java model when applying patch (work in progress)

  • Use DiffProject, FilePatch2 and Hunk as model objects
  • Ok green.gif Use PatchDiffNodes as model objects, they represent the result of applying a patch (not the patch strucutre as types above) and they implement ICompareInput so are compare-ready
  • Missing objects representing folders, the result is something like flat presentation
  • Progress.gif Other models do not indicate any conflicts when applying a patch -> unmerged hunks should be treated as sync view conflicts, see also #Label provider
  • Ok green.gif NPE when trying to execute a team action from context menu in Package Explorer
  • Ok green.gif bug: 'Patch Contents' model provider should not appear in CVS synchronizations bug 298923 [Szymon]
  • Ok green.gif bug: 'Patch Contents' model provider interfere unrelated Team operations (e.g. 'Replace with Another Branch or Version') bug 298923 [Szymon]
  • Ok green.gif bug: CCE when switched to 'Patch Contents' model if the Sync view opened with a different model displayed initially (e.g. Java Workspace) bug 298923

Sync view

  • Status line should display lines added/removed by the patch.
  • NPE when trying to switch to a different synchronization when applying patch (see bug 256972)
  • 'Schedule' action in the view's drop down menu should be disabled (or removed)
  • Support 'Link with Editor'
  • Applying patch ('Update' action) should process only matched hunks bug 298923

Content provider

Hunks (work in progress)

  • Ok green.gif Display hunks in Sync view
  • Hunks objects never have children, get rid of the [+] sign

Label provider

  • Ok green.gif Indicate that a hunk cannot be applied.
  • Display Patch options settings: fuzz factor, offset used (bug 205762), moved from(?). All per hunk.
  • Use conflict ('double-headed red arrow') icon instead of 'red X' icon for unmatched hunks
  • Indicate when a project from the patch doesn't exist in the workspace bug 298923
  • Ok green.gif bug: Missing 'incoming change' indicator for model provider different than 'Patch' when open for the first time. Workaround: switch to 'Patch' model and back.

Java model when applying patch in Sync view (work in progress)

  • bug: Folders to be created by an addition are not displayed when in 'All Models' mode

Sync view should display 'src/org/eclipse/core/internal/filesystem/local' not just 'local' (work in progress)

Context menu

Current sync's view context menu when applying patch (work in progress)
Context menu issues need to fixed before merging to HEAD, see bug 298923.

  • 'Update' means 'Apply' in the Apply Patch world
  • 'Apply' should work for projects, files and individual hunks
  • Progress.gif'Apply' should be disabled for unmatched hunks
  • 'Apply' on file/project containing unmatched hunks should affect matched hunks only
  • Do we need two 'Apply' variants: merge and overwrite-and-update? I assume we don't.
  • Add 'Open'/'Open With' actions
  • Ok green.gif Add 'Open in Compare' action
  • 'Remove from View' means 'Exclude' in the Apply Patch world
  • No 'Exclude' action available, replaced with 'Remove from the view'
  • 'Mark as Merged' does the same thing as 'Exclude' in the Apply Patch world (?) See 'Remove from View'.
  • 'Apply' made on a hunk should affect only the selected hunk not the whole file as it happens now

View toolbar

  • 'Copy All Incoming Changes...' / 'Merge All Non-conflicting Changes' means 'Apply All'
  • Ok green.gif Only 'Incoming' and 'Conflicts' mode should be available
  • 'Flat presentation' is meaningless for Patch Model (see also bug 277107)

Operations

Make all operations in the Apply Patch wizard be available in the Sync view (when applying a patch).

Patch options

Apply Patch wizard, Patch preview page

  • Re-applying patch -> synchronize again
  • Remember set options when re-applying: fuzz factor, ignored segments, moved hunks
  • Ignore segments setting applies to all files in the patch -> re-apply
  • Reverse patch on sync's view toolbar(?)
  • Ok green.gif Show matched Hunks: All hunks are shown
  • Show excluded Hunks -> Sync's view drop down > Restore Removed Items
  • Fuzz factor / Guess
  • Generate .rej files for unmerged hunks - applies to all changes from the patch
  • Move hunk

Compare Editor

  • 'Open In Compare Editor' for a file should display full file content with changes from all hunks
  • bug: Open in Compare editor for a file (in a patch) displays Hunks in the structure view. First hunk is select on start but nothing is displayed in the compare content area.

'Open in Compare Editor' for a file 1 (work in progress) 'Open in Compare Editor' for a file 2 (work in progress) 'Open in Compare Editor' for a file 3 (work in progress)

  • 'Open In Compare Editor' should be available for hunks
  • bug: No Java structure available for Java files; fine(?) for hunks

Java structure in Compare editor opened for a hunk (work in progress)

  • Ok green.gif bug: ClassCastException when right-clicking in comparison for a file
  • Update context menu, rename Merge, Mark as Merged and Overwrite action as in #Context menu
  • For Java files (All Models, Java Workspace modes) Java compare editor should be opened, instead Text compare is used. Works fine when compare is open for Java file from Patch Contents mode

Source code

You have two options here:

  • apply the latest patch from bug 236169
  • checkout "branch_20091215_bug236169" branch created for o.e.compare and o.e.team.ui (suggested)

Back to the top