Rust: the issue of filenames and Python interop

Georges Racinet georges.racinet at octobus.net
Tue Aug 27 12:02:28 EDT 2019


On 8/27/19 4:54 PM, Raphaël Gomès wrote:
> 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.
I like this idea, too, especially since it will help take care of
unforeseen issues as well.
>
>> 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.
>>
>> https://www.mercurial-scm.org/wiki/WindowsUTF8Plan
>
> 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?
This sounds indeed clean to me, and I guess we'll come to really
appreciate the stability of TryInto.
>
> Here I am, hoping that there is a solution that is simpler than
> re-implementing half Rust's stdlib Path.
:-)

-- 
Georges Racinet
https://octobus.net
GPG: BF5456F4DC625443849B6E58EE20CA44EF691D39, sur serveurs publics


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20190827/797e8acc/attachment.sig>


More information about the Mercurial-devel mailing list