[PATCH]: [Bug 6373] py3 support for popen on windows vs cmdbuilder

Yuya Nishihara yuya at tcha.org
Mon Jul 20 12:03:42 UTC 2020


On Mon, 20 Jul 2020 09:41:41 +0300, Александр Литягин wrote:
> > And we might also want to leverage the encoding parameter if specified:
> >
> > def init(dest=None, ssh=None, remotecmd=None, insecure=False,
> >           encoding=None, configs=None):
> >      args = util.cmdbuilder('init', ...)
> >      args = util.tonativeargs(args, encoding=encoding)
> >      ...
> >      proc = util.popen(args)
> 
> imho, no-native encodings may invalid work, not mutched encoding may 
> lead to args corruption on a shell-side.
> 
> At least to ensure that mercurial app read it as mbcs, need pass 
> `--encoding` option, or HGENCODING env variable to child process.
> 
> An even with this encoding - mercurial have no strict polycy about wich 
> encoding use for args. But essential use native-encodig for it.
> 
> ( For else case - users porsts many bug-reports about argument parsing 
> inconsistance from command line)
> 
> Therefore, imho, more clarify and true way - use native encoding for args.

That's basically true as of now. MBCS (or the native ANSI encoding) is the
only encoding that Mercurial can handle well on Windows. However, there's
a plan to improve the interoperability between Windows and the other platforms.

https://www.mercurial-scm.org/wiki/WindowsUTF8Plan

If it's implemented, a frontend will run hg commands with HGENCODING=utf-8
to handle UTF-8 filenames transparently. For hglib users, this means spawning
the server with hglib.open(path, encoding='utf-8').

And it doesn't make sense to encode only the repository path in native
encoding if you're working with utf-8 repository.

  hg = hglib.open(repo_path.encode('mbcs'), encoding='utf-8')
  hg.cat([file_path.encode('utf-8')])

That's why I think the encoding parameter should be respected.



More information about the Mercurial-devel mailing list