mercurial/patch.py
branchstable
changeset 15462 2b1ec74c961f
parent 15363 628a4a9e411d
child 15510 5414b56cfad6
child 15582 3da1f60fc80d
--- a/mercurial/patch.py	Tue Nov 08 17:08:58 2011 +0100
+++ b/mercurial/patch.py	Wed Nov 09 16:55:59 2011 -0800
@@ -723,11 +723,10 @@
 
         # fast case first, no offsets, no fuzz
         old = h.old()
-        # patch starts counting at 1 unless we are adding the file
-        if h.starta == 0:
-            start = 0
-        else:
-            start = h.starta + self.offset - 1
+        start = h.starta + self.offset
+        # zero length hunk ranges already have their start decremented
+        if h.lena:
+            start -= 1
         orig_start = start
         # if there's skew we want to emit the "(offset %d lines)" even
         # when the hunk cleanly applies at start + skew, so skip the