15

I've used the Create Patch facility in Eclipse to create patches for uncommitted changes. I'm looking for a way to create patches in Eclipse for changes that have already been committed to the VCS.

Unless I've missed something I don't think this is possible, but is there a plugin that adds this capability? e.g. enabling you to select two versions in the History view and create a patch between them or comparing two branches and being able to create a patch from the results in the Synchronize view?

I'm happy creating such patches from the command line but am looking for a way to streamline/integrate the process if possible.

Thanks for any help.

Update: if any suggestions are specific to a particular source control system I'm particularly interested in CVS, SVN and Mercurial. Thanks again.

mikej
  • 65,295
  • 17
  • 152
  • 131

6 Answers6

10

With subclipse you can select two revisions of a directory in the history view, compare them and save the patch as a unified diff.

Thomas Jung
  • 32,428
  • 9
  • 84
  • 114
6

I just made a patch SVN after a commit! :)

  • Enter in "SVN Repository"
  • Go to the root of the project.
  • Click on "Compare"
  • Select "Unified diff to output file"
  • Click on "Select" and choose the name and location of the file
  • Click "Ok"
  • This worked for me, but actually was right-click on directory, then "Compare with...", then "Branch/Tag...", then I picked the previous revision on my same branch, and selected "Unified diff to output file" option – oarevalo Oct 17 '13 at 21:49
4

I did some extensive research... and I've found out that there is no way to use the actual Eclipse Comparison Editor to generate a .patch file based on the differences in the "Local History" section.

I am going to create a new feature request for this.

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152
2

It's possible to do it using the "SVN Repository explorer" perspective.

  • Navigate to the root element you want to compare (typically the trunk folder)
  • Show "History view" (if not already displayed)
  • Select two revisions from "History view"
  • Right-click on one of the two revisions and select "Create Patch..." in the contextual menu.
Jidehem
  • 1,066
  • 11
  • 18
  • What version of Eclipse did you do this on? I can't seem to find the functionality on Kepler. – Andrew Oct 19 '16 at 16:25
  • 1
    @Andrew: I'm currently using Eclipse Luna and it's working well. However, I wrote this answer using a previous version of Eclipse. Not sure if it was Kepler. Probably Juno. – Jidehem Oct 20 '16 at 08:21
  • I do not have "Create patch" available when doing that in History view, only Generate changelog, compare and refresh view. – el-teedee Apr 10 '18 at 10:04
0

As per the other answers, no, it is not currently possible.

But for now, here's a manual work-around with SVN as the example (I imagine other VCSs will allow very similar comparisons):

  • Create a second Eclipse Workspace; Workspace 2.
  • Ensure that Workspace 2 has the right code for the "target" of the merge and the original Workspace 1, has the code you forgot to take a patch from.
  • Manually compare Workspace 1 and 2 using a merge tool capable of comparing directories (On Windows, I like Araxis Merge, but WinMerge works too).
  • Open each file and ensure only your changes are in it, if there are other changes, you'll have to take each of your changed lines across, if no one else has changed the target file, you can copy the whole file across.
  • Synchronise Workspace 2 (but do not check in!) so you can see the changes you've now got there.
  • In Workspace 1, open "SVN Repository Exploring Perspective"
  • Right click the folder where the code was checked in (something under "branches" or "trunk" probably) -> "Compare..." and it should already have filled in the revision number just before your check in.
  • You can now see the changes from the code you checked in (which you forgot to take a patch of) with the version before you checked it in.
  • Have Workspaces 1 and 2 open side by side and run each changed file visually to ensure they match everything from 1 now appears in 2.

Very, very tedious but it should pick up all the changes.

RedYeti
  • 1,024
  • 14
  • 28
0

When I couldn't make this in Eclipse (I needed to work with CVS only), I tried other software available and found that SmartCVS can do it. However, this function is available only in the Pro paid version and it takes a bit of time (kind of slow in comparison) when you have more code.

I would like to know about some open source software with this ability, if someone knows about it. Thanks

Kuba
  • 510
  • 3
  • 13