Add new functionaltiy for reversing diffs.#72
Add new functionaltiy for reversing diffs.#72vslashg wants to merge 1 commit intosourcegraph:masterfrom
Conversation
ReverseFileDiff() and ReverseMultiFileDiff() accept a diff and return a diff which is the reverse operation -- that is, a diff that when applied would undo the edits of the original diff.
|
We found ourselves needing a tool to reverse diffs, and wrote one in terms of sourcegraph/go-diff. Some colleagues suggested that this library might be generally useful, so I'm offering this as a contribution. |
|
Sorry, I need to make a quick edit. I'll repost soon. |
|
Sorry about the noise. This PR is ready for consideration. |
|
I'm curious about the level of interest in future patches. For our local purposes, I'm adding semantic understanding of git annotations to our wrapper. Is it worth the effort to develop this with an eye towards upstreaming it? (I'll take away no hard feelings if the answer is "no", of course.) |
|
Sorry about letting reviews on this slip. I'll take a look soon. We still internally heavily rely on this library. We are super open to contributions and improvements, but major refactors to the API are unlikely. Additionally it will likely be up to the will of the reviewer to decide if a feature is appropriate in this or in maybe a wrapper of this library :) |
keegancsmith
left a comment
There was a problem hiding this comment.
This is a rad change, well written and seems appropriate to me. Thanks so much!
One idea for testing, can you run the test on all patches we have in testdata and check that ReverseFileDiff(ReverseFileDiff(...)) gets back the same FileDiff?
eseliger
left a comment
There was a problem hiding this comment.
Looks great to me! Thanks for all the tests as well.
@keegancsmith did you hold back on merging this intentionally or can we accept this patch?
|
I would be very convinced this is good with my suggestion around tests. |
ReverseFileDiff() and ReverseMultiFileDiff() accept a diff and return a diff which is the reverse operation -- that is, a diff that when applied would undo the edits of the original diff.