escape repository path

Summary:
On Windows, paths components are usually separated by '\', and since the
repository path is stored in a toml file, whatever character is after a '\',
will be escaped. In my case, this is followed by U (for C:\Users), and thus
toml expects the next characters to be an escaped unicode. That's obviously
not the case and thus EdenFS fails to parse the config, preventing me from
cloning fbsource.

Since Windows is perfectly fine with '/' as path separator, let's just
replace '\' with '/'.

The underlying bug appears to be in the toml Python code: https://github.com/uiri/toml/issues/280

Manually trying some random path is pretty conclusive:
  (Pdb) toml.dumps({'foo': 'c:\\Users\\wez'})
  'foo = "c:\\\\Users\\\\wez"\n'
  (Pdb) toml.dumps({'foo': 'c:\\Users\\xavier'})
  'foo = "c:\\Users\\xavier"\n'

Reviewed By: chadaustin

Differential Revision: D21143545

fbshipit-source-id: 448471da12c253dd37680f6a28251a1e69850920
This commit is contained in:
Xavier Deguillard 2020-04-20 21:01:47 -07:00 committed by Facebook GitHub Bot
parent 1d231ebac7
commit 97cdd3a4d1

View File

@ -815,7 +815,8 @@ class EdenCheckout:
redirections = {k: str(v) for k, v in checkout_config.redirections.items()}
config_data = {
"repository": {
"path": str(checkout_config.backing_repo),
# TODO: replace is needed to workaround a bug in toml
"path": str(checkout_config.backing_repo).replace("\\", "/"),
"type": checkout_config.scm_type,
},
"redirections": redirections,