sapling/lib
Kostia Balytskyi 60f81d3be2 hg.rust: only use backslashes in canonicalized paths on Win
Summary:
We need to canonicalize `current_exe` to resolve symlinks on OSX.

Unfortunetely, on there's no way to just resolve symlinks and not
turn path into a `\\?\` on Windows, AFAIK.

Once the path is canonicalized on Windows, it starts with `\\?\` and
forward slashes are no longer recognized as valid separators.

Here's a demonstration:
```
> cat src\main.rs
use std::path::Path;
fn main() {
    let p = Path::new("\\\\?\\C:\\Code\\fbsource\\fbcode\\scm\\hg\\mercurial/entrypoint.py");
    for comp in p.components() { println!("{:?}", comp); }
    println!("{:?} exists: {}", p, p.exists());
    let p = Path::new("\\\\?\\C:\\Code\\fbsource\\fbcode\\scm\\hg\\mercurial\\entrypoint.py");
    for comp in p.components() { println!("{:?}", comp); }
    println!("{:?} exists: {}", p, p.exists());
    let p = Path::new("C:\\Code\\fbsource\\fbcode\\scm\\hg\\mercurial/entrypoint.py");
    for comp in p.components() { println!("{:?}", comp); }
    println!("{:?} exists: {}", p, p.exists());

}

> cargo run
Prefix(PrefixComponent { raw: "\\\\?\\C:", parsed: VerbatimDisk(67) })
RootDir
Normal("Code")
Normal("fbsource")
Normal("fbcode")
Normal("scm")
Normal("hg")
Normal("mercurial/entrypoint.py")
"\\\\?\\C:\\Code\\fbsource\\fbcode\\scm\\hg\\mercurial/entrypoint.py" exists: false
Prefix(PrefixComponent { raw: "\\\\?\\C:", parsed: VerbatimDisk(67) })
RootDir
Normal("Code")
Normal("fbsource")
Normal("fbcode")
Normal("scm")
Normal("hg")
Normal("mercurial")
Normal("entrypoint.py")
"\\\\?\\C:\\Code\\fbsource\\fbcode\\scm\\hg\\mercurial\\entrypoint.py" exists: true
Prefix(PrefixComponent { raw: "C:", parsed: Disk(67) })
RootDir
Normal("Code")
Normal("fbsource")
Normal("fbcode")
Normal("scm")
Normal("hg")
Normal("mercurial")
Normal("entrypoint.py")
"C:\\Code\\fbsource\\fbcode\\scm\\hg\\mercurial/entrypoint.py" exists: true
```

Differential Revision: D13176266

fbshipit-source-id: 5f35a3263e058d179b237c80f28e4fdf44105576
2018-11-23 04:28:11 -08:00
..
argparse codemod: add copyright headers 2018-10-26 15:09:12 -07:00
bookmarkstore codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
cdatapack hg: disable check-code tests for C code 2018-06-05 19:21:43 -07:00
clib Started Eden for Windows and integrated hg store with it. 2018-08-21 17:51:26 -07:00
commitcloudsubscriber codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
configparser tests: add a test-check test that runs fix-code.py 2018-11-15 18:54:06 -08:00
encoding encoding: use Cow for returned types that may be references 2018-10-30 04:07:02 -07:00
hg_watchman_client codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
hgpython hg.rust: only use backslashes in canonicalized paths on Win 2018-11-23 04:28:11 -08:00
indexedlog codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
linelog linelog: update README 2018-11-08 12:34:36 -08:00
lz4-pyframe codemod: add copyright headers 2018-10-26 15:09:12 -07:00
minibench codemod: add copyright headers 2018-10-26 15:09:12 -07:00
mpatch codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
mpatch-sys codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
pathmatcher codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
radixbuf codemod: add copyright headers 2018-10-26 15:09:12 -07:00
revisionstore tests: add a test-check test that runs fix-code.py 2018-11-15 18:54:06 -08:00
third-party xdiff: backport upstream changes 2018-04-13 21:51:48 -07:00
treestate codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
types codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
vlqencoding vlqencoding: don't require Sized for Read or Write traits 2018-10-29 04:10:46 -07:00
watchman_client codemod: use explicit versions in Cargo.toml 2018-11-15 18:54:06 -08:00
zstdelta rust: upgrade rust to 1.30.0 and bump zstd-sys version 2018-11-06 18:13:20 -08:00
Cargo.toml packaging: back out D10213071 to fix continuous build 2018-10-08 08:54:08 -07:00
README.md READMEs: tweaks based on feedback 2018-01-12 12:35:52 -08:00

lib

Any native code (C/C++/Rust) that Mercurial (either core or extensions) depends on should go here. Python code, or native code that depends on Python code (e.g. #include <Python.h> or use cpython) is disallowed.

As we start to convert more of Mercurial into Rust, and write new paths entrirely in native code, we'll want to limit our dependency on Python, which is why this barrier exists.

See also hgext/extlib/README.md, mercurial/cext/README.mb.

How do I choose between lib and extlib (and cext)?

If your code is native and doesn't depend on Python (awesome!), it goes here.

Otherwise, put it in hgext/extlib (if it's only used by extensions) or mercurial/cext (if it's used by extensions or core).