sapling/eden/scm/tests/test-revert-interactive-curses.t
Muir Manders db5d2b1b86 revert: fix interactive "no EOF newline" handling
Summary:
When using curses during interactive revert, we now properly handle the transition to or from having no newline at the end of file. We do this by peeking ahead one line and trimming the apparent newline if the next line is "No newline at end of file".

This is motivated by upstream https://phab.mercurial-scm.org/D8762, but that test didn't exercise the bug for me, and the code change didn't work properly when reverting back to the no-newline case.

Reviewed By: quark-zju

Differential Revision: D33541600

fbshipit-source-id: 6e605fe2f6017baad0aa8232313a209f68fc871c
2022-01-14 15:44:52 -08:00

47 lines
779 B
Raku

#require tic
Revert interactive tests with the Curses interface
$ cat <<EOF >> $HGRCPATH
> [ui]
> interactive = true
> interface = curses
> [experimental]
> crecordtest = testModeCommands
> EOF
When a line without EOL is selected during "revert -i"
$ hg init $TESTTMP/revert-i-curses-eol
$ cd $TESTTMP/revert-i-curses-eol
$ echo 0 > a
$ hg ci -qAm 0
$ echo -n 1 >> a
$ cat a
0
1 (no-eol)
$ cat <<EOF >testModeCommands
> c
> EOF
$ hg revert -i a
$ cat a
0
When a selected line is reverted to have no EOL
$ hg init $TESTTMP/revert-i-curses-eol2
$ cd $TESTTMP/revert-i-curses-eol2
$ echo -n boo > a
$ hg ci -qAm 0
$ echo blah > a
$ cat <<EOF >testModeCommands
> c
> EOF
$ hg revert -i a
$ cat a
boo (no-eol)