tests/test-revert-interactive-curses.t
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 04 Nov 2022 17:35:44 -0400
changeset 49572 c4f07a011714
parent 49034 079197e94b24
permissions -rw-r--r--
util: implement `writelines()` on atomictempfile With typehints on the vfs objects, pytype will flag this: FAILED: /mnt/c/Users/Matt/hg/.pytype/pyi/mercurial/patch.pyi /usr/bin/python3.8 -m pytype.single --imports_info /mnt/c/Users/Matt/hg/.pytype/imports/mercurial.patch.imports --module-name mercurial.patch -V 3.7 -o /mnt/c/Users/Matt/hg/.pytype/pyi/mercurial/patch.pyi --analyze-annotated --nofail --quick /mnt/c/Users/Matt/hg/mercurial/patch.py File "/mnt/c/Users/Matt/hg/mercurial/patch.py", line 535, in writerej: No attribute 'writelines' on mercurial.util.atomictempfile [attribute-error] In Union[ mercurial.util.atomictempfile, mercurial.vfs.checkambigatclosing, mercurial.vfs.delayclosedfile, mercurial.windows.fdproxy, mercurial.windows.mixedfilemodewrapper ] It's not a real problem there (atomictempfile is only created by passing different args), but it's reasonable for this to implement the function and behave like a normal file. There are other functions missing that can be added if/when needed.

#require curses
#testcases committed wdir

Revert interactive tests with the Curses interface

  $ cat <<EOF >> $HGRCPATH
  > [ui]
  > interactive = true
  > interface = curses
  > [experimental]
  > crecordtest = testModeCommands
  > EOF

TODO: Make a curses version of the other tests from test-revert-interactive.t.

#if committed
  $ maybe_commit() {
  >   hg ci "$@"
  > }
  $ do_revert() {
  >   hg revert -ir'.^'
  > }
#else
  $ maybe_commit() {
  >   true
  > }
  $ do_revert() {
  >   hg revert -i
  > }
#endif

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
  $ printf 1 >> a
  $ maybe_commit -qAm 1
  $ cat a
  0
  1 (no-eol)

  $ cat <<EOF >testModeCommands
  > c
  > EOF

  $ do_revert
  reverting 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
  $ printf 0 > a
  $ hg ci -qAm 0
  $ echo 0 > a
  $ maybe_commit -qAm 1
  $ cat a
  0

  $ cat <<EOF >testModeCommands
  > c
  > EOF

  $ do_revert
  reverting a
  $ cat a
  0 (no-eol)