changeset 98:55cf805769eb

- closes issue #36: unable to commit changes to previously empty file
author Mark Edgington <edgimar@gmail.com>
date Sat, 19 Jan 2013 08:18:52 -0500
parents 1a1d114b56be
children 2dfb2c4c6612
files crecord/crpatch.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/crecord/crpatch.py
+++ b/crecord/crpatch.py
@@ -472,11 +472,13 @@
         # precedes the hunk."
         #
         # So, if either of hunks is empty, decrease its line start. --immerrr
+        # But only do this if fromline > 0, to avoid having, e.g fromline=-1.
         fromline,toline = self.fromline, self.toline
-        if fromlen == 0:
-            fromline -= 1
-        if tolen == 0:
-            toline -= 1
+        if fromline != 0:
+            if fromlen == 0:
+                fromline -= 1
+            if tolen == 0:
+                toline -= 1
 
         fromToLine = '@@ -%d,%d +%d,%d @@%s\n' % (
             fromline, fromlen, toline, tolen,