Mercurial > hg-stable
changeset 16090:e1d8218d733b
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 06 Feb 2012 15:36:44 -0600 |
parents | 6c1daae0ae7b (current diff) 2e8f4b82c551 (diff) |
children | 914bc95e227b |
files | |
diffstat | 3 files changed, 54 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/mdiff.py Mon Feb 06 15:22:43 2012 -0600 +++ b/mercurial/mdiff.py Mon Feb 06 15:36:44 2012 -0600 @@ -268,14 +268,23 @@ # them into diff output. # hunk = None + ignoredlines = 0 for s, stype in allblocks(t1, t2, opts, l1, l2): + a1, a2, b1, b2 = s if stype != '!': + if stype == '~': + # The diff context lines are based on t1 content. When + # blank lines are ignored, the new lines offsets must + # be adjusted as if equivalent blocks ('~') had the + # same sizes on both sides. + ignoredlines += (b2 - b1) - (a2 - a1) continue delta = [] - a1, a2, b1, b2 = s old = l1[a1:a2] new = l2[b1:b2] + b1 -= ignoredlines + b2 -= ignoredlines astart = contextstart(a1) bstart = contextstart(b1) prev = None
--- a/tests/test-diff-ignore-whitespace.t Mon Feb 06 15:22:43 2012 -0600 +++ b/tests/test-diff-ignore-whitespace.t Mon Feb 06 15:36:44 2012 -0600 @@ -455,3 +455,46 @@ +hello +world goodbye world + +Test hunk offsets adjustments with --ignore-blank-lines + + $ hg revert -aC + reverting foo + $ printf '\nb\nx\nd\n' > a + $ printf 'b\ny\nd\n' > b + $ hg add a b + $ hg ci -m add + $ hg cat -r . a > b + $ hg cat -r . b > a + $ hg diff -B --nodates a > ../diffa + $ cat ../diffa + diff -r 0e66aa54f318 a + --- a/a + +++ b/a + @@ -1,4 +1,4 @@ + + b + -x + +y + d + $ hg diff -B --nodates b > ../diffb + $ cat ../diffb + diff -r 0e66aa54f318 b + --- a/b + +++ b/b + @@ -1,3 +1,3 @@ + b + -y + +x + d + $ hg revert -aC + reverting a + reverting b + $ hg import --no-commit ../diffa + applying ../diffa + $ hg revert -aC + reverting a + $ hg import --no-commit ../diffb + applying ../diffb + $ hg revert -aC + reverting b