Commit Graph

231 Commits

Author SHA1 Message Date
Wez Furlong
fbf697b7be mercurial: remove hg_watchman_client and watchman_client crates
Summary:
These are not currently used by mercurial and are superseded
by the newer more general `watchman_client` crate on crates.io:

https://docs.rs/watchman_client/0.2.0/watchman_client/

Some of the implementation of that crate was based on the work I'm
removing here.

I was going to update hg_watchman_client to be implemented in terms
of the new crate, but since it isn't used and it would only be a thin
wrapper, I figure that it is best to delete this code instead so that
we can integrate it in terms of the new API when we're ready.

Reviewed By: singhsrb

Differential Revision: D18777161

fbshipit-source-id: efacb749e6d35ff4cc1fdc7d99cdca9ed42c9cfe
2019-12-03 10:59:41 -08:00
Mateusz Kwapich
7a0665c9fc remove dead code from fbconduit hg extension
Summary:
Since it's not calling conduit anymore we can remove all conduit related
functions.

Reviewed By: quark-zju

Differential Revision: D18733121

fbshipit-source-id: 20a6022d9ac7ae6e9afea2791a8daac57cefb22c
2019-12-03 05:56:20 -08:00
Mateusz Kwapich
fa8571f49a migrate log_v2 to grpahql
Summary:
conduit is going away, phabricator team wants us to stop using
it in hg.

Reviewed By: quark-zju

Differential Revision: D18732257

fbshipit-source-id: c4faf83e36af80fc616e91adede141ba12de5446
2019-12-03 05:56:20 -08:00
Mateusz Kwapich
fd3b110471 migrate get_mirrored_rev to graphql
Summary: conduit is going away, phabricator team wants us to stop using it in hg

Reviewed By: quark-zju

Differential Revision: D18727399

fbshipit-source-id: c208f5fec5fefd83aa37629b56d2bbaa2532d30e
2019-12-03 05:56:20 -08:00
Stefan Filip
1f76f9e63f manifest: restructure InsertError to give back arguments
Summary:
It would be nice if the insert method would give back the path that
it failed to insert.

Reviewed By: dtolnay

Differential Revision: D18739978

fbshipit-source-id: 4c16d09750ade2f01397161129c31bcf0059a957
2019-12-02 15:53:41 -08:00
Stefan Filip
30045a27ba manifest: update python bindings to allow insertions before deletions
Summary:
The Mercurial code has the bad habbit of inserting files in what can
appear impossible locations. Sometimes files with directory names and
sometimes directories in file locations. This happens because the initial
code would do additions before deletions on Manifest implementations that
were rudimentary. As soon as we introduce validation various code paths
surface.

I tried to fix the codepaths that modify manifests but it's a losing game.
I fixed the issue that appeared in tests and a couple of issues people
reported but more situations crop up.

This is giving up on the python code.

Reviewed By: quark-zju

Differential Revision: D18737678

fbshipit-source-id: 0c97128ff67e5ba2334942b6afc404aa64a2e5f4
2019-12-02 15:53:41 -08:00
Joseph Friesen
74b914e6b5 change mode of lock file to workaround flock behavior with NFS v4.x
Summary:
In NFS v4.x, flock ends up inheriting some semantics of fcntl,
including that write locks can only be created against file handles
opened for O_WRONLY or O_RDWR.

This diff changes the mode of 'lockpath' to O_RDWR to solve this.

Reviewed By: simpkins

Differential Revision: D18714734

fbshipit-source-id: 84ba4a6a5de034a4942b1ca3aa8b0c92f882ce38
2019-12-02 15:34:23 -08:00
Jun Wu
6acee3c3b4 watchmanclient: drop "version =" in Cargo.toml
Summary:
`path = ...` is enough. This should resolve the following build issues:

  error: failed to select a version for the requirement `serde_bser = "^0.1.0"`
    candidate versions found which didn't match: 0.2.0
    location searched: ...
  required by package `watchman_client v0.1.0 (...)
      ... which is depended on by `hg_watchman_client v0.1.0 (...)`

Reviewed By: lukaspiatkowski

Differential Revision: D18738176

fbshipit-source-id: 725840895a8e988b35000a48cf92018b14cb4dee
2019-11-28 05:16:53 -08:00
Jun Wu
94cbed7002 metalog: track bookmarks
Summary:
Since bookmarks are stored in svfs, track it in metalog for better transaction
support.

This affects some transaction / rollback behaviors. Since our plan is to remove
`hg rollback` eventually, the compatibility is intentionally broken.

Reviewed By: xavierd

Differential Revision: D18538147

fbshipit-source-id: 6070772a4bce88d3808547207f5df194696b1b52
2019-11-27 11:37:44 -08:00
Jun Wu
7883ed2e7e metalog: also write files to disk
Summary:
Existing tools (ex. shell complete script) still read from
`.hg/store/{remotenames,bookmarks}`. Be compatible with them by double writing
content to both metalog and filesystem. Metalog is the source of truth for hg.

Reviewed By: xavierd

Differential Revision: D18524106

fbshipit-source-id: c37bc86b7443bba1b65735f29243767650b22ecd
2019-11-27 11:37:43 -08:00
Jun Wu
c0bc1fb8be bookmarks: move 'bookmarks' state to storevfs
Summary:
Similar to D17199834, by moving 'bookmarks' from localvfs and sharedvfs to
storevfs, we can make it part of metalog and get better transaction support.

Reviewed By: xavierd

Differential Revision: D18524104

fbshipit-source-id: ae148c1f02fc83b5c2d73102ecab39ff223ea5df
2019-11-27 11:37:43 -08:00
Jun Wu
864b42fc8a tests: do not operate on .hg/bookmarks directly
Summary:
I'm going to move `bookmarks` to "metalog". So operating on the `.hg/bookmarks`
file no longer works.

Reviewed By: xavierd

Differential Revision: D18524105

fbshipit-source-id: dc31b13e1acc171d2e8b32cdfea7028faf6dc4d3
2019-11-27 11:37:43 -08:00
Jun Wu
4fe519d97f repo: always share bookmarks
Summary:
Right now `bookmarks` is stored at both "local" vfs and the "shared" vfs.
In an upcoming change I'd like to move bookmarks to the "metalog" to get
better transaction. Therefore make it always shared.

The shared bookmark feature is turned on by default. Assuming nobody manually
turns it off, production hosts all have shared bookmark turned on.

Reviewed By: simpkins

Differential Revision: D18524103

fbshipit-source-id: 3160146f357dd01f2d78f5d2f4a14838f8f12a94
2019-11-27 11:37:42 -08:00
Jun Wu
541d4bf625 commands: avoid infinite loop when collecting process tree info
Summary:
We have seen cases on Windows where the hg process gets stuck in
CreateToolhelp32Snapshot. Let's be defensive and always exit the loop.

Reviewed By: singhsrb

Differential Revision: D18729720

fbshipit-source-id: fb8602ce231eec01b6b42c6759849d56e5db2030
2019-11-27 11:04:30 -08:00
Jun Wu
9c8156804e metalog: raise ProgrammingError on misuse
Summary:
The only valid place that metalog can be changed is inside a transaction, since
it's transaction.{close,abort} that writes or discards metalog changes.

In other words, metalog should not be changed during A, B, or C:

  |<- A ->|<----------- repo lock --------->|
          |<- B ->|<- transaction ->|<- C ->|

Add detection for them.

Reviewed By: xavierd

Differential Revision: D18538143

fbshipit-source-id: 036286ed32a897fe3ce0a91c1e3c848cc6167b1d
2019-11-27 00:24:09 -08:00
Jun Wu
353361701c metalog: add is_dirty API
Summary:
This helps test if there are uncommitted changes. It can help detecting
programming errors. For example, is metalog changed before starting a
transaction?

Reviewed By: xavierd

Differential Revision: D18538148

fbshipit-source-id: 9c82838d8174e6a93fde7108503a025660191cbf
2019-11-27 00:24:09 -08:00
Jun Wu
05b53a4d7b metalog: discard in-memory metalog at lock/transaction boundary
Summary:
Before this diff, metalog has a same lifetime as repo.svfs and never gets
reloaded or dropped. That is problematic in case external processes also
make changes, ex. running `hg amend` in `histedit exec`.

    pid 1> histedit action foo (a single transaction, metalog loaded here)
    pid 1> histedit action exec ... (a single transaction)
    pid 2> hg amend (changes metalog)
    pid 1> histedit action bar (cannot perform this action because metalog has
           conflicts!)

This is why test-mutation.t didn't work with metalog.

Fix it by discarding metalog state at transaction/lock boundary (enter/exit).

The next two diffs add checks so we wouldn't discard uncommitted data silently.

Reviewed By: xavierd

Differential Revision: D18519995

fbshipit-source-id: ceb030362d66ad4be142e81accb82a4afa67f305
2019-11-27 00:24:08 -08:00
Jun Wu
2e092eb740 infinitepush: protect writes with locks and transaction
Summary: This resolves ProgrammingErrors detected by a later change.

Reviewed By: xavierd

Differential Revision: D18538145

fbshipit-source-id: 650e956707af6024457cdc7dabf516d087ad03cd
2019-11-27 00:24:08 -08:00
Jun Wu
0dc3e471d7 remotenames: protect writes with locks and transaction
Summary: This resolves a ProgrammingError added later.

Reviewed By: xavierd

Differential Revision: D18538144

fbshipit-source-id: f6d26890e663eff7cb2aedd621b7df33f8bf1fa0
2019-11-27 00:24:08 -08:00
Jun Wu
6ef1bca4c2 clone: protect writes with locks and transaction
Summary: This resolves a ProgrammingError added later.

Reviewed By: xavierd

Differential Revision: D18538146

fbshipit-source-id: fd659491e77e2b21f876f16a61860806acbc1480
2019-11-27 00:24:07 -08:00
Jun Wu
1d4682dfa0 metalog: improve conflict handling
Summary:
The current `commit` code path errors out without telling much about what
conflicts are. Improve it by showing what are actually conflicting, and allows
users to replace the resolver function to do customized merges.

Reviewed By: xavierd

Differential Revision: D18519996

fbshipit-source-id: 78f42ada1df45659783ce1eba30a19f6fc6b3b62
2019-11-27 00:24:07 -08:00
Jun Wu
44e6e32d5a tests: remove tests that #require svn
Summary:
Those tests will crash `run-tests.py` because `svn` is unknown to `hghave`.

Alternatively we can revert `hghave` changes in D18088850. But it seems there
is little interest in converting svn repos using the convert extension.

Reviewed By: singhsrb

Differential Revision: D18713922

fbshipit-source-id: 1a70b3d5d0fe8d02cc0549eabeb609ab1d9c12e6
2019-11-27 00:24:07 -08:00
Jun Wu
d011a49d16 run-tests: protect a "print" with "iolock"
Summary:
I have been seeing the progress bars get messed up like:

  [                    ] 0 Passed. 0 Failed. 0 Skipped. 903 Remaining         0.3s
  [                    ] test-contrib-perf.t                                  0.3s
  [                    ] test-check-code.t                                    0.3s
  [                    ] test-check-config.t                                  0.3s
  [                    ] test-contrib-check-code.t                            0.3s
  [                    ] 2 Passed. 0 Failed. 0 Skipped. 902 Remaining         0.4s
  [                    ] test-contrib-perf.t                                  0.4s
  [                    ] test-check-code.t                                    0.4s
  [                    ] 3 Passed. 0 Failed. 0 Skipped. 900 Remaining         0.9s
  [                    ] test-contrib-perf.t                                  0.9s
  [->                  ] test-check-code.t                                    0.9s
  [                    ] 5 Passed. 0 Failed. 1 Skipped. 897 Remaining         2.4s
  [-->                 ] test-contrib-perf.t                                  2.4s
  [--------->          ] test-check-code.t                                    2.4s
  [----------------->  ] test-check-config.t                                  2.4s
  [----------------->  ] test-contrib-check-code.t                            2.4s
  [                    ] test-run-tests.t                                     2.4s
  [------>             ] test-checkoutidentifier-commitinfo.t                 2.4s
  [-------------->     ] test-commitcloud-checkoutlocations-update.t          2.4s
  [-------->           ] test-checkserverbookmark.t                           2.4s
  [--------------->    ] test-checkoutidentifier-dirstateinfo.t               2.4s
  [---------->         ] test-debugcheckcasecollisions-treemanifest.t         2.4s
  [                    ] test-fb-hgext-copytrace.t                            2.4s
  [                    ] test-copytrace-heuristics.t                          2.4s
  [---------------->   ] test-check-execute.t                                 2.4s
  [----------->        ] test-fb-hgext-grpcheck.t                             2.4s
  [---->               ] test-treestate-needcheck.t                           2.4s
  [------------->      ] test-check-help.t                                    2.4s

I tracked it down to `hghave` crash with unknown svn-related features. The fix is
to protect the write with iolock. With thi spatch the progress bar now looks like:

  skipped: unknown feature: svn
  skipped: unknown feature: svn-bindings
  skipped: unknown feature: svn
  skipped: unknown feature: svn-bindings
  skipped: unknown feature: svn
  skipped: unknown feature: svn-bindings

  [                    ] 7 Passed. 0 Failed. 1 Skipped. 895 Remaining         2.9s
  [--->                ] test-contrib-perf.t                                  2.9s
  [--------->          ] test-check-code.t                                    2.9s
  [----------------->  ] test-check-config.t                                  2.9s
  [->                  ] test-run-tests.t                                     2.9s
  [------>             ] test-checkoutidentifier-commitinfo.t                 2.9s
  [----------------->  ] test-commitcloud-checkoutlocations-update.t          2.9s
  [-------->           ] test-checkserverbookmark.t                           2.9s
  [---------------->   ] test-checkoutidentifier-dirstateinfo.t               2.9s
  [---------->         ] test-debugcheckcasecollisions-treemanifest.t         2.9s
  [                    ] test-fb-hgext-copytrace.t                            2.9s
  [                    ] test-copytrace-heuristics.t                          2.9s
  [------------->      ] test-fb-hgext-grpcheck.t                             2.9s
  [----->              ] test-treestate-needcheck.t                           2.9s
  [----------------->  ] test-check-help.t                                    2.9s
  [----------->        ] test-commitcloud-smartlog.t                          2.9s
  [----------->        ] test-lfs-checksum.t                                  2.8s
  [-------->           ] test-progressfile.t                                  2.8s
  [-->                 ] test-dirstate-race.t                                 2.4s
  [->                  ] test-fb-hgext-copytrace-amend.t                      2.2s
  [                    ] test-help.t                                          1.9s

Reviewed By: singhsrb

Differential Revision: D18713921

fbshipit-source-id: 2897b2dda56a02842d8d88f31972156cf8f615ad
2019-11-27 00:24:06 -08:00
Jun Wu
ab6e41e651 continue: show a hint about how to resolve conflicted files
Summary:
"outstanding merge conflicts" is not a helpful message to inexperienced users.
Print out commands to get more context.

Reviewed By: simpkins

Differential Revision: D18535010

fbshipit-source-id: 035ec9f3d79bf04a997ee907469f2e3d749a1d0e
2019-11-22 21:22:45 -08:00
Michael Devine
ad3d85038e Repo converter: Allow empty author/committer fields
Summary: Some commits in AOSP have empty fields for author/committer email addresses.

Reviewed By: tchebb

Differential Revision: D18661778

fbshipit-source-id: e975392da677879d598eb9fc77558251a55c2f23
2019-11-22 15:38:34 -08:00
Adam Simpkins
7f5608ed57 minor clean up to HgNativeBackingStore
Summary:
Remove some unnecessary forward declarations, and use full paths in includes
so autodeps can recognize which rule these headers come from.

Reviewed By: fanzeyi

Differential Revision: D18652106

fbshipit-source-id: e2c84e1aaf846c91c18242050c4015eca8c501d3
2019-11-22 13:00:07 -08:00
Adam Simpkins
2442b46ee8 cmake: always build support for the EdenSCM backing store
Summary:
Now that the fb-mercurial sources are available in the Eden repository, update
our CMake build files to always build them.  This moves the build logic from
the centralized `FBMercurialFeatures.cmake` file into `CMakeLists.txt` files
in the appropriate subdirectories.

Reviewed By: chadaustin

Differential Revision: D18588011

fbshipit-source-id: ded9decde5c2ec766aae0bb0f4f5b021d1044a98
2019-11-22 13:00:07 -08:00
Adam Simpkins
f71bfaacad getdeps: remove the fb-mercurial-rust target
Summary:
Remove the standalone fb-mercurial-rust target that was an internal-only
dependency for the Eden build.  This build step is now done entirely in the
Eden build.

Reviewed By: fanzeyi

Differential Revision: D18623943

fbshipit-source-id: c62a1155ddd1c0a6b2270c472176ba25194c6145
2019-11-22 13:00:06 -08:00
Sam Fu
d472f8348d write to machine username for log path
Summary:
D8997967 changed `hg rage` to pull from a path that uses the machine's unix user. But The write in the background backup for commit cloud used `util.shortuser(ui.username())`. This means that in On Demand, it would write to `$LOGDIR/samfu/$REPO$DATE` but `hg rage` would look in `$LOGDIR/svcscm/$REPO$DATE`. Changing this to the same `util.getuser()` should fix this.

Caveat: I didn't actually test this. I just know that my `hg rage` says "log directory does not exist: /tmp/svcscm" (P122851697)

Reviewed By: markbt

Differential Revision: D18654245

fbshipit-source-id: ccb78eba778ddedb23c7947a3eeb16e9f8fd2021
2019-11-22 12:25:18 -08:00
David Tolnay
d1d8fb939a Switch from failure::Fail trait to std::error::Error for errors
Summary:
This diff replaces eden's dependencies on failure::Error with anyhow::Error.

Failure's error type requires all errors to have an implementation of failure's own failure::Fail trait in order for cause chains and backtraces to work. The necessary methods for this functionality have made their way into the standard library error trait, so modern error libraries build directly on std::error::Error rather than something like failure::Fail. Once we are no longer tied to failure 0.1's Fail trait, different parts of the codebase will be free to use any std::error::Error-based libraries they like while still working nicely together.

Reviewed By: xavierd

Differential Revision: D18576093

fbshipit-source-id: e2d862b659450f2969520d9b74877913fabb2e5d
2019-11-22 08:53:31 -08:00
Johan Schuijt-Li
1b7dd50dbf hg: don't create tempfiles longer than allowed on filesystem
Summary:
[svcscm@hg022.prn2 /data/scm/www]$ hg log -r master
    transaction abort!
    rollback completed
    abort: File name too long: '/data/scm/www-merge-generaldelta/.hg/store/data/flib/intern/____generated____/_graph_q_l_meerkat_step/flib/intern/entschema/generated/entity/bizapps/dcp__insight/application__config/_ent_d_c_p_insights_application_config_action.php/._g_q_l_g___intern_____set_permission_manager_domain_dcp_insights_application_config_data_____ent_d_c_p_insights_application_config_action____gen_perform_graph_q_l_set_permission_manager_domain_dcp_insights_application_config_mutation_coercer.php.i-U0sMqX~'

On hg022.prn2 www currently failes under certain circumstances because filenames longer than
255 characters are currently created. I traced this back to mktempcopy and made sure that
we truncate filenames when they are created too long.

Reviewed By: quark-zju

Differential Revision: D18639433

fbshipit-source-id: 20e4b086ca5c775b6054b642ecedfb05efd00fb9
2019-11-21 10:41:02 -08:00
Jun Wu
6b6b6cf36d blackbox: add Event::Tags and its index
Summary:
Add Event::Tags so we can tag commands with one or more names.
Add index for the tags so we can search them more efficiently.

As we're here, update hgcommands to read EDENSCM_BLACKBOX_TAGS and write
Event::Tags automatically just after Event::Start.

Differential Revision: D18610733

fbshipit-source-id: c69b6e3d34b317e92a1c4d76f29e832b6b01c4fa
2019-11-21 08:36:10 -08:00
Jun Wu
49fe540b02 blackbox: build indexes to speed up certain query patterns
Summary:
Previously, the blackbox index was hardcoded on the timestamp, and is not
Event-aware. This diff changes the index to parse Event and build up indexes
for various common events (ex. Start, Finish).

For now, the index just includes start, finish timestamps and duration.

Differential Revision: D18610734

fbshipit-source-id: bf572f3138c8c18d3aab06eadcc83dd5b0b9cf02
2019-11-21 08:36:10 -08:00
Jun Wu
25e090c529 blackbox: extend match_pattern to capture matched objects
Summary:
Previously, `match_pattern` only returns a `bool`. This diff implements an
enhanced version `capture_pattern` to be able to capture matched objects.

This will be used to match query patterns and apply optimization.

Differential Revision: D18610732

fbshipit-source-id: 39e989e7633b834c04997bf8665494556f3b62b2
2019-11-21 08:36:09 -08:00
Jun Wu
f19a760f5f blackbox: remove IndexFilter
Summary: Migrate callsites to use the new pattern matching filtering APIs.

Differential Revision: D18610738

fbshipit-source-id: 242182f4e6a58bbff5dddbb177287921c85519bc
2019-11-21 08:36:09 -08:00
Jun Wu
ec9d925b69 blackbox: add timestamp field to Start and Finish event
Summary:
See the previous diff. As part of migrating away from IndexFilter. There needs
to be a way to filter commands by absolute clock time using pattern matching
against Events.  To achieve that, add the timestamp field to Start and Finish
events.

Differential Revision: D18610735

fbshipit-source-id: 9e1898a87bc93e47d0f0c77342428b5c42ef6f24
2019-11-21 08:36:09 -08:00
Jun Wu
41d6c2d42c blackbox: implement new query APIs
Summary:
The existing query API `filter` has 2 issues:
- It does querying and filtering together, making it hard to express certain
  queries. For example: "for commands taking more than 10 seconds, get all
  network requests used by those commands".
- The `IndexFilter` abstraction overlaps with `pattern`s. `IndexFilter` is
  built upon the `Entry` structure, and does not work for `Event`s. In the
  future, we want a `Event::Tags` to tag commands, and build indexes on it.
  That's not very compatible with `IndexFilter`.

To address the issues, I'm going to:
- Decouple querying and filtering by splitting it into 2 methods glued by
  `SessionId`s.
- Deprecate `IndexFilter`. Make `patterns` the only way to filter entries.
- Add dedicated indexes for certain events.

This diff adds the related APIs towards that direction.

Differential Revision: D18610737

fbshipit-source-id: c6ab92fd6fa7bb2ee7e14f567d72ac98b287c143
2019-11-21 08:36:08 -08:00
Jun Wu
34e2385f7d blackbox: remove type parameter of Entry
Summary:
The type `Entry<T>` provides flexibility on serializing different types.
Practically, only the `Event` type is used. Let's remove `T` so `blackbox` can
assume it's the `Event` type.

Differential Revision: D18610736

fbshipit-source-id: 102a5f61c758fa83cd1994c7f813576dcf5b59d5
2019-11-21 08:36:08 -08:00
Jun Wu
6b8acfe260 hgsql: add rate limiting for read commands
Summary:
Similar to D2756217. But skip sync directly if the repo has been synced
recently.

This will help reducing CPU load on the DB tier.

Reviewed By: ikostia

Differential Revision: D18621013

fbshipit-source-id: 83370669ea61eb693d06495aaa13664648b97aca
2019-11-21 07:45:31 -08:00
Jun Wu
5b61ae4c89 edenapi: add tracing spans
Summary:
Add tracing spans so we can get some insights about statistics from the pure
Rust land.

Reviewed By: xavierd

Differential Revision: D18625646

fbshipit-source-id: 15951fe2f8270a70f647a0f4e09819bbc33919c5
2019-11-20 18:56:07 -08:00
Jun Wu
60ccca41fc graphql: return directly for empty "landed" query
Summary:
It seems an emtpy GraphQL query always times out. So let's avoid such queries
from the client side.

Reviewed By: xavierd

Differential Revision: D18626286

fbshipit-source-id: 70f0061f7f7ad8c7d8be4e15fc419039dc07d61e
2019-11-20 16:57:35 -08:00
Adam Simpkins
344661b651 cmake: update RustStaticLibrary.cmake to hook up cargo dependencies
Summary:
Update `RustStaticLibrary.cmake` to let CMake know that running `cargo` will
produce the Rust static library output.  Without this CMake does not know how
to correctly wire up dependencies for libraries.  Previously the code used the
`ALL` target to ensure that the Rust static library was built, but this did
not ensure that it was built before executables that require it.

Reviewed By: pkaush

Differential Revision: D18588010

fbshipit-source-id: 1a1880993bdfa3fcb876a0f6507e5cddfea9b738
2019-11-20 12:28:40 -08:00
Adam Simpkins
55d980ee42 update RustStaticLibrary.cmake to support vendored crates on Windows
Summary:
Update the `RustStaticLibrary.cmake` code to explicitly find and invoke the
Python interpreter when running the Python script to download vendored crates.
This is required to work on Windows.

Reviewed By: pkaush

Differential Revision: D18588012

fbshipit-source-id: 4c2dfbc786adf0a7aa6b43483060800627a8aca1
2019-11-20 12:28:40 -08:00
Adam Simpkins
8dc2c5963a cmake: automatically decide whether to use vendored rust crates
Summary:
Update `RustStaticLibrary.cmake` to automatically decide to try and download
vendored Rust crates or not, based on the presence of the script it uses to
download them.

Reviewed By: fanzeyi

Differential Revision: D18588007

fbshipit-source-id: 995365f0cc2368897ddf94b5617bdb9bc0682edc
2019-11-20 12:28:40 -08:00
Adam Simpkins
a9d5178036 avoid downloading vendored crates once per library
Summary:
This updates the `RustStaticLibrary.cmake` file to download vendored
`crates.io` crates only once, rather than once per library.  It also now
downloads them into the build directory, rather than into the source
directory.

This can probaly still be improved more in the future: the vendored crates
should probably just be treated as a top-level getdeps manifest entry.
Currently if multiple projects build rust static libraries we will still end
up downloading the vendored crates once per project.

Reviewed By: fanzeyi

Differential Revision: D18548094

fbshipit-source-id: 83060e679455267bdf197e5ff2d33b1b7f0204fc
2019-11-20 12:28:39 -08:00
Jun Wu
9027d90624 dispatch: prompt 'eden doctor' for TApplicationException
Summary:
Many people hit TApplicationException recently. Most of them can be fixed
by `eden doctor`.  Instead of crashing and showing an unhelpful backtrace, show
a shorter error message and prompt the user to run `eden doctor`.

Reviewed By: fanzeyi

Differential Revision: D18609445

fbshipit-source-id: 5492fa92008cb33e1122b72b48d0858db0d5f994
2019-11-20 09:32:24 -08:00
Zeyi (Rice) Fan
c7546996e9 eden: switch to using Rust code parse manifest
Reviewed By: chadaustin

Differential Revision: D18365537

fbshipit-source-id: ef4d2fc5af01ab86f50df44b7a98f7b6f2884587
2019-11-19 18:01:24 -08:00
Zeyi (Rice) Fan
9328adfaf9 backingstore: add Tree and TreeEntry Rust structs to pass manifest
Summary: This diff adds Rust structs to represent the data EdenFS wants from a manifest so we can pass these to EdenFS.

Reviewed By: wez

Differential Revision: D18365440

fbshipit-source-id: b474ceb698d9230e1b02c2cce1bec2a32bd3f94f
2019-11-19 18:01:23 -08:00
Zeyi (Rice) Fan
1713cfca79 backingstore: impl Drop for CBytes and add From<Vec<u8>> for CBytes
Summary:
Some clean up.

`CByte` should clean up `vec` in `Drop` since we are going to have `CBytes` in other struct's field and this will allow Rust automatically manage this memory.

Reviewed By: chadaustin

Differential Revision: D18365441

fbshipit-source-id: 7038bc6ff457415ee8234cc4c6b7df0f70005cfe
2019-11-19 18:01:23 -08:00
Zeyi (Rice) Fan
f27e1eb2e0 backingstore: add TreeContentStore to impl TreeStore
Summary: `manifest::Tree` wants to have a store that implements `TreeStore`. However at current we don't want to introduce dependency between `manifest` and `contentstore`. So we create this wrapper struct to provide the trait implementation. This will allow us to use `manifest` to parse manifest data we get from hg store.

Reviewed By: chadaustin, xavierd

Differential Revision: D18365354

fbshipit-source-id: 3687032c7f51570ef51ccc4004efc87f64ef2188
2019-11-19 18:01:23 -08:00
Zeyi (Rice) Fan
7f0f541fa1 manifest: add FsNode to List::Directory
Reviewed By: sfilipco

Differential Revision: D18307923

fbshipit-source-id: 1844afb7b9a185f7e89c11476ee2eb34cac117c6
2019-11-19 18:01:22 -08:00
Zeyi (Rice) Fan
5b274b1a4c manifest: add tree HgId to FsNode
Summary: This diff adds `Option<HgId>` to `FsNode::Directory` because EdenFS needs the tree hash for the directories in the tree.

Reviewed By: sfilipco

Differential Revision: D18307205

fbshipit-source-id: 93db944ff1686a1c5927aa9a876a0fd008edbf9a
2019-11-19 18:01:22 -08:00
Jun Wu
2918ef4850 test-hggit-clone: update the test
Summary:
The test needs to be updated since we now print commit hashes instead of
revision numbers in `phase` output.

Reviewed By: akushner

Differential Revision: D18596300

fbshipit-source-id: b42bb6ed68dfc33977f0c9df5018a5bf365c2909
2019-11-19 12:05:05 -08:00
Xavier Deguillard
2afcb03dd8 split: use rebase.rebase instead of restackonce
Summary:
The restackonce function warns about not using it and using `rebase.rebase`
directly, so let's just do that.

Reviewed By: quark-zju

Differential Revision: D18574767

fbshipit-source-id: 56829bccbba7f727867ba2b9bd0a81530ba29bf3
2019-11-19 09:10:37 -08:00
Stanislau Hlebik
bcfbc5c19e fix compilation warning
Summary: I got unused warning every time I build Mononoke.

Reviewed By: singhsrb

Differential Revision: D18573764

fbshipit-source-id: 23921f581bdc74655041a2413f80cb159b4ba010
2019-11-19 00:43:36 -08:00
Jun Wu
0bab8ac4b2 tests: revive silenttestrunner.py
Summary: D18541783 accidentally removed it. Revive the file to unbreak tests.

Reviewed By: singhsrb

Differential Revision: D18587477

fbshipit-source-id: 7a7a0cf8a53e5e1fc1856aab18a3da02e53e019a
2019-11-18 20:34:04 -08:00
Jun Wu
1f5ccb5939 test-hggit-bookmark-workflow: update the test
Summary: D18544475 changed `phase` output. Update this test.

Reviewed By: singhsrb

Differential Revision: D18587462

fbshipit-source-id: 82b5a75a006c792f259af9ca038c24a032069f55
2019-11-18 20:34:04 -08:00
Jun Wu
48722a4f20 test-contrib: remove the test
Summary: The test was about `simplemerge`, which was removed. Therefore, remove the test.

Reviewed By: singhsrb

Differential Revision: D18587461

fbshipit-source-id: daf12f0c38ec08a0f73d834b8f32dc1a65620a8f
2019-11-18 20:34:04 -08:00
Xavier Deguillard
81aabc01e7 phase: print node, not revision number
Summary: Revision numbers are going away, let's print the node instead.

Reviewed By: quark-zju

Differential Revision: D18544475

fbshipit-source-id: df9ab928a3f7dbbcd95352eebcea46f563eec4f3
2019-11-18 13:23:00 -08:00
David Tolnay
066f461bcf Replace reliance on From<Context<_>> with an extension trait and constructor
Summary:
Edenapi uses a group of impls like the following as the canonical way to construct ApiError.

```
impl From<Context<ApiErrorKind>> for ApiError {
```

Downstream code would write:

```
use failure::ResultExt;

let stream_trees = config
    .get_or_default("edenapi", "streamtrees")
    .context(ApiErrorKind::BadConfig("edenapi.streamtrees"))?;
```

This relies on the way that ResultExt::context returns a unique type that is different from failure::Error.

This diff introduces a dedicated extension trait to allow the same code in the caller to continue to work even without a failure::Context<T> type, which will be required for dropping our dependency on failure::Fail and failure.

```
pub trait ApiErrorContext<T> {
    fn context(self, kind: ApiErrorKind) -> ApiResult<T>;
}
```

We also introduce a public constructor for ApiError and replace indirect construction that used to look like this:

```
error.context(ApiErrorKind::Curl).into()
```

with this instead:

```
ApiError::new(ApiErrorKind::Curl, error)
```

which is the same number of characters but clearer. The argument order matches [std::io::Error::new](https://doc.rust-lang.org/std/io/struct.Error.html#method.new).

Reviewed By: kulshrax

Differential Revision: D18574668

fbshipit-source-id: 0a56297bb942a26d75a62ca39fc16abeb4486345
2019-11-18 12:12:43 -08:00
Jun Wu
9561b5e22a treematcher: do not crash on non-utf-8 paths
Summary:
On Windows, the paths passed to the `match` functions are not encoded in utf-8
yet.  Do not crash if received them.

Reviewed By: sfilipco

Differential Revision: D18574951

fbshipit-source-id: c22ce95cb6538db0c15d60789286e2ff7d2148bc
2019-11-18 11:44:53 -08:00
David Tolnay
6ff01a57ec commitcloudsubscriber: Consolidate CommitCloudHttpError into ErrorKind enum
Summary: The CommitCloudHttpError seems to have been working around a limitation of failure's derive that no longer applies to thiserror.

Reviewed By: xavierd

Differential Revision: D18523907

fbshipit-source-id: 54efaedc405911a412ce842dff6285fb80d875b8
2019-11-18 11:44:52 -08:00
Jun Wu
13a6237c1d run-tests: silent some errors from run-tests itself
Summary:
I have seen errors like:

  Traceback (most recent call last):
    File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
      self.run()
    File "/usr/lib64/python2.7/threading.py", line 765, in run
      self.__target(*self.__args, **self.__kwargs)
    File "./run-tests.py", line 2636, in job
      del runningtests[test.name]
    File "/usr/lib64/python2.7/collections.py", line 68, in __delitem__
      dict_delitem(self, key)
  KeyError: 'test-empty-t.py'

It's not fatal and is caused by race condition. So let's just ignore it.

Reviewed By: ikostia

Differential Revision: D18538388

fbshipit-source-id: 85e38578bea4c9b27439e6f10abb7619a8bb9238
2019-11-18 11:42:09 -08:00
Jun Wu
b4f7ff744e run-tests: dott Python tests do not have reference outputs
Summary:
Before this patch, if `test-foo-t.py.out` exists, the output of `test-foo-t.py`
will be diffed against it, something like:

  % ./run-tests.py test-empty-t.py
  --- test-empty-t.py.out
  +++ test-empty-t.py.err
  @@ -1,4 +1,4 @@
   Traceback (most recent call last):
     File "tests/test-empty-t.py", line 77, in <module>
  -    raise RuntimeError('a')
  -RuntimeError: a
  +    raise RuntimeError('ab')
  +RuntimeError: ab

However, the dott Python tests are not using "reference output" at all. If they
output something, it's mostly likely some crash or back traces that we want to
see the full content of it.

This patch makes it so. The new output looks like:

  % ./run-tests.py test-empty-t.py
  Traceback (most recent call last):
    File "tests/test-empty-t.py", line 77, in <module>
      raise RuntimeError('ab')
  RuntimeError: ab

  ERROR: test-empty-t.py output changed

As we're here, also improve the detection of dott Python test so they don't
have to have the `-t.py` suffix in file name.

Reviewed By: ikostia

Differential Revision: D18534830

fbshipit-source-id: 826328be5de5841081e8f093b07295bc2fadc6b1
2019-11-18 11:42:08 -08:00
Puneet Kaushik
276ee0b882 fixing hg add on Eden Windows clone
Summary: Eden sets the "portablefilenames" to ignore and the current Mercurial code doesn't consider the setting on Windows, which triggers iterate on the Eden clone. Iterate is an unsupported function on Eden clone.

Reviewed By: quark-zju

Differential Revision: D18195607

fbshipit-source-id: a21e1fcec3ee74398f22eaf56c70116468a45b45
2019-11-18 11:31:17 -08:00
Victor Zverovich
3285a8f909 Replace Folly Format with fmt in logger to reduce binary size
Summary:
Now that fmt is available in Folly builds (D14813810), use it to reduce binary code size in Folly Logger. This is done by moving most of the formatting logic behind the type-erased `vformat` API. Previously it was instantiated for all combinations of formatting argument types used in calls to `FB_LOGF` and `XLOGF` in a program.

The effect of this change can be illustrated by looking at symbol sizes as given by `nm -S -td` for the following test function:

```
void test_log() {
  FB_LOGF(logger, WARN, "num events: {:06d}, duration: {:6.3f}", 1234, 5.6789);
}
```
compiled in `opt` mode.

`nm` before:

```
0000000004236736 0000000000000231 T test_log()
0000000004236992 0000000000001002 W std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > folly::LogStreamProcessor::formatLogString<int, double>(folly::Range<char const*>, int const&, double const&)
```

`nm` after:

```
0000000004237536 0000000000000231 T test_log()
0000000004237792 0000000000000251 W std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > folly::LogStreamProcessor::formatLogString<int, double>(folly::Range<char const*>, int const&, double const&)
0000000004238048 0000000000000740 W folly::LogStreamProcessor::vformatLogString[abi:cxx11](folly::Range<char const*>, fmt::v5::format_args, bool&)
```

Before we had one 1002 byte instantiation of `formatLogString<int, double>`. With this change it was reduced 4x to 251 bytes and non-template function `vformatLogString` was added which is shared among all logging calls. The size of `test_log` remained unchanged. There are even bigger savings from Folly Formatter instantiations which are no longer needed, e.g.

```
0000000004238032 0000000000001363 W _ZNK5folly13BaseFormatterINS_9FormatterILb0EJRKiRKdEEELb0EJS3_S5_EEclIZNKS7_8appendToINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENSt9enable_ifIXsr12IsSomeStringIT_EE5valueEvE4typeERSH_EUlNS_5RangeIPKcEEE_EEvSK_
```

So in total this change results in ~5x per-call/instantiation binary size. It is possible to reduce binary size even further but it is not done in the current diff to keep it manageable.

In addition to binary size improvements, switching to fmt will potentially

* allow catching errors in format strings at compile time,
* simplify future migration to C++20 [`std::format`](http://eel.is/c++draft/format).

Reviewed By: simpkins

Differential Revision: D15485589

fbshipit-source-id: 06db4436839f11c2c3dbed7b36658e2193343411
2019-11-18 05:53:08 -08:00
Xavier Deguillard
41e5d10db5 amend: _setbookmark already takes a node
Summary:
The caller already pass in a node, so there is no need to convert the rev
number to a node. This broke `hg next -B`.

Reviewed By: quark-zju

Differential Revision: D18539038

fbshipit-source-id: 44afdd184bc7c949f8efb863702af8a301bbcfb7
2019-11-16 12:57:36 -08:00
Jun Wu
e5d47a8bde codemod: remove unneeded files
Summary:
Remove files that are ancient, not used, or not referred.
The file list was initially generated via a Ruby script:

  (Dir['{contrib,tests}/**']-Dir['tests/test-*']).select{|name| `rg #{File.basename(name).split('.')[0]}`.empty?}

Plus some manual selection.

Some notes about deleted files:
- Revset benchmarks: Benchmarks on the Rust side is a cleaner choice.
- editmerge and hg-new-workdir: Newer versions live in fb/.

Reviewed By: xavierd

Differential Revision: D18541783

fbshipit-source-id: f08933d5c1a9c46d25322adbc2cc1e8a1b505d70
2019-11-15 17:08:40 -08:00
Michael Devine
02295d54b6 Fix commit ordering
Summary: The commit timestamps in Git have second granularity. As a result, sometimes multiple succeeding commits have numerically equivalent timestamps. This means that sorting by timestamp may not result in the correct ordering of commits. This is particularly true because the sort we use is a stable sort, which means that commits with the same timestamp must go into the sort in ascending commit history order to have the correct order coming out of the sort. This commit updates the log that generates the list to use ascending commit order rather than descending.

Reviewed By: tchebb

Differential Revision: D18486839

fbshipit-source-id: 7a0ff099375a250d92b0f1a846e1105bf7bb9c86
2019-11-15 11:16:09 -08:00
Stefan Filip
e07097e3bc tests: set flatcompat=False for test-fb-hgext-treemanifest-pushrebase.t
Summary: Title

Reviewed By: quark-zju

Differential Revision: D18463485

fbshipit-source-id: 6356d87743764e85f46e91e6bffe35db7ebdf10b
2019-11-15 10:47:50 -08:00
Michael Devine
8c7131b74f Optimize memory usage of rev-list parser
Summary: The existing logic for parsing rev-list data relies very heavily on split, which creates many intermediate strings that take up a lot of memory. This commit updates the logic to use indices into the original output to extract individual strings. It also includes a new unit test for the list parsing. Big thanks to Tom Hebb for identifying the excessive memory usage.

Reviewed By: tchebb

Differential Revision: D18513949

fbshipit-source-id: c3b4e420ae2635904b42b84f2973e83c81c21dd7
2019-11-15 10:38:48 -08:00
Xavier Deguillard
75d4a47eb1 histgrep: replace rev number with node in default output
Summary:
Revision numbers are deprecated, let's only show the short hash of the commit
instead.

Reviewed By: quark-zju

Differential Revision: D18519655

fbshipit-source-id: df277cc7e99ad747899d1fae2d92cd88eebea0f1
2019-11-15 09:48:10 -08:00
David Tolnay
9c6f253858 rust: Replace derive(Fail) with derive(Error)
Summary:
This diff replaces code of the form:

```
use failure::Fail;

#[derive(Fail, Debug)]
pub enum ErrorKind {
    #[fail(display = "something failed {} times", _0)]
    Failed(usize),
}
```

with:

```
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ErrorKind {
    #[error("something failed {0} times")]
    Failed(usize),
}
```

The former emits an implementation of failure 0.1's `Fail` trait while the latter emits an impl of `std::error::Error`. Failure provides a blanket impl of `Fail` for any type that implements `Error`, so these `Error` impls are strictly more general. Each of these error types will continue to have exactly the same `Fail` impl that it did before this change, but now also has the appropriate `std::error::Error` impl which sets us up for dropping our various dependencies on `Fail` throughout the codebase.

Reviewed By: Imxset21

Differential Revision: D18523700

fbshipit-source-id: 0e43b10d5dfa79820663212391ecbf4aeaac2d41
2019-11-14 22:04:38 -08:00
Xavier Deguillard
d7de06ddfd cmdutil: use ctx.node() instead of ctx.rev() in finddate
Summary:
The finddate function is used when using `hg update --date`, and since it
returned a revision number, the user would see the revision number deprecation
warning. Using nodes solves this.

Reviewed By: quark-zju

Differential Revision: D18486760

fbshipit-source-id: e1a51f624d8e7133fbf334f9b8b4b4c3d5aff2a0
2019-11-14 15:30:47 -08:00
Jun Wu
055cf342d9 pathmatcher: hint globset to use prefix strategy instead of regexp strategy
Summary:
`globset` supports multiple matching strategies, including literal prefix
(backed by AhoCorasick), or regexp, etc.

In theory patterns like `foo/**` (where `*` cannot match `/`) can use `foo`
prefix strategy. However, the implementation detail of `globset` wouldn't
accept it as a prefix. But `foo/*` (where `*` can match `/`) can be treated as
a prefix. Transform the former pattern to the latter to hint `globset` to use
the optimal strategies.

Reviewed By: sfilipco

Differential Revision: D18500298

fbshipit-source-id: 39e604d6157a919b75c392488b6d42375e518c16
2019-11-14 14:27:39 -08:00
David Tolnay
b1793a4416 rust: Rename Fallible<T> to Result<T>
Summary:
This diff is preparation for migrating off of failure::Fail / failure::Error for errors in favor of errors that implement std::error::Error. The Fallible terminology is unique to failure and in non-failure code we should be using Result<T>. To minimize the size of the eventual diff that removes failure, this codemod replaces all use of Fallible with Result by:

- In modules that do not use Result<T, E>, we import `failure::Fallible as Result`;
- In modules that use a mix of Result<T, E> and Fallible<T> (only 5) we define `type Result<T, E = failure::Error> = std::result::Result<T, E>` to allow both Result<T> and Result<T, E> to work simultaneously.

Reviewed By: Imxset21

Differential Revision: D18499758

fbshipit-source-id: 9f5a54c47f81fdeedbc6003cef42a1194eee55bf
2019-11-14 14:11:01 -08:00
Jun Wu
63c1b3001d treematcher: implement proper error handling
Summary:
simpkins encountered a case where the treematcher does not work with many
patterns.  It turns out `globset` has a hard-coded regex size limit (10MB).

Implement proper error handling so we can detect such issues and fallback to
slower paths.

Reviewed By: sfilipco

Differential Revision: D18500299

fbshipit-source-id: 0122ba9b0246c1536b2069a40e13261ee47f8bba
2019-11-14 11:43:18 -08:00
Jun Wu
d56700b63c lfs: implement gc
Summary: Add `hg debuglfsgc` command to reclaim disk space. Make it part of `hg gc`.

Reviewed By: xavierd

Differential Revision: D18417035

fbshipit-source-id: 7c0a445a0d4405df5cff960c0e28c4fc5a1f2c31
2019-11-14 11:14:05 -08:00
Xavier Deguillard
9d8eec40e4 rebase: properly handle --keep
Summary:
Even keep was being passed in, rebase still added mutation markers to the old
commits, which would then make them hidden in the smartlog output. Not adding
the mutation markers in this case solves the issue.

Reviewed By: quark-zju

Differential Revision: D18496840

fbshipit-source-id: f5d0f8920bd00041598841a65356b88df00708d7
2019-11-14 11:14:05 -08:00
Adam Simpkins
46890ae1ec Merge fb-mercurial sources into the eden repository
Summary:
Merge the fb-mercurial code into the Eden repository, under the
`eden/scm` subdirectory.

Reviewed By: quark-zju

Differential Revision: D18445774

fbshipit-source-id: fc3307f9937e0c7e1c8f7d03c5102c4fe5dedb10
2019-11-13 20:20:32 -08:00
Adam Simpkins
ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00