summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2013-10-09 17:51:53 +0200
committerJan Pokorný <jpokorny@redhat.com>2013-10-09 17:51:53 +0200
commit7db5236a835dc9940c05f997610a16fa3a7400d9 (patch)
treecf1c31f9699a026201d5d0d27960fcb67a6d830a
parent6447002182fecbc691c977fe4a4a2f1d8498105e (diff)
downloadpatch-fix-offsets-7db5236a835dc9940c05f997610a16fa3a7400d9.zip
patch-fix-offsets-7db5236a835dc9940c05f997610a16fa3a7400d9.tar.gz
patch-fix-offsets-7db5236a835dc9940c05f997610a16fa3a7400d9.tar.xz
Add a "critical adjustment" as a "misordered hunks" guard
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rwxr-xr-xfix-offsets10
1 files changed, 9 insertions, 1 deletions
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]