Ejemplo n.º 1
0
        private MatchResult match(DiffRefs diffRefs, DiffToolInfo difftoolInfo)
        {
            FullContextDiffProvider provider = new FullContextDiffProvider(_gitRepository);
            FullContextDiff         context  =
                provider.GetFullContextDiff(diffRefs.LeftSHA, diffRefs.RightSHA,
                                            difftoolInfo.Left?.FileName ?? null, difftoolInfo.Right?.FileName ?? null);

            Debug.Assert(context.Left.Count == context.Right.Count);

            bool isCurrentSideLeft = difftoolInfo.IsLeftSideCurrent;

            DiffToolInfo.Side currentSide = isCurrentSideLeft ? difftoolInfo.Left.Value : difftoolInfo.Right.Value;

            SparsedList <string> firstList  = isCurrentSideLeft ? context.Left : context.Right;
            SparsedList <string> secondList = isCurrentSideLeft ? context.Right : context.Left;

            SparsedListIterator <string> itFirst  = SparsedListUtils.FindNth(firstList.Begin(), currentSide.LineNumber - 1);
            SparsedListIterator <string> itSecond = SparsedListUtils.Advance(secondList.Begin(), itFirst.Position);

            return(new MatchResult
            {
                LeftLineNumber = isCurrentSideLeft ? currentSide.LineNumber : itSecond.LineNumber + 1,
                RightLineNumber = isCurrentSideLeft ? itSecond.LineNumber + 1 : currentSide.LineNumber
            });
        }
Ejemplo n.º 2
0
        private int?getOppositeLine(DiffRefs refs, bool isLeftSide, string leftFileName, string rightFileName,
                                    int lineNumber)
        {
            FullContextDiff context = _git.FullContextDiffProvider.GetFullContextDiff(
                refs.LeftSHA, refs.RightSHA, leftFileName, rightFileName);

            Debug.Assert(context.Left.Count == context.Right.Count);

            SparsedList <string> currentList  = isLeftSide ? context.Left : context.Right;
            SparsedList <string> oppositeList = isLeftSide ? context.Right : context.Left;

            SparsedListIterator <string> itCurrentList  = SparsedListUtils.FindNth(currentList.Begin(), lineNumber - 1);
            SparsedListIterator <string> itOppositeList = SparsedListUtils.Advance(oppositeList.Begin(), itCurrentList.Position);

            return(itOppositeList.GetLineNumber() == null ? new int?() : itOppositeList.GetLineNumber().Value + 1);
        }
Ejemplo n.º 3
0
 public FullContextDiff(SparsedList <string> left, SparsedList <string> right)
 {
     Left  = left;
     Right = right;
 }