PatchMake computes a list of patches.
(opt ...interface{})
| 156 | |
| 157 | // PatchMake computes a list of patches. |
| 158 | func (dmp *DiffMatchPatch) PatchMake(opt ...interface{}) []Patch { |
| 159 | if len(opt) == 1 { |
| 160 | diffs, _ := opt[0].([]Diff) |
| 161 | text1 := dmp.DiffText1(diffs) |
| 162 | return dmp.PatchMake(text1, diffs) |
| 163 | } else if len(opt) == 2 { |
| 164 | text1 := opt[0].(string) |
| 165 | switch t := opt[1].(type) { |
| 166 | case string: |
| 167 | diffs := dmp.DiffMain(text1, t, true) |
| 168 | if len(diffs) > 2 { |
| 169 | diffs = dmp.DiffCleanupSemantic(diffs) |
| 170 | diffs = dmp.DiffCleanupEfficiency(diffs) |
| 171 | } |
| 172 | return dmp.PatchMake(text1, diffs) |
| 173 | case []Diff: |
| 174 | return dmp.patchMake2(text1, t) |
| 175 | } |
| 176 | } else if len(opt) == 3 { |
| 177 | return dmp.PatchMake(opt[0], opt[2]) |
| 178 | } |
| 179 | return []Patch{} |
| 180 | } |
| 181 | |
| 182 | // patchMake2 computes a list of patches to turn text1 into text2. |
| 183 | // text2 is not provided, diffs are the delta between text1 and text2. |