public void PatchMatchesText_Previous(FileSet set) { var updatedPreviousText = new List <string>(set.PreviousLines); foreach (var(patchIdx, patch) in set.ReviewPatch.AsIndexed()) { var actual = updatedPreviousText.Slice(patch.Start1, patch.Length1); var expected = patch.PreviousLines().ToList(); Assert.That(actual, Is.EqualTo(expected), $"Patch index {patchIdx} Expected position: {patch.Start1}"); LinePatchOps.ApplyPatch(patch, updatedPreviousText); } }
public static List <(DiffClassification classification, LinePatch Patch)> ClassifyPatches(List <string> reviewText1, List <LinePatch> basePatch, List <LinePatch> reviewPatch) { var classifiedPatches = new List <(DiffClassification classification, LinePatch Patch)>(); var unusedBasePatches = new List <LinePatch>(basePatch); var rollingText = new List <string>(reviewText1); foreach (var patch in reviewPatch) { LinePatchOps.ApplyPatch(patch, rollingText); var basePatchIndex = unusedBasePatches.FindIndex(bp => ArePatchesMatching(bp, rollingText, patch)); if (basePatchIndex == -1) { classifiedPatches.Add((DiffClassification.ReviewChange, patch)); continue; } classifiedPatches.Add((DiffClassification.BaseChange, patch)); unusedBasePatches.RemoveRange(0, basePatchIndex + 1); } return(classifiedPatches); }