--- a/mercurial/mdiff.py Thu Nov 27 16:07:17 2008 +0100
+++ b/mercurial/mdiff.py Thu Nov 27 17:00:54 2008 +0100
@@ -160,7 +160,7 @@
if opts.showfunc:
# walk backwards from the start of the context
# to find a line starting with an alphanumeric char.
- for x in xrange(astart, -1, -1):
+ for x in xrange(astart - 1, -1, -1):
t = l1[x].rstrip()
if funcre.match(t):
func = ' ' + t[:40]
--- a/tests/test-diff-unified Thu Nov 27 16:07:17 2008 +0100
+++ b/tests/test-diff-unified Thu Nov 27 17:00:54 2008 +0100
@@ -44,6 +44,15 @@
echo '% invalid diff.unified'
hg --config diff.unified=foo diff --nodates
-exit 0
+echo % test off-by-one error with diff -p
+hg init diffp
+cd diffp
+echo a > a
+hg ci -Ama
+rm a
+echo b > a
+echo a >> a
+echo c >> a
+hg diff -U0 -p
-
+exit 0