Subject: Re: bug#36090: 26.1; Tramp hanging when writing version-controlled file

From: Michael Albinus <[email-masked]>
Date: Mon, 10 Jun 2019 15:09:02 +0200

Norman Gray <[email-masked]> writes:

> Michael, hello.

Hi Norman,

> I've narrowed down the problem: it's with 'pager=less' in the remote
> .hgrc.  See details below.
>
> helium:~> cat .hgrc
> [ui]
> username = Norman Gray <[email-masked]>
> [pager]
> pager = less
> helium:~>
>
> Then:
>
>> C-x C-f /scp:helium:checkouts/test/vc.txt
>
> hangs until
>
>> C-g

Well, this is what I've supposed. A pager in the way.

The problem was discussed already in <https://debbugs.gnu.org/18940>.
I've patched vc-hg.el to set HGPLAIN=1, and this works at least
partly. See tramp-notes-debug-4.txt:

> 12:04:29.776000 tramp-send-command (6) # _echo( cd /home/norman/checkouts/test/ && env LANGUAGE\=C HGPLAIN\=1 hg --config alias.status\=status --config defaults.status\= status -A vc.txt </dev/null; echo tramp_exit_status $? )_echo
> 12:04:29.902872 tramp-wait-for-regexp (6) #
> M vc.txt
> tramp_exit_status 0
> ///2df5766235934cbe1e41dec56521114c#$

This "hg status" command works, w/o any problem. But then there is a "hg
log" command, which hangs, because HGPLAIN is not set:

> 12:04:29.937969 tramp-send-command (6) # _echo( cd /usr/home/norman/checkouts/test/ && env LC_MESSAGES\=C hg log -r . -l1 --template \{if\(bookmarks\,sub\(\'\ \'\,\'\,\'\,bookmarks\)\,if\(phabdiff\,phabdiff\,shortest\(node\,6\)\)\)\} </dev/null; echo tramp_exit_status $? )_echo
> 12:04:30.107049 tramp-accept-process-output (10) # *tramp/scp helium* nil run t
> WARNING: terminal is not fully functional
> -  (press RETURN)
> 12:04:35.825130 tramp-file-name-handler (1) # Interrupt received in operation (process-file hg nil t nil log -r . -l1 --template {if(bookmarks,sub(' ',',',bookmarks),if(phabdiff,phabdiff,shortest(node,6)))})

Well, we could try to patch vc-hg.el, again. But there is a more elegant
solution, set HGPLAIN=1 yourself in Tramp. This is even explained in the
Tramp manual, for a good reason :-) See (info "(tramp) Remote processes")

Alternatively, you could try to set in .hgrc

pager = LESS='FRX' less -d

as proposed in <https://mercurial.selenic.com/wiki/PagerExtension> for
Tramp. I haven't tested this, 'tho.

Best regards, Michael.