Commit Graph

6 Commits

Author SHA1 Message Date
Kostia Balytskyi
fcae2817da hgpython: use MAIN_SEPARATOR instead of backslash
Summary: I only tested the original diff of Windows, aparently.

Reviewed By: mitrandir77

Differential Revision: D13188952

fbshipit-source-id: 9dc33cb0eedb8d3c09cb7a734528f71afd7cbe8a
2018-11-26 02:28:05 -08:00
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
Kostia Balytskyi
c646d8aa2a hg.rust: canonicalize the main binary address
Summary:
This is important on OSX where `current_exe` will return the symlink address if `hg.rust` is a symlink.
Therefore, if you create a symlink to the `hg.rust` in the repo (like tests do), repo Python code won't be picked up, and the system code will be.

Reviewed By: mitrandir77

Differential Revision: D13138333

fbshipit-source-id: ffdf27329609d77bee4b8a2eecc47e02cb2dd5c8
2018-11-21 05:47:45 -08:00
Kostia Balytskyi
f2b8b4571f hgpython: rename hgenv to be buildenv
Summary: As per quark-zju's request in the earlier diff.

Reviewed By: quark-zju

Differential Revision: D10173168

fbshipit-source-id: 20ab1fbc597b8329bbfec5dabd501d202571bdec
2018-10-12 14:55:09 -07:00
Kostia Balytskyi
0946205e68 hgmain/hgpython: add copyright headers
Reviewed By: farnz

Differential Revision: D10145635

fbshipit-source-id: 0d88c18a44a86a8eb19f40ddba0c13f9570f3a76
2018-10-12 14:55:09 -07:00
Kostia Balytskyi
682e4bed1a hgpython: extract hgpython from hgmain
Summary:
Following the conversation with quark-zju, this in future will help us conditionally dynamically load
the `hgpython` `.dll`/`.so` only if we need it.

Reviewed By: quark-zju

Differential Revision: D10084949

fbshipit-source-id: c20ef014ad9922913ee36d1ec28b0555b64f7d1f
2018-10-12 14:55:09 -07:00