Commit Graph

348 Commits

Author SHA1 Message Date
Stanislau Hlebik
d1cd7bf28f mononoke: put different modes to different subcommands in hg sync job
Summary:
Small refactoring before the  next diffs.

Before
  mononoke_hg_sync ...  --mode sync-once ssh://PATH  --start-id 0

Now
  mononoke_hg_sync ...  ssh://PATH sync-once --start-id 0

Reviewed By: HarveyHunt

Differential Revision: D14226940

fbshipit-source-id: 1b6db6f194aecb2f4bdb7bbd9e846aaba180e098
2019-02-26 11:01:23 -08:00
Stanislau Hlebik
f8e118000a sendunbundle: better process errors
Summary:
We didn't process parts like `error:abort` and so we might have easily missed
an error. This diff fixes it.

Reviewed By: quark-zju

Differential Revision: D14185378

fbshipit-source-id: e68e365fd939a4bd6a0c2835a513ebc94530aa87
2019-02-25 13:06:55 -08:00
Stanislau Hlebik
cb70c58b45 mononoke: simplify pushrebase replay
Summary:
Pretty big cleanup. The biggest part is simplifying comparing logic.
Pushrebase replay compared replayed pushrebase commits with their hg
counterparts. Because previously we didn't log enough data from hg servers we
had to jump through a lot of hoops to find out which commits should be compared
to which.
Now we are logging `ordered_added_revs` i.e. which commits mercurial produced
after the hg pushrebase, which is exactly what we need for comparison. So a lot
of code can be simplified.

That does mean though that some of the recorded pushrebases we won't be able to
replay because they don't have `ordered_added_revs`. At the moment we have
~300K pushrebases without `ordered_added_revs` and ~100K with. I think this
change is worth it given how simpler the code is and I'd argue 100K is a pretty
big number. For the rest 300K pushrebases we can later manually fill in
`ordered_added_revs` field if we consider it's necessary.

After this diff pushrebase replay won't use hg repo, and so we can run it on
normal twshared jobs instead of on hg servers.

A few smaller changes:
1) Also note that for now this diff makes pushrebase replay single threaded, while
previously we ran comparison in parallel. That will be fixed in the next diffs.

2) Pushrebase replay now always compare commits i.e. `--compare-commits` option
was removed

Also change repo id in tw spec to 20

Reviewed By: HarveyHunt

Differential Revision: D14122963

fbshipit-source-id: 0f8da7cffb13899f11143a01d1a301fdf8ea7f00
2019-02-25 09:32:16 -08:00
Stanislau Hlebik
f04a37cca2 mononoke: mononoke -> hg sync job
Summary:
First stab at a job that will keep hg in sync with Mononoke when Mononoke
becomes a source of truth.

Reviewed By: ikostia

Differential Revision: D14018269

fbshipit-source-id: f88c5eba8bf5482f2f162b7807ca8e41a3b4291d
2019-02-21 05:47:31 -08:00
Stanislau Hlebik
60c09b8a0c mononoke: do not change timezone during pushrebase
Summary: That matches mercurial pushrebase behaviour.

Reviewed By: ikostia

Differential Revision: D14149754

fbshipit-source-id: 66c0d09e78a21f2f308aba4d334c2db3118cfe9f
2019-02-21 05:47:31 -08:00
Stanislau Hlebik
6ddf4d16eb mononoke: revert D14143772
Summary:
Running hook test locally results in flaky errors - the new output just
disappears.

This is the error I'm getting

```
ERROR: test-hook-deny-files.t output changed
 --- test-hook-conflict-markers.t
+++ test-hook-conflict-markers.t.err
@@ -70,18 +70,6 @@
   searching for changes
   remote: Results of running hooks
   remote:   948f2cea 1
-  remote:     FAILED file hooks:
-  remote:       - conflict_markers on 1: Conflict markers were found in file '1'
-  remote:     no changeset hooks to run
-  remote:     1 of 1 file hooks failed
-  remote:     REJECTED
-  remote: Command failed
-  remote:   Error:
-  remote:     hooks failed
-  remote:   Root cause:
-  remote:     ErrorMessage {
-  remote:         msg: "hooks failed"
-  remote:     }
   abort: stream ended unexpectedly (got 0 bytes, expected 4)
   [255]

```

Apparently the output is not flushed properly

Reviewed By: HarveyHunt

Differential Revision: D14163914

fbshipit-source-id: b2acda3514ada0f720444f32f93997e148eed5f6
2019-02-21 05:47:31 -08:00
Liubov Dmitrieva
d32e501b71 commitcloud: trigger a backup to a secondary storage after cloud sync in the background
Summary:
We can't run in parallel at the moment as the log file and the lock file are
shared.

Every path maintains independent backup state (the previous diff).

The secondary backup state doesn't affect smartlog (only the main one)

The issue with this approach is that we maintain backup lock a bit longer.

Unfortunately, the progress in smartlog doesn't show anything about the second backup.

I added 'finished', it makes it easier to compare in the logs.

Reviewed By: markbt

Differential Revision: D14149399

fbshipit-source-id: f90e8aac6cb8dee53d5c7468bd6adba067e13362
2019-02-20 15:35:46 -08:00
Lukas Piatkowski
23cf9d0f4f hooks: pretty print summary of running a hook during push
Reviewed By: StanislavGlebik

Differential Revision: D14143772

fbshipit-source-id: c7770dc57dc1d49c373e7ddfc5cfb05e708c36af
2019-02-20 08:52:09 -08:00
Lukas Piatkowski
4150292a66 slog_ext: add SimpleFormatWithError to improve client side logging readability
Reviewed By: StanislavGlebik

Differential Revision: D14143774

fbshipit-source-id: 3afdaab20a15f61964cd5a604b35749803573ce9
2019-02-20 08:52:09 -08:00
Jun Wu
d3d4326fd8 remotenames: remove logic about named branches
Summary: Named branches are going away. Remove the logic around it.

Reviewed By: phillco

Differential Revision: D13978575

fbshipit-source-id: d6e28d7cadffa612f74a2afc12800829d6113dfa
2019-02-12 19:52:48 -08:00
Kostia Balytskyi
02ab033b04 mononoke: enable bundle2 content preservation conditionally
Summary: This is adds a metaconfig option to preserve push/pushrebase bundles in the blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D14020299

fbshipit-source-id: 94304d69e0ac5d81232f058c6d94eec61eb0020a
2019-02-12 13:03:48 -08:00
Kostia Balytskyi
19f4c1cd8d mononoke: add a no-op code to preserve raw bundle2 contents in the blobstore
Summary:
This diff does not change anything on it's own, but rather adds the not
reachable (but already somewhat tested) code to preserve bundles when doing
pushes and pushrebases.

I want to land it now so that conflict resolution is easier.

Reviewed By: StanislavGlebik

Differential Revision: D14001738

fbshipit-source-id: e3279bc34946400210d8d013910e28f8d519a5f8
2019-02-11 14:48:37 -08:00
Stanislau Hlebik
d0eac0f60f mononoke: save bundles for replay
Summary:
Together with logging bookmark moves, let's also log bundle handle. It will be
used during replay from Mononoke to mercurial.

Reviewed By: ikostia

Differential Revision: D13990929

fbshipit-source-id: 4039322903b13e84fb31c8e65cc2e097ca765213
2019-02-11 05:50:55 -08:00
Stanislau Hlebik
a75a1453f7 mononoke: add bookmark reason moves
Summary:
This is the first step in adding support for tracking all bookmark moves. They
will be recorded in the separate mysql table in the same transaction as
bookmark is updated.

That gives us two things:
1) Ability to inspect all bookmark moves and debug issues with them
2) Also record which mercurial bundle moved a bookmark if any so that we could
later replay these bundles in correct order on hg

Add a struct that let us track bookmark moves.

Reviewed By: ikostia

Differential Revision: D13958872

fbshipit-source-id: 9adfee6d977457db5af4ad5d3a6734c73fcbcd76
2019-02-11 05:50:54 -08:00
Lukas Piatkowski
322c029423 hooks tests: pass mocked values to test-hook-verify-integrity.t
Summary: Additionally parts of the hook were adjusted to better fit Mononoke design rather than being a copy of Mercurial version of the hook and so that kill switches are configs and test script is being passed through config

Reviewed By: StanislavGlebik

Differential Revision: D13964487

fbshipit-source-id: 8ab2784083ece80dfb781ddd1245172e65699ad7
2019-02-08 07:39:57 -08:00
Lukas Piatkowski
8fabbf8e18 integration tests: pass extra configs via file descriptor
Summary: Passing input on command line is restricted to the maximum length of a command, it is much better to pass the file descriptor, this way one can pass very long inputs inside the bash functions.

Reviewed By: StanislavGlebik

Differential Revision: D13964484

fbshipit-source-id: da010ecfcf05da8c5860c8b5ee0860a8aeda0502
2019-02-08 07:39:56 -08:00
David Budischek
d844c21777 Thrift endpoint for is_ancestor
Summary:
I decided against using the naming convention maybe_ancestor and maybe_descendant as I believe the name is_ancestor already implies this uncertainty.

Skiplist is used instead of bfs, this improves performance significantly when using very old commits. For now we do not update skiplist as more recent commits are in cache anyway.

Reviewed By: StanislavGlebik

Differential Revision: D13917333

fbshipit-source-id: 21b49d920ff473c953a952ee3c6d7b55565f98ac
2019-02-08 03:31:09 -08:00
Kostia Balytskyi
8c8215da82 mononoke: check if we can delete bookmarks in pushrebase pushes
Reviewed By: StanislavGlebik

Differential Revision: D13970634

fbshipit-source-id: b802ed02dc4750856df4c0e0d2493ac3bbee2955
2019-02-06 15:20:57 -08:00
Kostia Balytskyi
b40f3f1e94 mononoke: test force pushes
Summary: Test that we can non-forward push a bookmark. Hooks should prevent that for some bookmarks, but they are a different matter.

Reviewed By: lukaspiatkowski

Differential Revision: D13803097

fbshipit-source-id: f2dfba9a21f83127e8c92397c728a074037da046
2019-02-06 15:20:57 -08:00
Kostia Balytskyi
64c9a55c46 mononoke: check that we can create bookmarks on public commits in pushrebase
Reviewed By: StanislavGlebik

Differential Revision: D13970699

fbshipit-source-id: 8b840f9a2cd5f79532c51c9735a9128e5040e1fd
2019-02-06 15:20:57 -08:00
Lukas Piatkowski
515a2909eb monononoke hashes: remove usages of borrows of hashes which are Copy
Summary: The Copy trait means that something is so cheap to copy that you don't even need to explicitly do `.clone()` on it. As it doesn't make much sense to pass &i64 it also doesn't make much sense to pass &<Something that is Copy>, so I have removed all the occurences of passing one of ouf hashes that are Copy.

Reviewed By: fanzeyi

Differential Revision: D13974622

fbshipit-source-id: 89efc1c1e29269cc2e77dcb124964265c344f519
2019-02-06 15:11:35 -08:00
Kostia Balytskyi
2c4ea43016 mononoke: test pushrebase of a merge with public p2
Summary:
Can we rebase a merge commit whose one parent (p2) is an ancestor of our public
bookmark and the other - not?

Reviewed By: lukaspiatkowski

Differential Revision: D13802863

fbshipit-source-id: f12cbc0684a001a2b9ac6eb903d825e73777ab58
2019-02-06 14:51:52 -08:00
Kostia Balytskyi
52d5b5d52b mononoke: test rebases over a merge commit
Summary:
Are we sure we're prohibiting rebases over the merge commit in a public
history?

Reviewed By: lukaspiatkowski

Differential Revision: D13802865

fbshipit-source-id: d9556ea0616825f82d1f781c4e57bc01a5c5a0b0
2019-02-06 14:51:52 -08:00
Kostia Balytskyi
f8c4fc8ed2 mononoke: add a test for pushrebasing an unrelated merge
Summary: Can we rebase a merge where both parents are not ancestors of current master?

Reviewed By: lukaspiatkowski

Differential Revision: D13802864

fbshipit-source-id: 0003c72c54e8689e1a26a252d48008bac31d5c0b
2019-02-06 14:51:52 -08:00
Kostia Balytskyi
bc164d0f58 mononoke: add pushing with no new commits to test-pushrebase
Summary: Can we do a no-op push which neither adds commits nor advances a bookmark?

Reviewed By: lukaspiatkowski

Differential Revision: D13802862

fbshipit-source-id: 7ef3b7a2f79c9dc9619ffb4f0fad925d263ff425
2019-02-06 14:51:52 -08:00
Kostia Balytskyi
a6d873c9b9 mononoke: add fast-forward pushes to test-pushrebase
Summary: Do we successfully push a commit when no rebasing is needed?

Reviewed By: lukaspiatkowski

Differential Revision: D13802868

fbshipit-source-id: 5ca73f59b4057d8c00f10320a2d6b76f0197187d
2019-02-06 14:51:52 -08:00
Kostia Balytskyi
71e749a192 mononoke: test pushrebase with conflict in the top and bottom of the stack
Summary: Similarly to Mercurial's `pushrebase` tests, we want to test both cases.

Reviewed By: lukaspiatkowski

Differential Revision: D13802867

fbshipit-source-id: 77dc875857602e5abb177af4f61af9f1fda072e3
2019-02-06 14:51:52 -08:00
Kostia Balytskyi
b3aa0ef6d2 mononoke: use concise logs for test-pushrebase
Summary: Just a helper to print more concise logs.

Reviewed By: StanislavGlebik

Differential Revision: D13802866

fbshipit-source-id: 77c44735a416612320b22e20fa4413923334f79c
2019-02-06 14:51:51 -08:00
Arun Kulshreshtha
29653123f2 edenapi: rename mononokeapi to edenapi
Summary: Rename Mononoke API to Eden API, per war room discussion.

Reviewed By: quark-zju

Differential Revision: D13908195

fbshipit-source-id: 94a2fe93f8a89d0c5e9b6a24939cc4760cfaade0
2019-02-05 21:23:24 -08:00
Arun Kulshreshtha
2f0414068f mononokeapi: use auth section for TLS configuration
Summary:
Use the hgrc auth section to configure HTTP data fetching. For example:

```
[mononoke-api]
enabled = true
url = https://mononoke-api.internal.tfbnw.net

[auth]
mononoke-api.prefix = mononoke-api.internal.tfbnw.net
mononoke-api.schemes = https
mononoke-api.key = /var/facebook/credentials/$USER/x509/$USER.pem
mononoke-api.cert = /var/facebook/credentials/$USER/x509/$USER.pem
```

Reviewed By: DurhamG

Differential Revision: D13907185

fbshipit-source-id: 3b607f25912a85438b56c4ea7ab9cfed91ab7e85
2019-02-05 21:23:24 -08:00
Stanislau Hlebik
0c3fdfbf1e mononoke: add tests for pushrebase replay
Summary:
There were lots of small stupid mistakes with pushrebase replay in past.
Since pushrebase replay will stay with us for quite some time,
let's add a test to prevent these regressions in future.

In tests we'll use filesystem+sqlite instead of everstore + xdb to fetch
requests to replay.

Reviewed By: HarveyHunt

Differential Revision: D13940390

fbshipit-source-id: a4398d1c8c22bf16a85d6391a1f5665ce4b73eb1
2019-02-05 15:08:29 -08:00
Stanislau Hlebik
261e2674bc remotefilelog: add an option to verify all the hashes
Reviewed By: DurhamG

Differential Revision: D13838772

fbshipit-source-id: e7220ba8a0e07f3003693199086e3a3512023857
2019-02-05 15:03:11 -08:00
Stanislau Hlebik
0b0a5b93b2 mononoke: extract blobrepo_factory and postcommit from blobrepo
Summary:
`blobrepo_factory` is a crate that knows how to create blobrepo given
a configuration i.e. it creates blobstores, filenodes, changesets etc and
initializes blobrepo with them.

`post_commit` is a small part of blobrepo which can also be extracted from
blobrepo crate.

There are a few upsides with this approach
1) Less dependencies on Blobrepo, meaning we have to rebuild it fewer times
2) BlobRepo compilation is faster

Reviewed By: jsgf

Differential Revision: D13896334

fbshipit-source-id: 1f5701341f01fcefff4e5f9430ddc914b9496064
2019-02-05 01:23:15 -08:00
Lukas Piatkowski
05588f9e79 hook limit_filesize: make filesizelimit configurable via config
Reviewed By: StanislavGlebik

Differential Revision: D13901487

fbshipit-source-id: 8bef6a7d9a7ec6acfdf51a3a2ab62dd2e3ff38de
2019-02-01 05:52:20 -08:00
Johan Schuijt-Li
5fd2d5ae7a handle uncaught exceptions in AclChecker
Reviewed By: StanislavGlebik

Differential Revision: D13808604

fbshipit-source-id: b4d807754d5f935507bd7c787abdf80c9ecb8654
2019-02-01 03:51:34 -08:00
Arun Kulshreshtha
0d42fe39c8 mononokeapi: add metadata to datapack
Summary: Add metadata to each delta entry written to the datapack. Since the HTTP API never serves LFS files, and the only flag currently used simple indicates whether a file should use LFS, the flag field is intentionally set to `None`, leaving only the size in the metadata (which, since we're storing full file content, is the same as the content length).

Differential Revision: D13894292

fbshipit-source-id: 36db25adb0c46cd1c7fde841a69d3e6d48d08d06
2019-02-01 01:42:15 -08:00
Arun Kulshreshtha
1f6389a3da remotefilelog: add debug command to fetch multiple files over HTTP
Summary: Previously, `hg debuggetfile` would allow fetching a single file from the API server. This diff updates the command to `hg debuggetfiles`, which accepts a list of filenode/path pairs on stdin, and fetches all the files concurrently, writing the contents to a single datapack.

Reviewed By: DurhamG

Differential Revision: D13893894

fbshipit-source-id: 36fc54f1870273ab4b447de5d615b3fb6aaa3378
2019-02-01 01:42:15 -08:00
Arun Kulshreshtha
c173d738ee mononokeapi: add ability to fetch a file and write it to a datapack
Summary: Add a new `get_file()` method to `MononokeClient` that fetches Mercurial file content from the API server and writes it to a datapack in the cache. This functionality is exposed via the new `hg debuggetfile` debug command, which takes a filenode and file path and fetches the corresponding file.

Differential Revision: D13889829

fbshipit-source-id: 2b68bf114ee72d641de7a1043cca1975e34cf4e6
2019-02-01 01:42:15 -08:00
Arun Kulshreshtha
b5b0af79bc Add API server endpoint to serve HG file content
Summary: Add a `/getfile/` endpoint that takes a filenode and returns Mercurial file content. This is similar to the `/blob/` endpoint, except the returned content can also include copy information in the case that the file was copied. This matches the exact format in which Mercurial stores file content, so the resulting output can be directly written to disk.

Reviewed By: chadaustin

Differential Revision: D13876096

fbshipit-source-id: 0417cb1f993c4c93687e364b1647490c3a9040bc
2019-02-01 01:42:15 -08:00
David Budischek
b017b8eb94 Improved error handling for thrift apiserver
Summary:
At From<Error>::from errors are automatically downcast into an InternalError. While we unwrap them for http this was not done for thrift, resulting in an InternalError being returned for everything. By unwrapping the error first thrift now returns more meaningful errors.

In addition I added a new errorkind for ls_v2, this is purely for internal structure as the client will still see an InvalidInput error.

Reviewed By: StanislavGlebik

Differential Revision: D13881374

fbshipit-source-id: bd2e43a0ac7e5abdbf41068c3b1ab37681f03009
2019-01-31 05:03:44 -08:00
Arun Kulshreshtha
9f46866c75 remotefilelog: rename debugmononokeapi to debughttphealthcheck
Summary: Rename this debug command to make it obvious what it does (i.e., perform a health check) and make it print more useful output (i.e., the name of the server for which it performs the health check).

Reviewed By: DurhamG

Differential Revision: D13890867

fbshipit-source-id: 8fc96bcc06d04611a308ecc0b870049936f1cb29
2019-01-30 18:31:48 -08:00
Liubov Dmitrieva
310e8dab3d make test infra files to be symlinks to the mercurial ones.
Summary:
I already made them the same (but copy) in a different diff. As we discussed at
war room, symlinks is a better solution.

Also removed unused import and some functions that were copied from mercurial.
This is no longer needed as we now share tinit.sh with general purpose
functions.

The only mononoke specific file left is dummyssh.py

I think later we could pack them in a separate buck target or something and share in a better way that symlinks but for now it is the easiest solution.

Reviewed By: DurhamG

Differential Revision: D13881960

fbshipit-source-id: 36f425d6f0ddbae2c9d083de35d2779669dc01e7
2019-01-30 11:51:41 -08:00
Liubov Dmitrieva
77cc38f5d9 move to the same hg tests runner that is used by hg
Summary:
This is the first step, I just copied the files from mercurial to mononoke/tests/integration/third_party and made it work.

Further unification is required to reuse the same files.

It renders progress bars and other fancy things and matches our mercurial test framework.

Also it allows to use embedded python code!

Some things are not supported: like aliases, so changes in the tests are required.

Some  tests used urandom and cat in a wrong way, I had to fix it as well.

Reviewed By: lukaspiatkowski

Differential Revision: D13871531

fbshipit-source-id: c723bb18c2233639bb36bc7964e57baddff4c0b9
2019-01-30 07:29:53 -08:00
Jun Wu
7532a39624 codemod: import from the edenscm package
Summary:
D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`.
That has nasty problems if both `import mercurial` and
`import edenscm.mercurial` are used, because Python would think `mercurial.foo`
and `edenscm.mercurial.foo` are different modules so code like
`try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)`
would fail to handle the `edenscm.mercurial` version. There are also some
module-level states (ex. `extensions._extensions`) that would cause trouble if
they have multiple versions in a single process.

Change imports to use the `edenscm` so ideally the `mercurial` is no longer
imported at all. Add checks in extensions.py to catch unexpected extensions
importing modules from the old (wrong) locations when running tests.

Reviewed By: phillco

Differential Revision: D13868981

fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
2019-01-29 17:25:00 -08:00
Lukas Piatkowski
cc1568938b hooks: move them outside of the test directory to a better place
Reviewed By: StanislavGlebik

Differential Revision: D13817338

fbshipit-source-id: 866971b6631d121f4c85087db425e908a5308367
2019-01-29 08:23:04 -08:00
Stanislau Hlebik
67f220c89c mononoke: fix pushrebasing an empty commit
Summary:
Previously pushrebasing an empty commit failed because we assumed that root
manifest of a commit is always sent in a bundle. This diff removes this
assumption

Reviewed By: lukaspiatkowski

Differential Revision: D13818556

fbshipit-source-id: 44e96374ae343074f48e42a90c691b21e3c41386
2019-01-28 14:40:40 -08:00
Stanislau Hlebik
c950025387 mononoke: fix tests
Reviewed By: ikostia

Differential Revision: D13845830

fbshipit-source-id: 2423939ef02d094a2f24dbfa189e8dc4a7ee6dbd
2019-01-28 14:40:40 -08:00
Stanislau Hlebik
dac741fb1a mononoke: do not ignore pushrebase update
Summary:
Pushrebase wasn't returning a response to a pushkey part, and we get `server
ignored bookmark ... update` messages. This diff fixes it by returning the
reply to a pushkey part.

Note that behaviour is different from mercurial. In mercurial many pushkey
parts are allowed, while we allow only which moves `onto` bookmark. That
shouldn't be restrictive, however we can change this behaviour later if needed.

Reviewed By: aslpavel

Differential Revision: D13781546

fbshipit-source-id: edb0fdc7dc10c7a5cf4c49157fce0887e71fcf8a
2019-01-28 06:56:52 -08:00
Liubov Dmitrieva
5ff6db64ef add special pushvar to push Commit Cloud commits to Mononoke
Summary: This allows us to run pushbackup and cloud sync commands for Read Only Mononoke repos.

Reviewed By: ikostia

Differential Revision: D13804545

fbshipit-source-id: 8026fc4668afc8bb5c2c0a9587ca024e3c6920da
2019-01-25 05:26:58 -08:00
Liubov Dmitrieva
610671e486 implement bypass readonly option (to be used for Commit Cloud in
Summary:
Next step is to change infinitepush / cloud sync to pass this pushvar to
Mononoke

Reviewed By: StanislavGlebik

Differential Revision: D13802402

fbshipit-source-id: 25e3d699bd934e3e015b9784040bd2dc4b43188d
2019-01-24 08:50:27 -08:00