PatchMake computes a list of patches.
(opt ...interface{})
| 113 | |
| 114 | // PatchMake computes a list of patches. |
| 115 | func (dmp *DiffMatchPatch) PatchMake(opt ...interface{}) []Patch { |
| 116 | if len(opt) == 1 { |
| 117 | diffs, _ := opt[0].([]Diff) |
| 118 | text1 := dmp.DiffText1(diffs) |
| 119 | return dmp.PatchMake(text1, diffs) |
| 120 | } else if len(opt) == 2 { |
| 121 | text1 := opt[0].(string) |
| 122 | switch t := opt[1].(type) { |
| 123 | case string: |
| 124 | diffs := dmp.DiffMain(text1, t, true) |
| 125 | if len(diffs) > 2 { |
| 126 | diffs = dmp.DiffCleanupSemantic(diffs) |
| 127 | diffs = dmp.DiffCleanupEfficiency(diffs) |
| 128 | } |
| 129 | return dmp.PatchMake(text1, diffs) |
| 130 | case []Diff: |
| 131 | return dmp.patchMake2(text1, t) |
| 132 | } |
| 133 | } else if len(opt) == 3 { |
| 134 | return dmp.PatchMake(opt[0], opt[2]) |
| 135 | } |
| 136 | return []Patch{} |
| 137 | } |
| 138 | |
| 139 | // patchMake2 computes a list of patches to turn text1 into text2. |
| 140 | // text2 is not provided, diffs are the delta between text1 and text2. |