summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2013-10-09 21:49:56 +0200
committerJan Pokorný <jpokorny@redhat.com>2013-10-09 21:49:56 +0200
commitc24ebb9642c429cd5e8f0c4a80773e2d5b44cf2a (patch)
treec8067beb855a00d20e4b2bff6291a5523b94700b
parent1fb79e8d678346b71fa85f361f2c6099daf6ba11 (diff)
downloadpatch-fix-offsets-c24ebb9642c429cd5e8f0c4a80773e2d5b44cf2a.tar.gz
patch-fix-offsets-c24ebb9642c429cd5e8f0c4a80773e2d5b44cf2a.tar.xz
patch-fix-offsets-c24ebb9642c429cd5e8f0c4a80773e2d5b44cf2a.zip
"misordered hunks" guard: skip moving very first hunk
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rwxr-xr-xfix-offsets9
1 files changed, 4 insertions, 5 deletions
diff --git a/fix-offsets b/fix-offsets
index d9737e2..7035b05 100755
--- a/fix-offsets
+++ b/fix-offsets
@@ -135,18 +135,17 @@ def proceed(opts, args):
cnt += 1
avg /= cnt
ts[i] = False
- for i in xrange(len_ts):
+ for i in xrange(1, len_ts):
hunk = p.hunks[i]
- if i > 0 and hunk.startsrc < p.hunks[i-1].startsrc: #+ p.hunks[i-1].linessrc:
+ if hunk.startsrc < p.hunks[i-1].startsrc: #+ p.hunks[i-1].linessrc:
# "misordered hunks" guard
#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
+ ts[ii] = 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)
+ 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]: