sapling/blobimport_lib/src
Thomas Orozco 9068a413d4 mononoke: support non-publishing / non-pull_default Bookmarks
Summary:
This adds support for recording server-side whether a given bookmark is publishing and / or pull-default. This is a change on the way towards supporting Infinite Push in Mononoke. This diff will require schema changes on `xdb.mononoke_production`.

There isn't a whole lot of new user-facing functionality in this particular diff. For starters, nobody can edit this flag on bookmarks, and pushes that create a new bookmark will always result in setting a bookmark as publishing AND pull_default.

What this change does however introduce is the notion of `BookmarkHgKind`, which is represents the behavior of this bookmark as far as Mercurial operations are concerned.

There are 3 such kinds, which are relevant in different parts of the codebase:

- PullDefault - this is useful when we want to respond to listkeys queries.
- Publishing — this is useful when we want to identify commit Phases.
- All - this is useful when we want to respond to listkeyspatterns.

Note that only the first two groups are cached in CachedBookmarks.

 ---

There are a few things going on in this diff (which logically have to happen together):

- First, I updated the `Bookmarks` trait and its various implementations to expose new methods to select Bookmarks based on their hg kind. There's one method per hg kind, and all the methods use a `Freshness` parameter to determine whether to hit cache or not.
- Second, I refactored the various bookmark-access methods in blobrepo. A few of them were duplicative of each other, and some were unused, which became a bigger problem now that we had more (for publishing, pull default, etc.). We are now down to just one method that doesn't hit cache (which is used only by the blobimport script and some tests — perhaps this could be changed?).
- Third, I updated the call sites for the methods that were udpated in step 2 to use the proper method for their use case.

 ---

Here's a summary of where each method is used (I'm only listing stuff that isn't unit tests):

- `get_bonsai_heads_maybe_stale`:
  - `SqlPhases`'s `get_public`
  - `build_skiplist_index`
- `get_bonsai_publishing_bookmarks_most_recent`:
  - Blobimport (perhaps we can update this to a `maybe_stale` read?)
- `get_pull_default_bookmarks_maybe_stale`
  - `listkeys` implementations
- `get_publishing_bookmarks_maybe_stale`
  - API Server's `get_branches`
- `get_bookmarks_by_prefix_maybe_stale`:
  - `listkeyspatterns` implementation

 ---

As an aside, note that a lot of the code changes in this diff are actually in CacheBookmark's tests — I had to update those to minimize sleeps: it was fine to sleep in the earlier tests, but I introduced new quickcheck-based tests, and sleeping in those isn't ideal.

Reviewed By: StanislavGlebik

Differential Revision: D15298598

fbshipit-source-id: 4f0fe80ea98dea8af0c8289db4f6f4e4070af622
2019-05-30 07:14:32 -07:00
..
bookmark.rs Convert scm/mononoke/blobimport_lib to Rust 2018 2019-05-24 09:48:13 -07:00
changeset.rs Convert scm/mononoke/blobimport_lib to Rust 2018 2019-05-24 09:48:13 -07:00
lib.rs mononoke: support non-publishing / non-pull_default Bookmarks 2019-05-30 07:14:32 -07:00