Patchwork [Bug,5917] New: record (e.g. `hg ci -i` and `hg split`) crashes with "bad hunk #1" if diff makes a file empty

login
register
mail settings
Submitter mercurial-bugs@mercurial-scm.org
Date June 13, 2018, 7:31 p.m.
Message ID <bug-5917-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/32124/
State Not Applicable
Headers show

Comments

mercurial-bugs@mercurial-scm.org - June 13, 2018, 7:31 p.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=5917

            Bug ID: 5917
           Summary: record (e.g. `hg ci -i` and `hg split`) crashes with
                    "bad hunk #1" if diff makes a file empty
           Product: Mercurial
           Version: 4.6
          Hardware: PC
                OS: Linux
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla@mercurial-scm.org
          Reporter: martinvonz@google.com
                CC: mercurial-devel@mercurial-scm.org

Here's a patch showing a test case that passes:

Patch

diff --git a/tests/test-commit-interactive-curses.t
b/tests/test-commit-interactive-curses.t
--- a/tests/test-commit-interactive-curses.t
+++ b/tests/test-commit-interactive-curses.t
@@ -214,6 +214,16 @@  Amend option works
   @@ -0,0 +1,1 @@
   +hello world

+Make file empty
+  $ echo -n > x
+  $ cat <<EOF >testModeCommands
+  > X
+  > EOF
+  $ hg ci -i -m emptify -d "0 0"
+  abort: bad hunk #1
+  [255]
+  $ hg revert x
+
 Editing a hunk puts you back on that hunk when done editing (issue5041)
 To do that, we change two lines in a file, pretend to edit the second line,
 exit, toggle the line selected at the end of the edit and commit.