Author Topic: Feature request: diffzilla support for patch files  (Read 9058 times)

timur

  • Senior Community Member
  • Posts: 205
  • Hero Points: 3
Feature request: diffzilla support for patch files
« on: October 06, 2006, 09:02:28 PM »
I use Slickedit to work with the Linux kernel.  As such, most code changes are handled in the form of patch files, like this one:

Code: [Select]
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c
index a362ee9..6d2e314 100644
--- a/drivers/char/viocons.c
+++ b/drivers/char/viocons.c
@@ -947,7 +947,7 @@ #ifdef CONFIG_MAGIC_SYSRQ
  */
  continue;
  } else if (vio_sysrq_pressed) {
- handle_sysrq(cevent->data[index], NULL, tty);
+ handle_sysrq(cevent->data[index], tty);
  vio_sysrq_pressed = 0;
  /*
  * continue because we don't want to add
--
1.4.2.1

Each block of changes is called a 'hunk'.  Part of the problem with patchfiles is that if the original code has been updated since the patch was created, but before the patch is applied, some hunks may not apply.  The end result is a file that's been changed partially, but an number of hunks left behind.

What makes this procedure even more difficult is that the tools that are normally used don't make it easy to deal with partial patching.  The developer usually has no choice but to manually apply patches, one line at a time, using cut and paste.

Slickedit's diffzilla is an amazing tool, and I would like to see it extended to handling patch files.  Specifically:

1) To start the patch application, I specify a source file and patch file.  Diffzilla opens two windows as normal. Ideally, I should be able to just specify the patchfile, and diffzilla will find the right source file for me.
2) In the 2nd window is the patch file, broken down into a sequence of hunks.  If a hunk can be applied easily (i.e. diffzilla can identify where it's supposed to go), then that hunk can be applied with a single mouse click.
3) If a hunk can't be applied, I can use the editing tools of diffzilla to easily copy over single lines and/or edit the source file as I normally can in diffzilla.  Editing the patch file probably wouldn't be useful.
4) If I have to manually apply a hunk, then afterwards I can mark that hunk in the original patchfile as being applied.
5) After I'm done, diffzilla will give me the option of creating a new patchfile in case I had to make manual edits.

For now, being able to do this with a single source file and a single patch file would be great.  However, a single patch file can contain hunks for multiple source files, so diffzilla should be able to handle that somehow.  A later version would be able to handle multiple patch files as one group.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2905
  • Hero Points: 153
Re: Feature request: diffzilla support for patch files
« Reply #1 on: October 09, 2006, 01:49:43 PM »
I have considered adding this, but what to do with a patch file that has pieces of multiple source files is sort of a sticking point.  I hope you can look for a feature like this at some point in the future.
« Last Edit: October 09, 2006, 08:16:53 PM by Dan »

timur

  • Senior Community Member
  • Posts: 205
  • Hero Points: 3
Re: Feature request: diffzilla support for patch files
« Reply #2 on: October 09, 2006, 08:20:38 PM »
I would be willing to pay for an upgrade to get this feature.

As for how to handle multiple files, just treat it the same way as a multi-file diff.  Slickedit should scan the patchfile and determine which files are affected.  If there's only one file, then it will just display a diff of that file.  If there are multiple files, then it will generate a tree view of files like a multi-file diff does.

natros

  • Community Member
  • Posts: 59
  • Hero Points: 1
Re: Feature request: diffzilla support for patch files
« Reply #3 on: October 10, 2006, 10:27:27 PM »
KDE does have a tool that does that: kompare

timur

  • Senior Community Member
  • Posts: 205
  • Hero Points: 3
Re: Feature request: diffzilla support for patch files
« Reply #4 on: October 11, 2006, 06:23:34 PM »
Kompare doesn't allow you to edit the files, so it can't be used for manually applying hunks.

cdouble

  • Community Member
  • Posts: 43
  • Hero Points: 0
Re: Feature request: diffzilla support for patch files
« Reply #5 on: August 06, 2007, 06:15:31 AM »
I'd pay a LOT of money to get this feature....I'm having to do gnu diff's and patches and this is just killing me....:-)

Thanks,

McD

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2905
  • Hero Points: 153
Re: Feature request: diffzilla support for patch files
« Reply #6 on: August 08, 2007, 06:49:23 PM »
If we were to do this, what would the preferred format be?

cdouble

  • Community Member
  • Posts: 43
  • Hero Points: 0
Re: Feature request: diffzilla support for patch files
« Reply #7 on: August 10, 2007, 06:35:32 AM »
The format would be the current "diff" output format. Are there others?

Thanks,

mCD

cdouble

  • Community Member
  • Posts: 43
  • Hero Points: 0
Re: Feature request: diffzilla support for patch files
« Reply #8 on: August 10, 2007, 06:49:15 AM »
If you're thinking of this...here's what would be really cool (using diffzilla)...

Given a patch file for a target source tree, show me the patch (hunk) in the source (highlighted) and let me use the diffzilla controls to apply or not apply the patch. When done, move onto the next file (like diffzilla does now). In addition, for source trees that don't quite match up, ask me to "find" the source file in the target source tree and apply the patch. We have a source base with many source trees which aren't "exactly" the same but the file names are unique. So searching for the file will work. And we have a LOT of potential users (1000's)... :o

Thanks,

mCD


Ivan N. Zlatev

  • Community Member
  • Posts: 87
  • Hero Points: 5
Re: Feature request: diffzilla support for patch files
« Reply #9 on: August 12, 2007, 10:15:22 AM »
I work with patches quite often and it would be great if you add this feature!

Ding Zhaojie

  • Senior Community Member
  • Posts: 194
  • Hero Points: 37
Re: Feature request: diffzilla support for patch files
« Reply #10 on: November 19, 2014, 05:32:13 AM »
I've made a tool to view patch side-by-side: https://app.box.com/s/l8rmp281aptq711fqwve


jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Feature request: diffzilla support for patch files
« Reply #11 on: November 19, 2014, 08:13:15 PM »
Isn't this what the 3-way merge was created for?
Doesn't the same thing happen virtually everytime you need to merge two branches?

Given a common base version of a file, merge two, possibly conflicting descendant versions.




So, starting with version N of file.c:
Patch is created based on version N
File.c is changed several times. Now the current version is N+2


3-way merge: Base file is file.c version N
Revision #1: Head -- File.c version N+2
Revision #2: File.c version N with patch applied to it (should be straightforward, right?)




So really, all you need to do is be able to retrieve version N of file.c, apply the patch, then feed the results into Slicks 3-way merge tool.


Based on the patch file, can you tell which version of File.c it is based on?


Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
Re: Feature request: diffzilla support for patch files
« Reply #12 on: November 20, 2014, 04:40:39 PM »
On an partly related note, I just started putting together a language mode for patch files.  You should see this in 19.0.1.  It only does color coding of the patch syntax and lists the files in the patch (as tags), but it's better than fundamental mode.