Exemple #1
0
        public static void CollectActions(SourceLine[] source,
			VersionLine[] version1,
			VersionLine[] version2,
			List<MergeAction> removeActions,
			List<MergeAction> insertActions)
        {
            int si = 0, v1 = 0, v2 = 0;
            while (si < source.Length || v1 < version1.Length || v2 < version2.Length) {
                if (v1 < version1.Length) {
                    if (version1[v1].SourcePositon >= 0) {
                        v1++;
                    } else {
                        var sp = v1 - 1 >= 0 ? version1[v1 - 1].SourcePositon : 0;
                        var mergeAction = new MergeAction(sp);
                        while (v1 < version1.Length && version1[v1].SourcePositon < 0) {
                            mergeAction.Lines.Add(version1[v1]);
                            v1++;
                        }

                        insertActions.Add(mergeAction);
                    }
                }

                if (v2 < version2.Length) {
                    if (version2[v2].SourcePositon >= 0) {
                        v2++;
                    } else {
                        var sp = v2 - 1 >= 0 ? version2[v2 - 1].SourcePositon : 0;
                        var mergeAction = new MergeAction(sp);
                        while (v2 < version2.Length && version2[v2].SourcePositon < 0) {
                            mergeAction.Lines.Add(version2[v2]);
                            v2++;
                        }
                        insertActions.Add(mergeAction);
                    }
                }

                if (si < source.Length) {
                    if (source[si].ExistsFlag != 2) {
                        var mergeAction = new MergeAction(si);
                        mergeAction.Lines.Add(source[si]);
                        removeActions.Add(mergeAction);
                    }
                    si++;
                }
            }
        }
Exemple #2
0
        public bool IsEqualContents(MergeAction comp)
        {
            if (MergePosition != comp.MergePosition) {
                return false;
            }
            if (Lines.Count != comp.Lines.Count) {
                return false;
            }

            for (var i = 0; i < Lines.Count; i++) {
                if (Lines[i].TrimedContent != comp.Lines[i].TrimedContent) {
                    return false;
                }
            }

            return true;
        }
Exemple #3
0
        public bool IsEqualContents(MergeAction comp)
        {
            if (MergePosition != comp.MergePosition)
            {
                return(false);
            }
            if (Lines.Count != comp.Lines.Count)
            {
                return(false);
            }

            for (var i = 0; i < Lines.Count; i++)
            {
                if (Lines[i].TrimedContent != comp.Lines[i].TrimedContent)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #4
0
        public static void CollectActions(SourceLine[] source,
                                          VersionLine[] version1,
                                          VersionLine[] version2,
                                          List <MergeAction> removeActions,
                                          List <MergeAction> insertActions)
        {
            int si = 0, v1 = 0, v2 = 0;

            while (si < source.Length || v1 < version1.Length || v2 < version2.Length)
            {
                if (v1 < version1.Length)
                {
                    if (version1[v1].SourcePositon >= 0)
                    {
                        v1++;
                    }
                    else
                    {
                        var sp          = v1 - 1 >= 0 ? version1[v1 - 1].SourcePositon : 0;
                        var mergeAction = new MergeAction(sp);
                        while (v1 < version1.Length && version1[v1].SourcePositon < 0)
                        {
                            mergeAction.Lines.Add(version1[v1]);
                            v1++;
                        }

                        insertActions.Add(mergeAction);
                    }
                }

                if (v2 < version2.Length)
                {
                    if (version2[v2].SourcePositon >= 0)
                    {
                        v2++;
                    }
                    else
                    {
                        var sp          = v2 - 1 >= 0 ? version2[v2 - 1].SourcePositon : 0;
                        var mergeAction = new MergeAction(sp);
                        while (v2 < version2.Length && version2[v2].SourcePositon < 0)
                        {
                            mergeAction.Lines.Add(version2[v2]);
                            v2++;
                        }
                        insertActions.Add(mergeAction);
                    }
                }

                if (si < source.Length)
                {
                    if (source[si].ExistsFlag != 2)
                    {
                        var mergeAction = new MergeAction(si);
                        mergeAction.Lines.Add(source[si]);
                        removeActions.Add(mergeAction);
                    }
                    si++;
                }
            }
        }