From 7db5236a835dc9940c05f997610a16fa3a7400d9 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Wed, 9 Oct 2013 17:51:53 +0200 Subject: Add a "critical adjustment" as a "misordered hunks" guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- fix-offsets | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fix-offsets b/fix-offsets index e036a46..5635c8b 100755 --- a/fix-offsets +++ b/fix-offsets @@ -113,16 +113,24 @@ def proceed(opts, args): avg /= cnt ts[i] = False for i in xrange(len_ts): + hunk = p.hunks[i] + if i > 0 and hunk.startsrc < p.hunks[i-1].startsrc: #+ p.hunks[i-1].linessrc: + #print >>sys.stderr, "Critical adjustment: {0}".format(i+1) + p.hunks[i-1].startsrc = hunk.startsrc - p.hunks[i-1].linessrc + for ii in xrange(i-1, len_ts): + ts[i] = True + break ts[i] = ts[i] or abs(tres[i] - avg) > avg_limit if i > 0: ts[i] = ts[i] or abs(tres[i] - tres[i-1]) > (avg_limit/2) if i < len_ts - 1: ts[i] = ts[i] or abs(tres[i] - tres[i+1]) > (avg_limit/2) if ts[i]: - hunk = p.hunks[i] delta = int(tres[i] + (tres[i] - avg) / 1.25) hunk.startsrc += delta hunk.starttgt += delta + else: + continue avg_limit *= 1.25 for i in xrange(len_ts): delta = tres[i] -- cgit