コード例 #1
0
		public static IList MergeLists(IList original, IList[] changed, IComparer comparer, IEqualityComparer hashcoder) {
			Merge m = new Merge(original, changed, comparer, hashcoder);
			ArrayList ret = new ArrayList();
			ArrayList newlines = new ArrayList();
			foreach (Hunk h in m) {
				newlines.Clear();
				
				for (int i = 0; i < changed.Length; i++)
					if (!h.IsSame(i))
						newlines.Add(h.Changes(i));
				
				// If there were no differences in this region, take the original.
				if (newlines.Count == 0)
					ret.AddRange(h.Original());
				
				// If one list has changes, take them
				else if (newlines.Count == 1)
					ret.AddRange((Range)newlines[0]);
				
				// Indicate conflict
				else
					ret.Add(new Conflict((Range[])newlines.ToArray(typeof(Range))));
			}
			return ret;
		}
コード例 #2
0
			internal Hunk(Merge merge, Diff.Hunk[][] hunks, int start, int count, bool same) {
				this.merge = merge;
				this.hunks = hunks;
				this.start = start;
				this.count = count;
				this.same = same;
				
				int ct = 0;
				foreach (Diff.Hunk[] hh in hunks) {
					foreach (Diff.Hunk h in hh) {
						if (!h.Same) {
							ct++;
							break;
						}
					}
				}
				conflict = (ct > 1);
			}
コード例 #3
0
		public DiffWidget(Merge merge, Options options) : this(Hunkify(merge), options) 
		{
		}