-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The documentation is lacking examples #49
Comments
Agreed, I'm rtying to create a gnu patch string and then beeing able to apply it at a later stage but I can't seem to understand how to do this:
|
@tirithen: Maybe we should open a new issue for your question, but do you mean PatchMake? |
I wanted a way to create a diff/patch string and then I wanted to be able to apply that string. I could not understand how to do this full cycle of diffing and patching |
You can for example do that like this: diffs := dmp.DiffMain(text1, text2, true)
patches := dmp.PatchMake(text1, diffs)
patchText := dmp.PatchToText(patches)
patchesFromText, _ := dmp.PatchFromText(patchText)
text2FromPatches, _ := dmp.PatchApply(patchesFromText, text1) |
Super! That seem to be it! ;D Got a bit lost in all the methods. |
Yeah, I will partly fix this with #53. Would you be interested in helping me out with the examples? I only have so much time to work on OSS so I would highly appreciate some help. |
Complicated. Imagine a wiki. Data typesHistory data type type History struct {
ID string
EntryID string
Date time.Time
PatchText string
PreviousHistoryID string
} Entry data type type Entry struct {
ID string
Content string
} When I have New Entry:
Update Entry:
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(new, old, true)
patches := dmp.PatchMake(new, diffs)
patchText := dmp.PatchToText(patches)
Revert to History point
for each of the History entries dmp := diffmatchpatch.New()
patchesFromText, _ := dmp.PatchFromText(patchText)
text2FromPatches, _ := dmp.PatchApply(patchesFromText, new) How does Mediawiki do it? I think I'll just store the old version in the history database without any diffing, only use diff to display differences between revisions.
Sometimes you need "a rubberducky" to talk to, maybe others will have the same problem and read it. |
go-diff is currently lacking examples for each exported function and method. This would not only help other users but make the whole project a lot better and complete.
The text was updated successfully, but these errors were encountered: