sapling/lib/util
Jun Wu 3e73af0a9a util: add a function to get absolute path without resolving symlinks
Summary:
On Windows, some people use the "map drive" feature to map a long path (ex.
`C:\long\path\to\repo`) to a short path (ex. `Z:\`) so their tooling can
handle some long paths.

In that case, resolving symlinks by `hg root` is undesirable.

Unfortunately, the Rust stdlib does not have a Python `os.path.abspath`
equivalent. There were some attempts (ex. https://github.com/rust-lang/rust/pull/47363)
but the corner cases (ex. symlinks) have made the problem much more
complicated.

There are some 3rd-party crates. But they are not a good fit:
- https://github.com/danreeves/path-clean/ (last commit fb84930) follows the golang plan9 idea. It does not have proper support for Windows paths.
- https://github.com/vitiral/path_abs/ (latest commit 8370838) reinvents many path-related types, which is an overkill for this usecase.

This diff implements the feature "reasonably" for both Windows and Linux, with
nasty corner cases (symlink) ignored.

Differential Revision: D16952485

fbshipit-source-id: ba91f4975c2e018362e2530119765a380f103e19
2019-08-21 17:59:50 -07:00
..
src util: add a function to get absolute path without resolving symlinks 2019-08-21 17:59:50 -07:00
Cargo.toml bindings: move configparser path normalization to a new util crate 2019-08-20 16:40:25 -07:00