D3737: crecord: fix line number in hunk header (issue5917)

quark (Jun Wu) phabricator at mercurial-scm.org
Thu Jun 14 18:27:53 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG03350f5234a4: crecord: fix line number in hunk header (issue5917) (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3737?vs=9065&id=9066

REVISION DETAIL
  https://phab.mercurial-scm.org/D3737

AFFECTED FILES
  mercurial/crecord.py
  tests/test-commit-interactive-curses.t

CHANGE DETAILS

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,14 @@
   @@ -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"
+  $ hg update -C '.^' -q
+
 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.
@@ -236,7 +244,7 @@
   > X
   > EOF
   $ printf "printf 'editor ran\n'; exit 0" > editor.sh
-  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit  -i -m "edit hunk" -d "0 0"
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit  -i -m "edit hunk" -d "0 0" -q
   editor ran
   $ hg cat -r . x
   foo
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -398,7 +398,7 @@
         if fromline != 0:
             if fromlen == 0:
                 fromline -= 1
-            if tolen == 0:
+            if tolen == 0 and toline > 0:
                 toline -= 1
 
         fromtoline = '@@ -%d,%d +%d,%d @@%s\n' % (



To: quark, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list