Commit Graph

46172 Commits

Author SHA1 Message Date
Aida Getoeva
5d7f245f80 commitcloud: support remote bookmarks sync
Summary:
Made changes to the commit cloud sync to support remote bookmarks. Here I only declared steps of future remote bookmarks sync and will add the implementation further in the stack.

Processing a merge state between cloud remote bookmarks state, last sync and local state is done earlier in the workflow, than, for example, for local bookmarks, because to update remote bookmarks we may need to fetch new public heads from the server and so need to get them first.

Reviewed By: mitrandir77

Differential Revision: D15898740

fbshipit-source-id: ca77f66b0f1244a811b4b549e5b189c5f1772708
2019-06-27 08:10:58 -07:00
Aida Getoeva
2bb6071bd8 commitcloud: add remote bookmarks to the get/update references
Summary: Adding support of remote bookmarks to the get/set references of Commit Cloud client service.

Reviewed By: mitrandir77

Differential Revision: D15852515

fbshipit-source-id: 9d5331955f5fc95ecb4bfe8e060d3b1d67952a41
2019-06-27 08:10:58 -07:00
Kostia Balytskyi
8d68e40dd2 run-tests: do not rely on PYTHONPATH for heredoctest
Summary:
PYTHONPATH is no longer a thing on Windows. Let's not rely on it
for our `heredoctest.py`-based tests

Reviewed By: mitrandir77

Differential Revision: D16028830

fbshipit-source-id: ae66d9cf194c7e3c15e44a81a18dfeeb4b68e281
2019-06-27 06:42:45 -07:00
Arun Kulshreshtha
802dbcd5a1 remotefilelog: log exception type on ssh fallback
Summary: When Eden API falls back to SSH, log the exception type and message (in addition to the traceback) to the `hg_errors` table. Note that previously, we were attempting to log the error message but failing because we were using the wrong column name. (`msg` instead of `exception_msg`).

Reviewed By: xavierd

Differential Revision: D16014833

fbshipit-source-id: 06460574f66999b1293ea31b43b5c7ec89737144
2019-06-26 20:17:11 -07:00
Brian Strauch
93780344d2 debugedenimporthelper get file size
Summary: `hg debugedenimporthelper --get-file-size PATH:REV` will print the size of the given file

Reviewed By: chadaustin, xavierd

Differential Revision: D16009279

fbshipit-source-id: 6edb01dd154a467cdd26c0ced1d4ae82411088f1
2019-06-26 17:09:14 -07:00
Arun Kulshreshtha
5b17733c4d remotefilelog: catch all exceptions during Eden API client setup
Summary: Now that Eden API returns specific exception types rather than always raising a `RuntimeError` when things go wrong, the fallback path needs to be updated to catch all exception types, not just `RuntimeError`.

Reviewed By: xavierd

Differential Revision: D16013115

fbshipit-source-id: d5c2d88acede7e70519eda8915401bb8ee394038
2019-06-26 14:40:47 -07:00
Kostia Balytskyi
85e0a72826 run-tests: do not set PYTHONUSERBASE on Windows
Summary: This was causing `Popen` to crash, since `env` had non-strings (`NoneType`)

Reviewed By: mitrandir77

Differential Revision: D16009578

fbshipit-source-id: cbed384b7d773e3de23f9a8920d85296c5deec85
2019-06-26 12:40:29 -07:00
Kostia Balytskyi
9125f0d9e8 run-tests: avoid dead lock when calling a child process
Summary: If `subprocess.Popen` crashes, the lock is never released.

Reviewed By: mitrandir77

Differential Revision: D16009579

fbshipit-source-id: e27137826ffb29aa1f497a3c4c85160b183f2a51
2019-06-26 12:40:29 -07:00
Jun Wu
282fb28151 amend: show deprecation warnings about --fixup
Summary:
`--fixup` is not really a great flag name and it came from a legacy
implementation.  Suggest `restack` instead.

Reviewed By: kulshrax

Differential Revision: D15978952

fbshipit-source-id: 4e8c2e79be01f6d8f13628409a446d42ae22c0af
2019-06-26 11:24:15 -07:00
Jun Wu
164b3ff4da amend: do not rebase unrelated commits
Summary:
See the test change for what this change is about.

The new code has side effect on linearizing things for `<rebase_src>::`. This
is reflected on the second last test change. The new behavior is arguably more
desiable - The new code can fail if rebasing D onto C2 causes conflicts. If
that happens, and rebasing C+C2+D onto the new B does not cause conflicts, then
the old behavior is better. We can add fallback code to the old behavior if
there are conflicts later, by calling a plain `rebase` instead of `restack`.

Reviewed By: kulshrax

Differential Revision: D15978953

fbshipit-source-id: 20b9d62c6125ce2faf8e21bd86f6aad31ac38a0c
2019-06-26 11:24:14 -07:00
Jun Wu
86e119ea37 restack: allow the callsite to override rebaseopts["rev"]
Summary: This allows the callsite to control what revs to rebase.

Reviewed By: kulshrax

Differential Revision: D15978954

fbshipit-source-id: 73174475411c3986f3a8e93a1a61ce5b857f454b
2019-06-26 11:24:14 -07:00
Jun Wu
37ad2345e6 amend: add a test about suboptimal UX
Summary:
I run into this frequently and it's pretty annoying. Basically, amending X
tries to rebase things that are outside `X::`, which is unexpected.

Also, rebasing commits outside `X::` can easily fail due to conflicts. That
rollbacks the *entire* transaction. It'd be better if it only rolls back
the transaction rebasing a single branch.

I have a stack like:

  o  86685181  79 minutes ago  quark  D15755281
  |  [hg] logging: log ui.write blocked time
  |
  o  218029b5  79 minutes ago  quark  D15755284
  |  [hg] logging: log ui.prompt blocked time
  |
  o  da4d16a3  79 minutes ago  quark  D15755283
  |  [hg] logging: migrate crecord "blocked" logging to new API
  |
  o  6d0574e1  Today at 15:17  quark  D15710672
  |  [hg] logging: migrate fsmonitor to new blackbox API
  |
  o
  .
  .
  o  388aabb8  Today at 11:41  quark  D15685475
  |  [hg] blackbox: add pattern matching for filtering events
  |
  | o  e7d08fbd  Today at 11:41  quark  D15710677
  | |  wip
  | |
  | x  55895cb8 [Rewritten into 6d0574e15334]  Today at 11:41  quark  D15710672
  | |  [hg] logging: migrate fsmonitor to new blackbox API
  | |
  | | o  de3b561f  Today at 11:41  quark
  | | |  wip
  | | |
  | | o  5898b7a0  Today at 11:41  quark
  | | |  wip
  | | |
  | | x  478da1be [Rewritten into 55895cb88484]  Today at 11:41  quark  D15710672
  | | |  [hg] logging: migrate fsmonitor to new blackbox API
  | | |
  | | x  e7c5c7d3 [Rewritten into e7d08fbdb3e0]  Today at 11:41  quark  D15710677
  | | |  [hg] blackbox: add more event types
  | | |
  | | x  7d715385 [Rewritten into 55895cb88484]  Today at 11:41  quark
  | |/   [hg] blackbox: add fsmonitor event
  | |
  | x  c9a01966 [Rewritten into 00c67719c09d]  Today at 11:41  quark
  | .  [hg] blackbox: change session id to u64
  | .
  | x  b4a0a8ab [Rewritten into 388aabb8f9f6]  Today at 11:41  quark  D15685475
  |/   [hg] blackbox: add pattern matching for filtering events
  |
  o  708540a9  Today at 11:41  quark  D15685471
     [hg] blackbox: add Event::to_value

The current behavior rebases the wip commits when amending commits on the top
like 6d0574e1. It always causes conflicts and rolls back the entire rebase.

Reviewed By: kulshrax

Differential Revision: D15978955

fbshipit-source-id: 1573407958fec647fca4ca261f6807cd8eae9803
2019-06-26 11:24:14 -07:00
Arun Kulshreshtha
693deae060 remotefilelog: add configurable warning for bad TLS certificates
Summary: When the Eden API Rust client raises a CredsError exception, print out a configurable error message to the user (defined by the `edenapi.badcertmessage` config option). This allows us to provide specific instructions on how the user should renew their certificate.

Reviewed By: xavierd

Differential Revision: D15992903

fbshipit-source-id: 8316e33c3a5d86da272deea6402271d4a65548f4
2019-06-26 11:16:40 -07:00
Xavier Deguillard
c60abedfc6 tests: remove use of fastdatapack in test-fb-hgext-revisionstore-datastore.py
Summary: The future is the Rust stores, not C ones.

Reviewed By: kulshrax

Differential Revision: D15993202

fbshipit-source-id: fbdb796eafcfdaccd1f98177e83a5c0a851bee5a
2019-06-26 11:10:55 -07:00
Xavier Deguillard
1b69ae4751 tests: remove use of remotefilelog.{use,}fastdatapack
Summary: These 2 options simply do not exist anymore.

Reviewed By: kulshrax

Differential Revision: D15993203

fbshipit-source-id: e845c060b5c96a78659556488da620a92f63e121
2019-06-26 11:10:55 -07:00
Xavier Deguillard
9d18031708 remotefilelog: hardcode using Rust {data,hist}pack implementation
Summary:
We've had these 2 options turned on for a while now. Let's stop pretending
we'll switch them off, and just hardcode them over the codebase.

Some places are still using either the C code, or the Python one explicitely,
future changes will switch them to the Rust code.

Reviewed By: kulshrax

Differential Revision: D15981631

fbshipit-source-id: c23e474a84e887a2b92c9a304d63ef8d680cdf2d
2019-06-26 11:10:54 -07:00
Jun Wu
d172be76bf logging: stop logging requirements
Summary:
The requirements field is only interesting for non-remotefilelog or
generaldelta repos. Nowadays it's probably safe to assume clients are
remotefilelog and "requirements" is less useful.

Reviewed By: xavierd

Differential Revision: D15710676

fbshipit-source-id: 65f04b64760c652432471c4a8dda7acc4cf45466
2019-06-26 11:03:28 -07:00
Jun Wu
c754e0147b commands: provide in-core blackbox command
Summary:
The in-core blackbox command displays blackbox entries in the given time range.

The `blackbox` command provided by the blackbox extension was removed. They
can still be accessed via `.hg/blackbox.log`, though.

Tests are updated. Most `| grep` patterns were changed to use structured pattern
matching `--pattern` instead. Tests that are not interesting (ex. bundlebackup,
since we are moving away from bundle files slowly) are just removed.

Reviewed By: markbt

Differential Revision: D15640718

fbshipit-source-id: 7e5da60ca2b15ae9495d0242b340a066979d5a4f
2019-06-26 11:03:27 -07:00
Jun Wu
8640eccbeb blackbox: initial integrate with mercurial Python code
Summary:
Add a `mercurial.blackbox` module which just delegates to the Rust
binding. This means blackbox is no longer optional.

Change `ui.log` to log to the native blackbox as `LegacyLog` event.
The plan is to slowly migrate users from `ui.log` to `blackbox.log`,
which supports well-defined event types (instead of `LegacyLog`).

This does not change the `blackbox` command, which still uses the
legacy blackbox implementation. That will be changed in a later diff.

Reviewed By: markbt

Differential Revision: D15640720

fbshipit-source-id: de171f46e1430060083c9b7aee0a96dde315d021
2019-06-26 11:03:27 -07:00
Jun Wu
794c46a5d9 checkcode: remove the "use regex test output patterns instead of sed" rule
Summary:
The downside of regex test output is that it is not `run-tests.py -i` friendly.
So stop suggesting that.

Reviewed By: markbt

Differential Revision: D15755287

fbshipit-source-id: fa9ededb358955bc2ac78a5d6d5f71265385b40d
2019-06-26 11:03:27 -07:00
Jun Wu
935f3367f1 bindings: add blackbox bindings
Summary: Expose the Rust library to the Python world.

Reviewed By: markbt

Differential Revision: D15640717

fbshipit-source-id: b0e42da031949d8828f5c9a46d591a830db34d79
2019-06-26 11:03:27 -07:00
Jun Wu
cadcaea95c blackbox: buffer writes
Summary:
This is a simple but effective way to speed up frequent writes.

Before:

  blackbox insertion (400 entries)                   99.856 ms  12.896 KB/ 54.109 KB  16.012 KB

After:

  blackbox insertion (400 entries)                    0.940 ms      39 B / 20.207 KB  16.012 KB

Since writing is fast, the benchmark was changed to insert 4000 entries instead:

  blackbox insertion (4000 entries)                   3.918 ms      39 B /209.836 KB 160.012 KB

Reviewed By: markbt

Differential Revision: D15685472

fbshipit-source-id: 62a53512a3e0ad83120e625998e7a853b43dbe41
2019-06-26 11:03:26 -07:00
Jun Wu
4f845ca603 blackbox: add some benchmarks
Summary:
This gives us some data about blackbox performance, and interesting areas to improve.

  blackbox insertion (400 entries)                   99.856 ms  12.896 KB/ 54.109 KB  16.012 KB
  blackbox filter by index (4000 entries)             2.259 ms       0 B /      0 B
  blackbox filter by pattern (4000 entries)           9.592 ms       0 B /      0 B
                                                   (wall time) (IO read  / write    ) (log size)
                                                               (not counting mmap IO)

Takeaways:
- Insertion performance is bad.
- Blackbox size looks okay.
- Pattern matching alone can be slow for large data (ex. 100MB log requires ~6s
  matching). Therefore using indexes to narrow down entries seems worthwhile.

Reviewed By: markbt

Differential Revision: D15685473

fbshipit-source-id: 44ffffefd77f9e22699755b2ec520b1fc57ae244
2019-06-26 11:03:26 -07:00
Jun Wu
43a8d5f22c minibench: fix IO measurement when running multiple times
Summary:
In case an IO measurement is run multiple times, it should not sum the bytes,
but just pick a max, or average.

This affects a future use-case.

Reviewed By: kulshrax

Differential Revision: D15685476

fbshipit-source-id: 8b98088c2596b8a39f09a9a1358e364c21ba50ae
2019-06-26 11:03:26 -07:00
Jun Wu
8aa33d653b blackbox: rename Filter to IndexFilter
Summary:
This just renames it to make it clear that the filter is backed by index, while
the pattern matching isn't.

Reviewed By: kulshrax

Differential Revision: D15685477

fbshipit-source-id: 64145caea00baa336c8c98a633129bc0f063ce8c
2019-06-26 11:03:26 -07:00
Jun Wu
4f00a1eefb blackbox: add pattern matching for blackbox.filter
Summary:
This allows filtering events by flexible patterns. Conceptually it's reduentant
with the existing "filter". The difference is performance - one backed by
indexes, the other does linear scans.

The next diff will rename `Filter` to `IndexFilter` to make the difference more
obvious.

Reviewed By: markbt

Differential Revision: D15685474

fbshipit-source-id: ac533c25676256e6463d68bb72ba9a0a7e3cc867
2019-06-26 11:03:25 -07:00
Jun Wu
5111c62087 blackbox: add pattern matching for filtering events
Summary:
Treat Event as a JSON value, then use flexible pattern matching to match it.
The matching logic is somewhat flexible (and powerful), but not designed to be
efficient, though. Practically, it's probably always a good idea to filter
events by a time range first, then filter by the (expensive) pattern matching.

Reviewed By: markbt

Differential Revision: D15685475

fbshipit-source-id: aae033c39dd6e1845818a6b738de2ed5b0139721
2019-06-26 11:03:25 -07:00
Jun Wu
e703ca4ea6 blackbox: add Event::to_value
Summary: This converts `Event` to human-friendly JSON value.

Reviewed By: xavierd

Differential Revision: D15685471

fbshipit-source-id: 7eafe5e8e56c0ad696a7df6c69fbc5c6eb927341
2019-06-26 11:03:25 -07:00
Jun Wu
58a0971e4e hgpython: use absolute path for Python argv[0]
Summary:
The `argv[0]` is used by libpython to decide the "executable path". However,
libpython cannot handle `argv[0]` being a relative path in the buck test
environment. Looking at the logic, it seems rather fragile. Therefore, use
the Rust stdlib to resolve the full path of the current executable. Pass
it as `argv[0]` to libpython, to make it able to insert the executable path
correctly.

This does affect `sys.argv[0]` seen from Python code. It is changed from a
relative path (ex.  `hg`) to a full path (ex. `/bin/hg`). It seems to be
more executable and therefore might avoid some surprises.

Reviewed By: markbt, xavierd

Differential Revision: D15989622

fbshipit-source-id: 5a0d5b2f3e0b9ca1d97c84cb72d5dc079e9d3c1b
2019-06-25 11:44:20 -07:00
Arun Kulshreshtha
e3d07dbd54 bindings: expose EdenAPI exceptions types to Python
Summary: Export Rust-defined Python exceptions from the Eden API bindings module to Mercurial's Python code.

Reviewed By: quark-zju

Differential Revision: D15975434

fbshipit-source-id: eb681cfbd0c81d51180f04eb2c13394cc0e57f6f
2019-06-25 09:37:11 -07:00
Arun Kulshreshtha
b7dd8dd0ba remotefilelog: add python wrapper class around edenapi.client
Summary: This diff adds wrapper class around the Rust `edenapi.client` class defined in the bindings crate whose purpose is to catch any exceptions raised by the Rust bindings. For now, the wrapper class simply re-raises all exceptions; later diffs will use this to add special-case handling for certain exception types. (For example, for showing helpful messages when an error is due to a client certificate issue.)

Reviewed By: quark-zju

Differential Revision: D15975435

fbshipit-source-id: 21cef44dac84d5f468cb0e1d9eaddc2a1e93bfda
2019-06-25 09:37:10 -07:00
Thomas Orozco
a179a0bde4 mononoke: rebuild test framework
Summary:
Our test framework as it stands right now is a light passthrough to the hg `run-tests.py` test framework, which attempts to place all the files it needs to run (including tests) into a `python_binary`, then runs the hg test runner from that directory.

It heavily relies on how Buck works to offer functionality:

- It expects that all the sources it registers for its master binary will all be in the same directory when it builds
- It expects that the sources will be symlinks to the real files so that `--interactive` can work.

This has a few problems:

- It doesn't work in `mode/opt`. The archive that gets built in `mode/opt` doesn't actually have all the sources we registered, so it's impossible to run tests.
- To add a new test, you must rebuild everything. We don't do that very often, but it'd be nice if we didn't have to.
- Iterating on the runner itself is painful, because as far as Buck is concerned, it depends on the entire world. This means that every change to the runner has to scan a lot more stuff than necessary. There's some functionality I'd like to get into the runner (like reporting test timings) that hasn't been easy to add as a result.

This diff attempts to solve these problems by separating concerns a little more:

- The runner is now just a simple `python_binary`, so it's easier to make changes to it.
- The runner now provides the logic of working from local files when needed (this means you can add a new test and it'll work immediately),
- All the binaries we need are dependencies of the integration test target, not the runner's. However, to make it possible to run the runner incrementally while iterating on something, there's a manifest target that points at all the various paths the runner needs to work. This will also help integrate the test runner with other build frameworks if necessary (e.g. for open-sourcing).
- We have separate targets for various assets we need to run the tests (e.g. the hg test framework).
- The runner now controls whether to use the network blackhole. This was necessary because the network blackhole breaks PAR archives (because tmp is no longer owned by the right owner, because we use a user namespace). We should be able to bring this back at some point if we want to by using a proper chroot for opt tests.

I included a README to explain this new design as well.

There are some things that could yet stand to be improved here (notably, I think we should put assets and tests in different directories for the sake of clarity), but so far I've been aiming at providing a 1-1 translation of the old system into the new one. I am planning to make further improvements in followup diffs.

Reviewed By: farnz

Differential Revision: D15921732

fbshipit-source-id: 09052591c419acf97f7e360b1e88ef1f412da6e5
2019-06-25 08:35:32 -07:00
Mark Thomas
7047352153 tests: ensure stable output on osx
Summary: The output of `find` is wrong on OSX if the path is given with a trailing slash.

Reviewed By: ikostia, krallin

Differential Revision: D15984473

fbshipit-source-id: 57977b01310d95dd2b4828d62d53baf54a2f00bb
2019-06-25 05:13:03 -07:00
Greg Cowan
15b886ef45 Transition fbcode Rust crates to 2018 edition
Summary: Marking all Cargo.tomls in fbcode as 2018 edition.

Reviewed By: jsgf

Differential Revision: D15951175

fbshipit-source-id: edf18449c214ee1ff285d6a2cb61839aaf58a8cd
2019-06-24 13:15:55 -07:00
Arun Kulshreshtha
e1324e280a edenapi: Add conversion from ApiError to Python exceptions
Summary: Now that we have an error type that we can pattern match on, use this to raise an appropriate Python exception in the bindings. Note that due to Rust's coherence rules, we need to implement the conversion to Python errors in the `edenapi` crate. Since not all users will need this FFI functionality, it is gated behind a feature flag (which is enabled by default for Buck builds due to limitations in how Rust targets are specified).

Reviewed By: xavierd

Differential Revision: D15914529

fbshipit-source-id: 3f6a5a651fc62d2506231dd2a33fbc06528d2bce
2019-06-24 12:37:07 -07:00
Xavier Deguillard
abfb57ac13 mononoke: add getpackv2 wire protocol
Summary:
The getpackv1 protocol doesn't unfortunately support LFS blobs, which is
therefore blocking deploying remotefilelog.fetchpacks on ovrsource on the
clients.

The easiest way to get there was to simply add a getpackv2 API that is similar
in every way to getpackv1, but with the addition of a metadata field. While
full support for this was added to Mercurial, the Mononoke support is the
absolute minimum required as Mononoke doesn't support LFS.

I'm expecting that EdenAPI will completely remove the need for getpackv2 and
therefore for this code should be fairly short-lived.

Reviewed By: farnz

Differential Revision: D15954031

fbshipit-source-id: 465ac13ed8987191ccf9a7cec198d913143aaf13
2019-06-24 11:20:39 -07:00
Xavier Deguillard
26aa32152f remotefilelog: add getpackv2 to the wireprotocol
Summary:
The getpackv1 API doesn't support LFS blobs as no metadata flags are sent over
the wire. This means that repositories like ovrsource can't use it, which
prevents these repos from moving away from loosefiles...

The getpackv2 is similar to getpackv1, except that it also sends the metadata
alongside the data. This means that the LFS flag is properly sent over the
wire.

Reviewed By: DurhamG

Differential Revision: D15905425

fbshipit-source-id: dab8dcb75c8d9db8c661f11f87318feca7d0f6a9
2019-06-24 11:20:39 -07:00
Xavier Deguillard
969b2a02eb remotefilelog: simplify _getdeltachain for getpackv1
Summary:
The getpackv1 is never sending delta chains, as the full content is always
requested.  We don't have plans to change this, so let's simplify the code a
bit.

Reviewed By: DurhamG

Differential Revision: D15905431

fbshipit-source-id: f853da08391185b525d8b3da2382519b5f8d76b2
2019-06-24 11:20:38 -07:00
Jun Wu
fb6f7f16e4 hgpython: simplify run
Summary:
This just rewrites the code to be shorter by avoiding testing `is_system_exit`
multiple times and avoiding some temporary variables.

Reviewed By: ikostia

Differential Revision: D15924835

fbshipit-source-id: 2bd17538ebbfde2e2865991dd9bfd778774d33b4
2019-06-24 08:34:24 -07:00
Jun Wu
f82e332742 setup: stop shipping data files
Summary:
The most important template files are now shipped in the code. Assuming hgweb
is not used, the rest of template files are not necessary. Therefore do not
distribute them. The contributing guide is also heavily outdated and was
removed.

Reviewed By: ikostia

Differential Revision: D15915003

fbshipit-source-id: b080337bbd07775f9ec0643c34d7634ade1afdc7
2019-06-24 08:34:23 -07:00
Jun Wu
242bf4638b demandimport: remove embeddedimport
Summary:
[hg] demandimport: remove embeddedimport

C:\open\fbsource\fbcode\scm\hg\build>\tools\hg\hg.real version
Mercurial Distributed SCM (version 4.4.2_20190619_140020_a183754579ac)
....

C:\open\fbsource\fbcode\scm\hg\build>\tools\hg\hg.real dbsh -c "print(sys.path)"
['C:\\tools\\hg\\python27.zip', 'C:\\tools\\hg']
```

Reviewed By: ikostia

Differential Revision: D15902013

fbshipit-source-id: 730b746ed482db22bf5c13c1f9dfd16f9b912c20
2019-06-24 08:34:23 -07:00
Jun Wu
8997f2f15d windows: switch to the new Python runtime
Summary:
Switch to the new Python runtime. Remove parts that are incompatible and no
longer necessary, including:

- Building curses, python-lz4, and urllib3 (in build_nupkg.py).
- Mangling sys.path (in hgpython and entrypoint.py).
- Zip-related logic (in hgpython).
- Cargo features controlling build environment (in hgpython and hgmain).
- Zipping Python stdlib (in setup.py).
- Shipping files in `templates`, `help`, and most `contrib` files (in
  setup.py).

For the hgpython part, the new expectation is: in all cases (windows, linux,
make local, installed, buck), `edenscm.mercurial.entrypoint` and
`edenscmnative` modules are always directly importable and are always the
expected modules if imported. So the `hg` logic just imports and runs it
without having any `sys.path` related logic.

To explain it further:
- When installed on a POSIX system, the default `sys.path` contains
  site-packages.  Both edenscm and edenscmnative are in site-packages.
- When installed on Windows, the executable (hg.real.exe), python27.dll,
  python27.zip, and edenscmnative/ are all in a same directory. Therefore the
  default sys.path (exe dir + python27.zip) would be sufficient.
- When using `make local`, and run via `scm/hg/hg`, the `PySys_SetArgv` API
  (called by `hgpython`) inserts the `scm/hg` directory as `sys.path[0]`,
  therefore edenscm and edenscmnative in `scm/hg` will be imported as expected.

Since we no longer hard code paths to search for modules, this should fix
issues on systems with a different sys.path, ex. debian and ubuntu uses
"dist-packages" instead of "site-packages".

Note: IPython is broken. It seems to be a combination of newer Python version,
newer compiler and 64 bit (see [1]). It looks like prompt_toolkit incorrectly
uses untyped ctypes APIs where it passes "int/long"s to places expecting a
HANDLE. The ctypes library uses 4-byte integers for plain "int/long"s where a
HANDLE is 8 byte on 64 bit Windows.  The new interpreter is stricter somehow
and will error out in this case (also explains why D15912516 is needed).

The fix to prompt_toolkit was sent as
https://github.com/prompt-toolkit/python-prompt-toolkit/pull/930.

[1]: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/406

Reviewed By: ikostia

Differential Revision: D15894694

fbshipit-source-id: 560d11ae28c1e65d58b760eac93701e753bd397e
2019-06-24 08:34:23 -07:00
Mark Thomas
eae1cdf956 remotefilelog: use _n for plurals of strings
Summary:
Use _n for plurals of strings, rather than hard-coding the suffix, and don't
retranslate the string after is has already been translated.

Reviewed By: kulshrax

Differential Revision: D15940244

fbshipit-source-id: 26ef175fe201bcc5211ad05c8b3894fbc22d61b6
2019-06-24 05:08:20 -07:00
Xavier Deguillard
f00c1f1a70 simplecache: fix infinite loop when reading from memcache socket
Summary:
In S179901, we've seen a couple of instances of `hg status` consuming as much
memory as they could until getting OOM killed. Looking at backtraces for these
processes (P67246356) the code spins trying to read data from memcache. The
connection is however closed and therefore `recv` returns an empty string,
which is then added to a list and the `recv` is retried again.

Reviewed By: kulshrax

Differential Revision: D15947154

fbshipit-source-id: f1216e26b0ce159377ff8e82bedc13a7cc3d0444
2019-06-21 14:17:27 -07:00
Jun Wu
aa1986fcf2 windows: add a patch to make python.exe search for argv[0] path
Summary:
This makes it possible for `python setup.py` to import `distutils_rust` without
changing sys.path. The `argv[0]` path being part of `sys.path` is the expected
Python interpreter behavior.

Note: the `argv[0]` path is used in hgmain for POSIX, but not Windows because
of `0005-PC-aggressively-simplify-sys.path.patch`. That is desirable since on
Windows, the "main exe path" is the `argv[0]` path, and it already exists in
the default `sys.path`.

Reviewed By: ikostia

Differential Revision: D15935893

fbshipit-source-id: a759440ef3103dfdd49d97727ea74d09afe1d881
2019-06-21 10:07:01 -07:00
Jun Wu
b751f99ccf windows: fix PDcurses build
Summary:
Some features of the PDCurses binding requires some marcos to compile. Define them.

Also removed duplicated source code that got accidentally copied.

The macros are copied from setup.py of the Python binding [1],
with `NCURSES_MOUSE_VERSION` removed, which breaks complication.

[1]: curses‑2.2‑source.zip at https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses

Reviewed By: ikostia

Differential Revision: D15935894

fbshipit-source-id: 944466f083666b68c55435881d627d8a51acffa2
2019-06-21 10:07:00 -07:00
Thomas Orozco
26c6765128 run-tests: conditonally report execution time in milliseconds
Summary: This updates `run-tests.py` to report times in milliseconds if we're running under TestPilot. This is useful because TestPilot diverges a bit from the JUnit spec in the sense that it expects time to be in milliseconds, not seconds.

Reviewed By: StanislavGlebik

Differential Revision: D15938672

fbshipit-source-id: a421b523931abfdf5da10e6702739cecf00a4cdd
2019-06-21 03:50:28 -07:00
Arun Kulshreshtha
550e3826a0 bindings: use more specific exception types in edenapi module
Summary: Instead of just throwing `RuntimeError` for every failure, we should return more appropriate built in exceptions on a case-by-case basis.

Reviewed By: quark-zju

Differential Revision: D15913954

fbshipit-source-id: 753aa95111bca5ce18c3b0a210e6439f60f4894a
2019-06-20 16:15:00 -07:00
Arun Kulshreshtha
3b68076741 edenapi: Add new ApiError type
Summary: This diff adds a new `ApiError` type that will serve as the general error type for Eden API operations. This error type is a based on the ["Error and ErrorKind pair" pattern](https://rust-lang-nursery.github.io/failure/error-errorkind.html) described in the `failure` crate's documentation. It uses a `failure::Context` to wrap an underlying error, and provides both the ability to provide users with high-quality custom error messages as well as the ability to programmatically consume such errors via pattern matching. See the doc comment in the code for usage details.

Reviewed By: xavierd

Differential Revision: D15913955

fbshipit-source-id: cb61f8c40dc04c78a5c281535163788e95c4f4e8
2019-06-20 16:14:59 -07:00
Arun Kulshreshtha
858b285a3b edenapi: add new errors module
Summary: Add a new `errors` module with a new `ApiResult` type. For now, this type is just an alias for `failure::Fallible`. The goal of this diff is to simply plumb the new result type throughout the crate. In a later diff, we will then leverage this to change the error type for the whole crate without needing to update all the function signatures.

Reviewed By: xavierd

Differential Revision: D15913956

fbshipit-source-id: be3c64051c67722b517add3c006006bcd9116962
2019-06-20 16:14:59 -07:00