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

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

Warning2.png
Please note that this page is longer updated as often as it used to be during 3.6M5. The code is now in HEAD and all issues are tracked in bugzilla.
Note.png
Overall progress
52% (38/72)


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
  • Ok green.gif Pinning synchronization... seems to be working fine.
  • Ok green.gif Response to workspace changes, reapply all hunks for a file when needed using the patch options already set bug 298923
  • Ok green.gif bug: Applying a change should remove it from the sync view - change state to 'in sync' bug 298923
  • Ok green.gif 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) It's not an issue anymore, resource changes do not make applied hunks to reappear.
  • Ok green.gif Patches from multiple synchronizations (when pinned) should be applicable in any order. This includes applying only part of a patch. bug 298923
  • Ok green.gif Synchronizing against multiple patches and applying changes to the same file from these patches causes data loss. The file's content is overwritten, so changes from the previously applied patch are lost.
  • bug: synchronize with patch, close the project, do 'Apply All' -> Error dialog saying "Project is not open" will pop up. When closing the project, no changes should be visible in the synch view, 'Apply All' button should be disabled. How does CVS Synchronization behave in such situation?

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 Allow other model providers to participate in synchronization (applying patch)
  • Other model providers do not display hunks Only Patch Model provider displays 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, this results in something similar to 'flat presentation'
  • Ok green.gif Other models do not indicate any conflicts when applying a patch -> unmatched 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

  • Ok green.gif Treat unmerged hunks/files as conflicts
  • 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). Not a blocking issue anymore, added icon for the participant.
  • 'Schedule' action in the view's drop down menu should be disabled (or removed) bug 301243
  • Ok green.gif Support 'Link with Editor'
  • Ok green.gif Applying patch ('Update' action) should process only matched hunks bug 298923
  • Clicking on the model switching drop-down doesn't turn Patch Contents model on. Same thing for Change Sets when doing CVS synchronization. bug 210087
  • Ok green.gif bug: Do 'apply' on a file with an unmatched hunk. Other matching hunks should disappear from the view (applied and marked as excluded), the only one remaining should be the unmatched hunk. bug 300213

Content provider

Hunks (work in progress)

  • Ok green.gif Display hunks in Sync view
  • Hunks objects never have children, get rid of the [+] sign bug 300346
  • Fix hunks sorting. Hunk labeled '123...' should not appear before '13...'. bug 300347

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. bug 300350
  • Progress.gif Indicate when a project from the patch doesn't exist in the workspace. Currently 'No change' msg is displayed, which is ok when applying a patch for a single project. For multiple projects, showing no changes may result in omitting part of the patch without noticing it. Showing a dialog with a warning message seems to be reasonable. What does CVS Synchronization do in such cases? Does it ever happen for CVS? bug 300215

Sync view should indicate that a project from patch doesn't exist (mockup)

  • 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)

  • Display 'busy' hint in the sync view for diffs that are being reapplied.
  • Direction indicator vanishes after merge bug 300656
  • bug: Patched project receives 'unmatched' decoration after merge bug 301432

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 We will stick to the Synchronize naming i.e. 'Merge'. bug 300211
  • Ok green.gif 'Apply' should work for projects, files and individual hunks.
  • 'Apply' should be disabled for unmatched projects/files/hunks. 'Update' action (equivalent of 'Apply' in patch world) in other synchronizations is enabled for conflicts.
  • Ok green.gif '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 to 'Patch Contents' model. bug 300217
  • Ok green.gif Add 'Open in Compare' action
  • Progress.gif 'Remove from View' means 'Exclude' in the Apply Patch world I think we will stick to 'Remove from View' action to be consistent with other synchronizations. bug 300211
  • 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'. bug 300211
  • 'Apply' done on a hunk should affect only the selected hunk not the whole file as it happens now... bug 300214
  • Ok green.gif ... but for now, disable 'Apply' for all (matched and unmatched) hunks

View toolbar

  • 'Copy All Incoming Changes...' / 'Merge All Non-conflicting Changes' means 'Apply All' We will stick to the Synchronize naming.
  • 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). bug 300348

Patch options

Apply Patch wizard, Patch preview page

  • Ok green.gif Re-apply the patch <-> synchronize again bug 298923
  • 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

Compare editor for Patch Contents model

  • Ok green.gif 'Open In Compare Editor' for a file should display full file content with changes from all hunks
  • bug: 'Open in Compare Editor' for a patch file displays hunks in the structure view, which is fine. The problem is that initially first hunk is selected and nothing is displayed in the compare content area. bug 300225

'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)

  • Ok green.gif 'Open In Compare Editor' should be available for hunks
  • bug: No Java structure available for Java files. It's shown only when a hunk is selected or compare editor has been opened for a hunk. bug 300238

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
  • Make left side editable bug 300229
  • Refresh contents when local resource changes bug 300221

All compare editors

  • Update context menu, rename Merge, Mark as Merged and Overwrite action as in #Context menu bug 300231
  • Ok green.gif 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. bug 300235
  • Manually copying changes from right to left causes the copied hunk to appear as conflict in the Sync View. bug 300237

Source code

The code is in HEAD.

Back to the top