Mercurial > hg > soundsoftware-site
comparison lib/diff.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 513646585e45 |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
7 astart = 0 | 7 astart = 0 |
8 bstart = 0 | 8 bstart = 0 |
9 afinish = a.length-1 | 9 afinish = a.length-1 |
10 bfinish = b.length-1 | 10 bfinish = b.length-1 |
11 mvector = [] | 11 mvector = [] |
12 | 12 |
13 # First we prune off any common elements at the beginning | 13 # First we prune off any common elements at the beginning |
14 while (astart <= afinish && bstart <= afinish && a[astart] == b[bstart]) | 14 while (astart <= afinish && bstart <= afinish && a[astart] == b[bstart]) |
15 mvector[astart] = bstart | 15 mvector[astart] = bstart |
16 astart += 1 | 16 astart += 1 |
17 bstart += 1 | 17 bstart += 1 |
18 end | 18 end |
19 | 19 |
20 # now the end | 20 # now the end |
21 while (astart <= afinish && bstart <= bfinish && a[afinish] == b[bfinish]) | 21 while (astart <= afinish && bstart <= bfinish && a[afinish] == b[bfinish]) |
22 mvector[afinish] = bfinish | 22 mvector[afinish] = bfinish |
23 afinish -= 1 | 23 afinish -= 1 |
24 bfinish -= 1 | 24 bfinish -= 1 |
25 end | 25 end |
26 | 26 |
27 bmatches = b.reverse_hash(bstart..bfinish) | 27 bmatches = b.reverse_hash(bstart..bfinish) |
28 thresh = [] | 28 thresh = [] |
29 links = [] | 29 links = [] |
30 | 30 |
31 (astart..afinish).each { |aindex| | 31 (astart..afinish).each { |aindex| |
32 aelem = a[aindex] | 32 aelem = a[aindex] |
33 next unless bmatches.has_key? aelem | 33 next unless bmatches.has_key? aelem |
34 k = nil | 34 k = nil |
35 bmatches[aelem].reverse.each { |bindex| | 35 bmatches[aelem].reverse.each { |bindex| |
116 @curdiffs = [] | 116 @curdiffs = [] |
117 makediff(diffs_or_a, b) | 117 makediff(diffs_or_a, b) |
118 @difftype = diffs_or_a.class | 118 @difftype = diffs_or_a.class |
119 end | 119 end |
120 end | 120 end |
121 | 121 |
122 def match(ai, bi) | 122 def match(ai, bi) |
123 @diffs.push @curdiffs unless @curdiffs.empty? | 123 @diffs.push @curdiffs unless @curdiffs.empty? |
124 @curdiffs = [] | 124 @curdiffs = [] |
125 end | 125 end |
126 | 126 |