Rust: the issue of filenames and Python interop
raphael.gomes at octobus.net
Tue Aug 27 10:54:26 EDT 2019
On 8/27/19 3:37 PM, Yuya Nishihara wrote:
> Using Path/PathBuf is probably good for paths like repo.root, but we have
> other kind of paths, to be stored in changelog/manifest/dirstate. These data
> must be byte-transparent, may contain invalid character on some platforms,
> and have different rules (e.g. \ vs / on Windows.) So I don't think they
> can be backed by Path/PathBuf. Maybe we'll need our own HgPath type and
> allow conversion to Path/PathBuf/[u8]/str, etc.
I suppose having an HgPath type will help abstract the issue somewhat,
regardless of whether a better solution exists.
> Regarding Windows filenames, Mercurial uses ANSI (or MBCS) encoding, whereas
> Rust OsStr is basically a Unicode (WTF-8.) If WindowsUTF8Plain is implemented,
> things will get more complicated. Filenames may be either ANSI or UTF-8,
> so we'll have to select the codec per repository.
Am I correct in saying our main issue is that paths can be created and
used by different platforms? Should we split "local-only" paths to use
Rust's OsString and "shared" paths to use HgPath?
Here I am, hoping that there is a solution that is simpler than
re-implementing half Rust's stdlib Path.
More information about the Mercurial-devel