Community
Participate
Working Groups
Here is a patch that's a companion to the Create Patch enchancements attached to Bug# 41340. It modifies the Apply Patch mechanism to allow it to apply workspace patches that are created by the Create Patch wizard while preserving the ability to still apply single selection patches. Summary of what changes have been made - Rearranged the Patch Wizard page ordering: a) InputPatchPage: Used by the user to select the location of the patch. Depending on the type of patch that is being applied, the wizard either directs the user to the PatchTargetPage (for single selection patches) or the PreviewPatchPage (for workspace patches) b) PatchTargetPage: This page is displayed to allow the user to select the root of the patch they wish to apply. (Single selection patch only) c) PreviewPatchPage: This page summarizes all of the changes that are to be applied. For single patches everything looks like it did before. For workspace patches, the Diffs are now contained by projects. There is also the ability to change the projects targeted by the patch in case the projects in the patch don't match up to the current workspace or if the user wishes to target another project. - Extracted the model from the PreviewPatchPage and put it into DiffProjects, Diffs and Hunks. Also changed some of the UI to use a JFace tree viewer. - Added WorkspacePatcher as a subclass of Patcher - Added some code to CompareUI to allow users to create own workspace patch (not sure if there's a better place for this). - Contributed some tests for new functionality.
Created attachment 27460 [details] Apply Patch zip
BTW, the Create Patch portion of this has already been commited to head. So to try this out, apply the attached patch and then start up Eclipse with the VM flag: -DworkspacePatch=true This enables workspace patch creation in Create Patch. To try it out, you can select multiple projects, resources etc and create a patch (the wizard will only allow you to create a workspace format patch if you have multiple selections).
I've applied the patch and it works for me. Cool stuff, thanks! Here are some remarks: - the layout of the first page is slightly confusing. At least on MacOS X it is not obvious that the workspace radio button and the workspace tree underneath it, belongs together (see attached screenshot). One way to fix this would be to indent the tree so that it looks "grouped" under the workspace button. - I'm reluctant to add the two new API methods to CompareUI (it is already a kitchen sink :-). Why not create a new package org.eclipse.compare.patch for the public API of patch? (There are other requests to make the patcher available as API, so we could use the new package anyway) - I would rename method Utilities.getResource(ISelection) to getFirstResource and keep it in internal.patch package by creating a local Utilities class there. How should we proceed? Should I release your code and you'll create new patches based on that, or should I wait for a new patch from you?
Created attachment 27925 [details] existing layout
I think it will be easier if you release the patch and we send you an additional patch with the requested modifications. That way, we can have it available in the next integration build and will have time to get comments from others before M3.
patch released to HEAD.
Here are some changes for Apply Patch relating to Bugs 110481, Bug 112169 and Bug 112661. Changes are as follows: From Bug 110481: 1) The workspace tree on the first page of the wizard has been indented to fall under the Workspace selection button. 2) Created new org.eclipse.compare.patch package that has WorkspacePatcherUI.java which contains the API needed to write out workspace format patches. 3) Renamed Utilities.getResource(ISelection) to getFirstResource From Bug 112169: 4) Added a check to PreviewPatchPage to make sure that users can't select Diffs or Hunks that have problems From Bug 112661 5) Changed the error reporting so that no errors are shown when the dialog first starts up (the user can't continue unless a patch is selected) 6) Changed the initial patch selection mechanism as follows: i) See if the resource that the user has selected to run Apply Patch on is a patch file. If it is, select it in the workspace tree and choose the workspace button. If not go on. ii) See if the clipboard contains a valid patch. If so select the clipboard button. If not go on. iii) Load the persisted setting from the last time apply patch was run. (If it has never been run, the default setting is file). If the previous option no longer exists (ie. junk on the clipboard or workspace file has been deleted) default to file. 7) Changed title on first page to "Select the patch location." 8) Added mnemonics to workspace trees on both the first and second pages. 9) Changed sorter in workspace trees to ResourceSorter(ResourceSorter.Name) 10) Save dialog resize settings. Andre, if you could release this patch to HEAD sometime next week, it would give us a chance to exercise the code before M3. Thanks!
Created attachment 28602 [details] Apply Patch Fixes
Thanks for the patch. Looks good and works great! Since I'll be on vacation for the next two weeks, I've already applied the patch and tagged the project for the next build input. In addition I've updated component.xml for the new package and the new public type.
Verified using I20051213-0010 Filed additional bug 120531