mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
mononoke: Rename Bookmark to BookmarkName
Summary: As part of adding support for infinitepush in Mononoke, we'll include additional server-side metadata on Bookmarks (specifically, whether they are publishing and pull-default). However, we do use the name `Bookmark` right now to just reference a Bookmark name. This patch updates all reference to `Bookmark` to `BookmarkName` in order to free up `Bookmark`. Reviewed By: StanislavGlebik Differential Revision: D15364674 fbshipit-source-id: 126142e24e4361c19d1a6e20daa28bc793fb8686
This commit is contained in:
parent
39599a866d
commit
77ba80ebd8
@ -13,7 +13,7 @@ use std::{
|
||||
use blobrepo::{get_sha256_alias, get_sha256_alias_key, BlobRepo};
|
||||
use blobrepo_factory::open_blobrepo;
|
||||
use blobstore::Blobstore;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use bytes::Bytes;
|
||||
use cachelib::LruCachePool;
|
||||
use cloned::cloned;
|
||||
@ -133,7 +133,7 @@ impl MononokeRepo {
|
||||
.into_future()
|
||||
.from_err()
|
||||
.left_future(),
|
||||
Revision::Bookmark(bookmark) => Bookmark::new(bookmark)
|
||||
Revision::Bookmark(bookmark) => BookmarkName::new(bookmark)
|
||||
.into_future()
|
||||
.from_err()
|
||||
.and_then(move |bookmark| {
|
||||
|
@ -15,7 +15,7 @@ use futures_ext::{BoxFuture, FutureExt};
|
||||
use slog::Logger;
|
||||
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason};
|
||||
use context::CoreContext;
|
||||
use mercurial::RevlogRepo;
|
||||
use mercurial_types::HgChangesetId;
|
||||
@ -46,7 +46,7 @@ pub fn upload_bookmarks(
|
||||
revlogrepo: RevlogRepo,
|
||||
blobrepo: Arc<BlobRepo>,
|
||||
stale_bookmarks: Vec<(Vec<u8>, HgChangesetId)>,
|
||||
mononoke_bookmarks: Vec<(Bookmark, ChangesetId)>,
|
||||
mononoke_bookmarks: Vec<(BookmarkName, ChangesetId)>,
|
||||
) -> BoxFuture<(), Error> {
|
||||
let logger = logger.clone();
|
||||
let stale_bookmarks = Arc::new(stale_bookmarks.into_iter().collect::<HashMap<_, _>>());
|
||||
@ -116,7 +116,7 @@ pub fn upload_bookmarks(
|
||||
|
||||
let mut count = 0;
|
||||
for (key, value) in vec {
|
||||
let key = Bookmark::new_ascii(try_boxfuture!(AsciiString::from_ascii(key)));
|
||||
let key = BookmarkName::new_ascii(try_boxfuture!(AsciiString::from_ascii(key)));
|
||||
if mononoke_bookmarks.get(&key) != Some(&value) {
|
||||
count += 1;
|
||||
try_boxfuture!(transaction.force_set(&key, value, BookmarkUpdateReason::Blobimport))
|
||||
|
@ -20,7 +20,7 @@ use crate::{BlobManifest, HgBlobChangeset};
|
||||
use blob_changeset::{ChangesetMetadata, HgChangesetContent, RepoBlobstore};
|
||||
use blobstore::Blobstore;
|
||||
use bonsai_hg_mapping::{BonsaiHgMapping, BonsaiHgMappingEntry, BonsaiOrHgChangesetIds};
|
||||
use bookmarks::{self, Bookmark, BookmarkPrefix, BookmarkUpdateReason, Bookmarks};
|
||||
use bookmarks::{self, BookmarkName, BookmarkPrefix, BookmarkUpdateReason, Bookmarks};
|
||||
use bytes::Bytes;
|
||||
use cacheblob::{LeaseOps, MemWritesBlobstore};
|
||||
use changeset_fetcher::{ChangesetFetcher, SimpleChangesetFetcher};
|
||||
@ -626,7 +626,7 @@ impl BlobRepo {
|
||||
pub fn get_bookmark(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
name: &Bookmark,
|
||||
name: &BookmarkName,
|
||||
) -> BoxFuture<Option<HgChangesetId>, Error> {
|
||||
STATS::get_bookmark.add_value(1);
|
||||
self.bookmarks
|
||||
@ -647,7 +647,7 @@ impl BlobRepo {
|
||||
pub fn get_bonsai_bookmark(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
name: &Bookmark,
|
||||
name: &BookmarkName,
|
||||
) -> BoxFuture<Option<ChangesetId>, Error> {
|
||||
STATS::get_bookmark.add_value(1);
|
||||
self.bookmarks.get(ctx, name, self.repoid)
|
||||
@ -656,7 +656,7 @@ impl BlobRepo {
|
||||
pub fn list_bookmark_log_entries(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
max_rec: u32,
|
||||
) -> impl Stream<Item = (Option<ChangesetId>, BookmarkUpdateReason, Timestamp), Error = Error>
|
||||
{
|
||||
@ -669,7 +669,7 @@ impl BlobRepo {
|
||||
pub fn get_bookmarks_maybe_stale(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
) -> impl Stream<Item = (Bookmark, HgChangesetId), Error = Error> {
|
||||
) -> impl Stream<Item = (BookmarkName, HgChangesetId), Error = Error> {
|
||||
self.get_bookmarks_by_prefix_maybe_stale(ctx, &BookmarkPrefix::empty())
|
||||
}
|
||||
|
||||
@ -677,7 +677,7 @@ impl BlobRepo {
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
) -> impl Stream<Item = (Bookmark, HgChangesetId), Error = Error> {
|
||||
) -> impl Stream<Item = (BookmarkName, HgChangesetId), Error = Error> {
|
||||
STATS::get_bookmarks_maybe_stale.add_value(1);
|
||||
self.bookmarks
|
||||
.list_by_prefix_maybe_stale(ctx.clone(), prefix, self.repoid)
|
||||
@ -694,7 +694,7 @@ impl BlobRepo {
|
||||
pub fn get_bonsai_bookmarks_maybe_stale(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
STATS::get_bookmarks_maybe_stale.add_value(1);
|
||||
self.bookmarks
|
||||
.list_by_prefix_maybe_stale(ctx.clone(), &BookmarkPrefix::empty(), self.repoid)
|
||||
@ -704,7 +704,7 @@ impl BlobRepo {
|
||||
pub fn get_bonsai_bookmarks(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
STATS::get_bookmarks.add_value(1);
|
||||
self.bookmarks
|
||||
.list_by_prefix(ctx.clone(), &BookmarkPrefix::empty(), self.repoid)
|
||||
@ -719,7 +719,7 @@ impl BlobRepo {
|
||||
pub fn get_bonsai_heads(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
) -> impl Stream<Item = (Bookmark, ChangesetId), Error = Error> {
|
||||
) -> impl Stream<Item = (BookmarkName, ChangesetId), Error = Error> {
|
||||
self.get_bonsai_bookmarks(ctx)
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
use bookmarks::{
|
||||
Bookmark, BookmarkPrefix, BookmarkUpdateLogEntry, BookmarkUpdateReason, Bookmarks,
|
||||
BookmarkName, BookmarkPrefix, BookmarkUpdateLogEntry, BookmarkUpdateReason, Bookmarks,
|
||||
BundleReplayData, Transaction,
|
||||
};
|
||||
use context::CoreContext;
|
||||
@ -40,14 +40,14 @@ pub struct SqlBookmarks {
|
||||
|
||||
queries! {
|
||||
write ReplaceBookmarks(
|
||||
values: (repo_id: RepositoryId, name: Bookmark, changeset_id: ChangesetId)
|
||||
values: (repo_id: RepositoryId, name: BookmarkName, changeset_id: ChangesetId)
|
||||
) {
|
||||
none,
|
||||
"REPLACE INTO bookmarks (repo_id, name, changeset_id) VALUES {values}"
|
||||
}
|
||||
|
||||
write InsertBookmarks(
|
||||
values: (repo_id: RepositoryId, name: Bookmark, changeset_id: ChangesetId)
|
||||
values: (repo_id: RepositoryId, name: BookmarkName, changeset_id: ChangesetId)
|
||||
) {
|
||||
insert_or_ignore,
|
||||
"{insert_or_ignore} INTO bookmarks (repo_id, name, changeset_id) VALUES {values}"
|
||||
@ -55,7 +55,7 @@ queries! {
|
||||
|
||||
write UpdateBookmark(
|
||||
repo_id: RepositoryId,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
old_id: ChangesetId,
|
||||
new_id: ChangesetId,
|
||||
) {
|
||||
@ -67,14 +67,14 @@ queries! {
|
||||
AND changeset_id = {old_id}"
|
||||
}
|
||||
|
||||
write DeleteBookmark(repo_id: RepositoryId, name: Bookmark) {
|
||||
write DeleteBookmark(repo_id: RepositoryId, name: BookmarkName) {
|
||||
none,
|
||||
"DELETE FROM bookmarks
|
||||
WHERE repo_id = {repo_id}
|
||||
AND name = {name}"
|
||||
}
|
||||
|
||||
write DeleteBookmarkIf(repo_id: RepositoryId, name: Bookmark, changeset_id: ChangesetId) {
|
||||
write DeleteBookmarkIf(repo_id: RepositoryId, name: BookmarkName, changeset_id: ChangesetId) {
|
||||
none,
|
||||
"DELETE FROM bookmarks
|
||||
WHERE repo_id = {repo_id}
|
||||
@ -85,7 +85,7 @@ queries! {
|
||||
write AddBookmarkLog(
|
||||
values: (
|
||||
repo_id: RepositoryId,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
from_changeset_id: Option<ChangesetId>,
|
||||
to_changeset_id: Option<ChangesetId>,
|
||||
reason: BookmarkUpdateReason,
|
||||
@ -99,7 +99,7 @@ queries! {
|
||||
}
|
||||
|
||||
read ReadNextBookmarkLogEntries(min_id: u64, repo_id: RepositoryId, limit: u64) -> (
|
||||
i64, RepositoryId, Bookmark, Option<ChangesetId>, Option<ChangesetId>,
|
||||
i64, RepositoryId, BookmarkName, Option<ChangesetId>, Option<ChangesetId>,
|
||||
BookmarkUpdateReason, Timestamp, Option<String>, Option<String>
|
||||
) {
|
||||
"SELECT id, repo_id, name, to_changeset_id, from_changeset_id, reason, timestamp,
|
||||
@ -163,7 +163,7 @@ queries! {
|
||||
VALUES {values}"
|
||||
}
|
||||
|
||||
read SelectBookmark(repo_id: RepositoryId, name: Bookmark) -> (ChangesetId) {
|
||||
read SelectBookmark(repo_id: RepositoryId, name: BookmarkName) -> (ChangesetId) {
|
||||
"SELECT changeset_id
|
||||
FROM bookmarks
|
||||
WHERE repo_id = {repo_id}
|
||||
@ -171,7 +171,7 @@ queries! {
|
||||
LIMIT 1"
|
||||
}
|
||||
|
||||
read SelectBookmarkLogs(repo_id: RepositoryId, name: Bookmark, max_records: u32) -> (
|
||||
read SelectBookmarkLogs(repo_id: RepositoryId, name: BookmarkName, max_records: u32) -> (
|
||||
Option<ChangesetId>, BookmarkUpdateReason, Timestamp
|
||||
) {
|
||||
"SELECT to_changeset_id, reason, timestamp
|
||||
@ -182,13 +182,13 @@ queries! {
|
||||
LIMIT {max_records}"
|
||||
}
|
||||
|
||||
read SelectAll(repo_id: RepositoryId) -> (Bookmark, ChangesetId) {
|
||||
read SelectAll(repo_id: RepositoryId) -> (BookmarkName, ChangesetId) {
|
||||
"SELECT name, changeset_id
|
||||
FROM bookmarks
|
||||
WHERE repo_id = {repo_id}"
|
||||
}
|
||||
|
||||
read SelectByPrefix(repo_id: RepositoryId, prefix: BookmarkPrefix) -> (Bookmark, ChangesetId) {
|
||||
read SelectByPrefix(repo_id: RepositoryId, prefix: BookmarkPrefix) -> (BookmarkName, ChangesetId) {
|
||||
mysql(
|
||||
"SELECT name, changeset_id
|
||||
FROM bookmarks
|
||||
@ -230,7 +230,7 @@ impl SqlBookmarks {
|
||||
prefix: &BookmarkPrefix,
|
||||
repo_id: RepositoryId,
|
||||
conn: &Connection,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
if prefix.is_empty() {
|
||||
SelectAll::query(&conn, &repo_id)
|
||||
.map(|rows| stream::iter_ok(rows))
|
||||
@ -249,7 +249,7 @@ impl Bookmarks for SqlBookmarks {
|
||||
fn get(
|
||||
&self,
|
||||
_ctx: CoreContext,
|
||||
name: &Bookmark,
|
||||
name: &BookmarkName,
|
||||
repo_id: RepositoryId,
|
||||
) -> BoxFuture<Option<ChangesetId>, Error> {
|
||||
STATS::get_bookmark.add_value(1);
|
||||
@ -261,7 +261,7 @@ impl Bookmarks for SqlBookmarks {
|
||||
fn list_bookmark_log_entries(
|
||||
&self,
|
||||
_ctx: CoreContext,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
repo_id: RepositoryId,
|
||||
max_rec: u32,
|
||||
) -> BoxStream<(Option<ChangesetId>, BookmarkUpdateReason, Timestamp), Error> {
|
||||
@ -276,7 +276,7 @@ impl Bookmarks for SqlBookmarks {
|
||||
_ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
repo_id: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
STATS::list_by_prefix.add_value(1);
|
||||
self.list_by_prefix_impl(prefix, repo_id, &self.read_master_connection)
|
||||
}
|
||||
@ -286,7 +286,7 @@ impl Bookmarks for SqlBookmarks {
|
||||
_ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
repo_id: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
STATS::list_by_prefix_maybe_stale.add_value(1);
|
||||
self.list_by_prefix_impl(prefix, repo_id, &self.read_connection)
|
||||
}
|
||||
@ -373,12 +373,12 @@ impl Bookmarks for SqlBookmarks {
|
||||
// Note: types are explicit here to protect us from query behavior change
|
||||
// when tuple items 2 or 5 become something else, and we still succeed
|
||||
// compiling everything because of the type inference
|
||||
let first_name: &Bookmark = &first_entry.2;
|
||||
let first_name: &BookmarkName = &first_entry.2;
|
||||
let first_reason: &BookmarkUpdateReason = &first_entry.5;
|
||||
entries
|
||||
.into_iter()
|
||||
.take_while(|entry| {
|
||||
let name: &Bookmark = &entry.2;
|
||||
let name: &BookmarkName = &entry.2;
|
||||
let reason: &BookmarkUpdateReason = &entry.5;
|
||||
name == first_name && reason == first_reason
|
||||
})
|
||||
@ -461,11 +461,11 @@ impl Bookmarks for SqlBookmarks {
|
||||
struct SqlBookmarksTransaction {
|
||||
write_connection: Connection,
|
||||
repo_id: RepositoryId,
|
||||
force_sets: HashMap<Bookmark, (ChangesetId, BookmarkUpdateReason)>,
|
||||
creates: HashMap<Bookmark, (ChangesetId, BookmarkUpdateReason)>,
|
||||
sets: HashMap<Bookmark, (BookmarkSetData, BookmarkUpdateReason)>,
|
||||
force_deletes: HashMap<Bookmark, BookmarkUpdateReason>,
|
||||
deletes: HashMap<Bookmark, (ChangesetId, BookmarkUpdateReason)>,
|
||||
force_sets: HashMap<BookmarkName, (ChangesetId, BookmarkUpdateReason)>,
|
||||
creates: HashMap<BookmarkName, (ChangesetId, BookmarkUpdateReason)>,
|
||||
sets: HashMap<BookmarkName, (BookmarkSetData, BookmarkUpdateReason)>,
|
||||
force_deletes: HashMap<BookmarkName, BookmarkUpdateReason>,
|
||||
deletes: HashMap<BookmarkName, (ChangesetId, BookmarkUpdateReason)>,
|
||||
}
|
||||
|
||||
impl SqlBookmarksTransaction {
|
||||
@ -481,7 +481,7 @@ impl SqlBookmarksTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_if_bookmark_already_used(&self, key: &Bookmark) -> Result<()> {
|
||||
fn check_if_bookmark_already_used(&self, key: &BookmarkName) -> Result<()> {
|
||||
if self.creates.contains_key(key)
|
||||
|| self.force_sets.contains_key(key)
|
||||
|| self.sets.contains_key(key)
|
||||
@ -530,7 +530,7 @@ impl SqlBookmarksTransaction {
|
||||
repo_id: RepositoryId,
|
||||
timestamp: Timestamp,
|
||||
moves: HashMap<
|
||||
Bookmark,
|
||||
BookmarkName,
|
||||
(
|
||||
Option<ChangesetId>,
|
||||
Option<ChangesetId>,
|
||||
@ -575,7 +575,7 @@ impl SqlBookmarksTransaction {
|
||||
impl Transaction for SqlBookmarksTransaction {
|
||||
fn update(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
old_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
@ -588,7 +588,7 @@ impl Transaction for SqlBookmarksTransaction {
|
||||
|
||||
fn create(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -599,7 +599,7 @@ impl Transaction for SqlBookmarksTransaction {
|
||||
|
||||
fn force_set(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -610,7 +610,7 @@ impl Transaction for SqlBookmarksTransaction {
|
||||
|
||||
fn delete(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
old_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -619,7 +619,7 @@ impl Transaction for SqlBookmarksTransaction {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn force_delete(&mut self, key: &Bookmark, reason: BookmarkUpdateReason) -> Result<()> {
|
||||
fn force_delete(&mut self, key: &BookmarkName, reason: BookmarkUpdateReason) -> Result<()> {
|
||||
self.check_if_bookmark_already_used(key)?;
|
||||
self.force_deletes.insert(key.clone(), reason);
|
||||
Ok(())
|
||||
|
@ -9,7 +9,7 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
use bookmarks::{
|
||||
Bookmark, BookmarkPrefix, BookmarkUpdateLogEntry, BookmarkUpdateReason, Bookmarks,
|
||||
BookmarkName, BookmarkPrefix, BookmarkUpdateLogEntry, BookmarkUpdateReason, Bookmarks,
|
||||
BundleReplayData,
|
||||
};
|
||||
use context::CoreContext;
|
||||
@ -24,8 +24,8 @@ use mononoke_types_mocks::changesetid::{
|
||||
use mononoke_types_mocks::repo::{REPO_ONE, REPO_TWO, REPO_ZERO};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
fn create_bookmark(book: &str) -> Bookmark {
|
||||
Bookmark::new(book.to_string()).unwrap()
|
||||
fn create_bookmark_name(book: &str) -> BookmarkName {
|
||||
BookmarkName::new(book.to_string()).unwrap()
|
||||
}
|
||||
|
||||
fn create_prefix(book: &str) -> BookmarkPrefix {
|
||||
@ -53,8 +53,8 @@ fn compare_log_entries(
|
||||
fn test_simple_unconditional_set_get() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_correct = create_bookmark("book");
|
||||
let name_incorrect = create_bookmark("book2");
|
||||
let name_correct = create_bookmark_name("book");
|
||||
let name_incorrect = create_bookmark_name("book2");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
@ -106,8 +106,8 @@ fn test_simple_unconditional_set_get() {
|
||||
fn test_multi_unconditional_set_get() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_2 = create_bookmark("book2");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
let name_2 = create_bookmark_name("book2");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
@ -149,7 +149,7 @@ fn test_multi_unconditional_set_get() {
|
||||
fn test_unconditional_set_same_bookmark() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
@ -186,7 +186,7 @@ fn test_unconditional_set_same_bookmark() {
|
||||
fn test_simple_create() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -231,7 +231,7 @@ fn test_simple_create() {
|
||||
fn test_create_already_existing() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -260,7 +260,7 @@ fn test_create_already_existing() {
|
||||
fn test_create_change_same_bookmark() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -423,7 +423,7 @@ fn test_create_change_same_bookmark() {
|
||||
fn test_simple_update_bookmark() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -480,7 +480,7 @@ fn test_simple_update_bookmark() {
|
||||
fn test_noop_update() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -518,7 +518,7 @@ fn test_noop_update() {
|
||||
fn test_update_non_existent_bookmark() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.update(
|
||||
@ -537,7 +537,7 @@ fn test_update_non_existent_bookmark() {
|
||||
fn test_update_existing_bookmark_with_incorrect_commit() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -567,7 +567,7 @@ fn test_update_existing_bookmark_with_incorrect_commit() {
|
||||
fn test_force_delete() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_delete(
|
||||
@ -645,7 +645,7 @@ fn test_force_delete() {
|
||||
fn test_delete() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.delete(
|
||||
@ -709,7 +709,7 @@ fn test_delete() {
|
||||
fn test_delete_incorrect_hash() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -743,8 +743,8 @@ fn test_delete_incorrect_hash() {
|
||||
fn test_list_by_prefix() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book1");
|
||||
let name_2 = create_bookmark("book2");
|
||||
let name_1 = create_bookmark_name("book1");
|
||||
let name_2 = create_bookmark_name("book2");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.create(
|
||||
@ -801,7 +801,7 @@ fn test_list_by_prefix() {
|
||||
fn test_create_different_repos() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
@ -901,8 +901,8 @@ fn fetch_single(bookmarks: &SqlBookmarks, id: u64) -> BookmarkUpdateLogEntry {
|
||||
fn test_log_correct_order() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_2 = create_bookmark("book2");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
let name_2 = create_bookmark_name("book2");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
@ -1074,7 +1074,7 @@ fn test_log_correct_order() {
|
||||
fn test_log_bundle_replay_data() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
let timestamp = Timestamp::now();
|
||||
let expected = BundleReplayData {
|
||||
bundle_handle: "handle".to_string(),
|
||||
@ -1108,7 +1108,7 @@ fn test_log_bundle_replay_data() {
|
||||
fn test_read_log_entry_many_repos() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
@ -1177,7 +1177,7 @@ fn test_read_log_entry_many_repos() {
|
||||
fn test_list_bookmark_log_entries() {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let bookmarks = SqlBookmarks::with_sqlite_in_memory().unwrap();
|
||||
let name_1 = create_bookmark("book");
|
||||
let name_1 = create_bookmark_name("book");
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx.clone(), REPO_ZERO);
|
||||
txn.force_set(
|
||||
|
@ -5,7 +5,8 @@
|
||||
// GNU General Public License version 2 or any later version.
|
||||
|
||||
use crate::{
|
||||
Bookmark, BookmarkPrefix, BookmarkUpdateLogEntry, BookmarkUpdateReason, Bookmarks, Transaction,
|
||||
BookmarkName, BookmarkPrefix, BookmarkUpdateLogEntry, BookmarkUpdateReason, Bookmarks,
|
||||
Transaction,
|
||||
};
|
||||
use context::CoreContext;
|
||||
use failure::{err_msg, Error};
|
||||
@ -23,7 +24,7 @@ use std::{
|
||||
struct Cache {
|
||||
expires: Instant,
|
||||
maybe_stale: bool,
|
||||
current: future::Shared<BoxFuture<BTreeMap<Bookmark, ChangesetId>, Error>>,
|
||||
current: future::Shared<BoxFuture<BTreeMap<BookmarkName, ChangesetId>, Error>>,
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
@ -168,7 +169,7 @@ impl Bookmarks for CachedBookmarks {
|
||||
ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
repoid: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
let range = prefix.to_range();
|
||||
let cache = self.get_cache(ctx, repoid);
|
||||
cache
|
||||
@ -197,7 +198,7 @@ impl Bookmarks for CachedBookmarks {
|
||||
fn get(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
repoid: RepositoryId,
|
||||
) -> BoxFuture<Option<ChangesetId>, Error> {
|
||||
self.bookmarks.get(ctx, bookmark, repoid)
|
||||
@ -208,7 +209,7 @@ impl Bookmarks for CachedBookmarks {
|
||||
ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
repoid: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
self.bookmarks.list_by_prefix(ctx, prefix, repoid)
|
||||
}
|
||||
|
||||
@ -237,7 +238,7 @@ impl Bookmarks for CachedBookmarks {
|
||||
fn list_bookmark_log_entries(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
repoid: RepositoryId,
|
||||
max_rec: u32,
|
||||
) -> BoxStream<(Option<ChangesetId>, BookmarkUpdateReason, Timestamp), Error> {
|
||||
@ -281,7 +282,7 @@ impl Bookmarks for CachedBookmarks {
|
||||
impl Transaction for CachedBookmarksTransaction {
|
||||
fn update(
|
||||
&mut self,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
old_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
@ -291,7 +292,7 @@ impl Transaction for CachedBookmarksTransaction {
|
||||
|
||||
fn create(
|
||||
&mut self,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -300,7 +301,7 @@ impl Transaction for CachedBookmarksTransaction {
|
||||
|
||||
fn force_set(
|
||||
&mut self,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -309,14 +310,18 @@ impl Transaction for CachedBookmarksTransaction {
|
||||
|
||||
fn delete(
|
||||
&mut self,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
old_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
self.transaction.delete(bookmark, old_cs, reason)
|
||||
}
|
||||
|
||||
fn force_delete(&mut self, bookmark: &Bookmark, reason: BookmarkUpdateReason) -> Result<()> {
|
||||
fn force_delete(
|
||||
&mut self,
|
||||
bookmark: &BookmarkName,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
self.transaction.force_delete(bookmark, reason)
|
||||
}
|
||||
|
||||
@ -373,8 +378,8 @@ mod tests {
|
||||
}
|
||||
|
||||
enum Request {
|
||||
ListReplica(Sender<Result<HashMap<Bookmark, ChangesetId>>>),
|
||||
ListMaster(Sender<Result<HashMap<Bookmark, ChangesetId>>>),
|
||||
ListReplica(Sender<Result<HashMap<BookmarkName, ChangesetId>>>),
|
||||
ListMaster(Sender<Result<HashMap<BookmarkName, ChangesetId>>>),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -394,7 +399,7 @@ mod tests {
|
||||
fn get(
|
||||
&self,
|
||||
_ctx: CoreContext,
|
||||
_name: &Bookmark,
|
||||
_name: &BookmarkName,
|
||||
_repoid: RepositoryId,
|
||||
) -> BoxFuture<Option<ChangesetId>, Error> {
|
||||
unimplemented!()
|
||||
@ -405,7 +410,7 @@ mod tests {
|
||||
_ctx: CoreContext,
|
||||
_prefix: &BookmarkPrefix,
|
||||
_repoid: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
let (send, recv) = channel();
|
||||
self.requests.with(|rs| rs.push(Request::ListMaster(send)));
|
||||
recv.map_err(Error::from)
|
||||
@ -420,7 +425,7 @@ mod tests {
|
||||
_ctx: CoreContext,
|
||||
_prefix: &BookmarkPrefix,
|
||||
_repoid: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error> {
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error> {
|
||||
let (send, recv) = channel();
|
||||
self.requests.with(|rs| rs.push(Request::ListReplica(send)));
|
||||
recv.map_err(Error::from)
|
||||
@ -461,7 +466,7 @@ mod tests {
|
||||
fn list_bookmark_log_entries(
|
||||
&self,
|
||||
_ctx: CoreContext,
|
||||
_name: Bookmark,
|
||||
_name: BookmarkName,
|
||||
_repo_id: RepositoryId,
|
||||
_max_rec: u32,
|
||||
) -> BoxStream<(Option<ChangesetId>, BookmarkUpdateReason, Timestamp), Error> {
|
||||
@ -503,7 +508,7 @@ mod tests {
|
||||
impl Transaction for MockTransaction {
|
||||
fn update(
|
||||
&mut self,
|
||||
_key: &Bookmark,
|
||||
_key: &BookmarkName,
|
||||
_new_cs: ChangesetId,
|
||||
_old_cs: ChangesetId,
|
||||
_reason: BookmarkUpdateReason,
|
||||
@ -513,7 +518,7 @@ mod tests {
|
||||
|
||||
fn create(
|
||||
&mut self,
|
||||
_key: &Bookmark,
|
||||
_key: &BookmarkName,
|
||||
_new_cs: ChangesetId,
|
||||
_reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -522,7 +527,7 @@ mod tests {
|
||||
|
||||
fn force_set(
|
||||
&mut self,
|
||||
_key: &Bookmark,
|
||||
_key: &BookmarkName,
|
||||
_new_cs: ChangesetId,
|
||||
_reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
@ -531,14 +536,18 @@ mod tests {
|
||||
|
||||
fn delete(
|
||||
&mut self,
|
||||
_key: &Bookmark,
|
||||
_key: &BookmarkName,
|
||||
_old_cs: ChangesetId,
|
||||
_reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn force_delete(&mut self, _key: &Bookmark, _reason: BookmarkUpdateReason) -> Result<()> {
|
||||
fn force_delete(
|
||||
&mut self,
|
||||
_key: &BookmarkName,
|
||||
_reason: BookmarkUpdateReason,
|
||||
) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -588,9 +597,9 @@ mod tests {
|
||||
};
|
||||
sender
|
||||
.send(Ok(hashmap! {
|
||||
Bookmark::new("a0").unwrap() => ONES_CSID,
|
||||
Bookmark::new("b0").unwrap() => TWOS_CSID,
|
||||
Bookmark::new("b1").unwrap() => THREES_CSID,
|
||||
BookmarkName::new("a0").unwrap() => ONES_CSID,
|
||||
BookmarkName::new("b0").unwrap() => TWOS_CSID,
|
||||
BookmarkName::new("b1").unwrap() => THREES_CSID,
|
||||
}))
|
||||
.unwrap();
|
||||
sleep();
|
||||
@ -598,10 +607,10 @@ mod tests {
|
||||
assert_eq!(
|
||||
log.with(|log| log.drain().collect::<HashMap<_, _>>()),
|
||||
hashmap! {
|
||||
0 => vec![(Bookmark::new("a0").unwrap(), ONES_CSID)],
|
||||
0 => vec![(BookmarkName::new("a0").unwrap(), ONES_CSID)],
|
||||
1 => vec![
|
||||
(Bookmark::new("b0").unwrap(), TWOS_CSID),
|
||||
(Bookmark::new("b1").unwrap(), THREES_CSID),
|
||||
(BookmarkName::new("b0").unwrap(), TWOS_CSID),
|
||||
(BookmarkName::new("b1").unwrap(), THREES_CSID),
|
||||
],
|
||||
},
|
||||
);
|
||||
@ -634,8 +643,8 @@ mod tests {
|
||||
};
|
||||
sender
|
||||
.send(Ok(hashmap! {
|
||||
Bookmark::new("a").unwrap() => ONES_CSID,
|
||||
Bookmark::new("b").unwrap() => TWOS_CSID,
|
||||
BookmarkName::new("a").unwrap() => ONES_CSID,
|
||||
BookmarkName::new("b").unwrap() => TWOS_CSID,
|
||||
}))
|
||||
.unwrap();
|
||||
sleep();
|
||||
@ -643,7 +652,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
log.with(|log| log.drain().collect::<HashMap<_, _>>()),
|
||||
hashmap! {
|
||||
0 => vec![(Bookmark::new("a").unwrap(), ONES_CSID)],
|
||||
0 => vec![(BookmarkName::new("a").unwrap(), ONES_CSID)],
|
||||
},
|
||||
);
|
||||
assert_eq!(mock.requests.with(|rs| rs.len()), 0);
|
||||
@ -655,7 +664,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
log.with(|log| log.drain().collect::<HashMap<_, _>>()),
|
||||
hashmap! {
|
||||
1 => vec![(Bookmark::new("b").unwrap(), TWOS_CSID)],
|
||||
1 => vec![(BookmarkName::new("b").unwrap(), TWOS_CSID)],
|
||||
},
|
||||
);
|
||||
assert_eq!(mock.requests.with(|rs| rs.len()), 0);
|
||||
@ -671,7 +680,7 @@ mod tests {
|
||||
};
|
||||
sender
|
||||
.send(Ok(hashmap! {
|
||||
Bookmark::new("b").unwrap() => THREES_CSID,
|
||||
BookmarkName::new("b").unwrap() => THREES_CSID,
|
||||
}))
|
||||
.unwrap();
|
||||
sleep();
|
||||
@ -679,7 +688,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
log.with(|log| log.drain().collect::<HashMap<_, _>>()),
|
||||
hashmap! {
|
||||
1 => vec![(Bookmark::new("b").unwrap(), THREES_CSID)],
|
||||
1 => vec![(BookmarkName::new("b").unwrap(), THREES_CSID)],
|
||||
},
|
||||
);
|
||||
assert_eq!(mock.requests.with(|rs| rs.len()), 0);
|
||||
|
@ -28,17 +28,17 @@ pub use cache::CachedBookmarks;
|
||||
type FromValueResult<T> = ::std::result::Result<T, FromValueError>;
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)]
|
||||
pub struct Bookmark {
|
||||
pub struct BookmarkName {
|
||||
bookmark: AsciiString,
|
||||
}
|
||||
|
||||
impl fmt::Display for Bookmark {
|
||||
impl fmt::Display for BookmarkName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.bookmark)
|
||||
}
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
impl BookmarkName {
|
||||
pub fn new<B: AsRef<str>>(bookmark: B) -> Result<Self> {
|
||||
Ok(Self {
|
||||
bookmark: AsciiString::from_ascii(bookmark.as_ref())
|
||||
@ -59,7 +59,7 @@ impl Bookmark {
|
||||
}
|
||||
}
|
||||
|
||||
impl Weight for Bookmark {
|
||||
impl Weight for BookmarkName {
|
||||
#[inline]
|
||||
fn get_weight(&self) -> usize {
|
||||
mem::size_of::<Self>() + self.bookmark.len()
|
||||
@ -107,12 +107,12 @@ impl BookmarkPrefix {
|
||||
self.bookmark_prefix.is_empty()
|
||||
}
|
||||
|
||||
pub fn to_range(&self) -> Range<Bookmark> {
|
||||
pub fn to_range(&self) -> Range<BookmarkName> {
|
||||
let mut end_ascii = self.bookmark_prefix.clone();
|
||||
end_ascii.push(AsciiChar::DEL); // DEL is the maximum ascii character
|
||||
Range {
|
||||
start: Bookmark::new_ascii(self.bookmark_prefix.clone()),
|
||||
end: Bookmark::new_ascii(end_ascii),
|
||||
start: BookmarkName::new_ascii(self.bookmark_prefix.clone()),
|
||||
end: BookmarkName::new_ascii(end_ascii),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ pub struct BookmarkUpdateLogEntry {
|
||||
/// Id of a repo
|
||||
pub repo_id: RepositoryId,
|
||||
/// Name of the bookmark
|
||||
pub bookmark_name: Bookmark,
|
||||
pub bookmark_name: BookmarkName,
|
||||
/// Previous position of bookmark if it's known. It might not be known if a bookmark was
|
||||
/// force set or if a bookmark didn't exist
|
||||
pub to_changeset_id: Option<ChangesetId>,
|
||||
@ -143,7 +143,7 @@ pub trait Bookmarks: Send + Sync + 'static {
|
||||
fn get(
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
name: &Bookmark,
|
||||
name: &BookmarkName,
|
||||
repoid: RepositoryId,
|
||||
) -> BoxFuture<Option<ChangesetId>, Error>;
|
||||
|
||||
@ -156,7 +156,7 @@ pub trait Bookmarks: Send + Sync + 'static {
|
||||
ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
repoid: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error>;
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error>;
|
||||
|
||||
/// Lists the bookmarks that match the prefix with bookmark's values but the bookmarks may not
|
||||
/// be the most up-to-date i.e. they may be read from a replica that's behind master.
|
||||
@ -169,7 +169,7 @@ pub trait Bookmarks: Send + Sync + 'static {
|
||||
ctx: CoreContext,
|
||||
prefix: &BookmarkPrefix,
|
||||
repoid: RepositoryId,
|
||||
) -> BoxStream<(Bookmark, ChangesetId), Error>;
|
||||
) -> BoxStream<(BookmarkName, ChangesetId), Error>;
|
||||
|
||||
/// Creates a transaction that will be used for write operations.
|
||||
fn create_transaction(&self, ctx: CoreContext, repoid: RepositoryId) -> Box<dyn Transaction>;
|
||||
@ -199,7 +199,7 @@ pub trait Bookmarks: Send + Sync + 'static {
|
||||
fn list_bookmark_log_entries(
|
||||
&self,
|
||||
_ctx: CoreContext,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
repo_id: RepositoryId,
|
||||
max_rec: u32,
|
||||
) -> BoxStream<(Option<ChangesetId>, BookmarkUpdateReason, Timestamp), Error>;
|
||||
@ -374,18 +374,18 @@ pub trait Transaction: Send + Sync + 'static {
|
||||
/// committing the transaction will fail.
|
||||
fn update(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
old_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()>;
|
||||
|
||||
/// Adds create() operation to the transaction set.
|
||||
/// Creates a bookmark. Bookmark should not already exist, otherwise committing the
|
||||
/// Creates a bookmark. BookmarkName should not already exist, otherwise committing the
|
||||
/// transaction will fail.
|
||||
fn create(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()>;
|
||||
@ -395,7 +395,7 @@ pub trait Transaction: Send + Sync + 'static {
|
||||
/// exists or not.
|
||||
fn force_set(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
new_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()>;
|
||||
@ -404,14 +404,14 @@ pub trait Transaction: Send + Sync + 'static {
|
||||
/// Deletes bookmark only if it currently points to `old_cs`.
|
||||
fn delete(
|
||||
&mut self,
|
||||
key: &Bookmark,
|
||||
key: &BookmarkName,
|
||||
old_cs: ChangesetId,
|
||||
reason: BookmarkUpdateReason,
|
||||
) -> Result<()>;
|
||||
|
||||
/// Adds force_delete operation to the transaction set.
|
||||
/// Deletes bookmark unconditionally.
|
||||
fn force_delete(&mut self, key: &Bookmark, reason: BookmarkUpdateReason) -> Result<()>;
|
||||
fn force_delete(&mut self, key: &BookmarkName, reason: BookmarkUpdateReason) -> Result<()>;
|
||||
|
||||
/// Commits the transaction. Future succeeds if transaction has been
|
||||
/// successful, or errors if transaction has failed. Logical failure is indicated by
|
||||
@ -419,23 +419,23 @@ pub trait Transaction: Send + Sync + 'static {
|
||||
fn commit(self: Box<Self>) -> BoxFuture<bool, Error>;
|
||||
}
|
||||
|
||||
impl From<Bookmark> for Value {
|
||||
fn from(bookmark: Bookmark) -> Self {
|
||||
impl From<BookmarkName> for Value {
|
||||
fn from(bookmark: BookmarkName) -> Self {
|
||||
Value::Bytes(bookmark.bookmark.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl ConvIr<Bookmark> for Bookmark {
|
||||
impl ConvIr<BookmarkName> for BookmarkName {
|
||||
fn new(v: Value) -> FromValueResult<Self> {
|
||||
match v {
|
||||
Value::Bytes(bytes) => AsciiString::from_ascii(bytes)
|
||||
.map_err(|err| FromValueError(Value::Bytes(err.into_source())))
|
||||
.map(Bookmark::new_ascii),
|
||||
.map(BookmarkName::new_ascii),
|
||||
v => Err(FromValueError(v)),
|
||||
}
|
||||
}
|
||||
|
||||
fn commit(self) -> Bookmark {
|
||||
fn commit(self) -> BookmarkName {
|
||||
self
|
||||
}
|
||||
|
||||
@ -444,8 +444,8 @@ impl ConvIr<Bookmark> for Bookmark {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromValue for Bookmark {
|
||||
type Intermediate = Bookmark;
|
||||
impl FromValue for BookmarkName {
|
||||
type Intermediate = BookmarkName;
|
||||
}
|
||||
|
||||
impl From<BookmarkPrefix> for Value {
|
||||
|
@ -44,7 +44,7 @@
|
||||
/// Note: Usually rebased set == pushed set. However in case of merges it may differ
|
||||
use blobrepo::{save_bonsai_changesets, BlobRepo};
|
||||
use bonsai_utils::{bonsai_diff, BonsaiDiffResult};
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason, BundleReplayData};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason, BundleReplayData};
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
use failure::{Error, Fail};
|
||||
@ -72,14 +72,14 @@ pub enum ErrorKind {
|
||||
#[fail(display = "Bonsai not found for hg changeset: {:?}", _0)]
|
||||
BonsaiNotFoundForHgChangeset(HgChangesetId),
|
||||
#[fail(display = "Pushrebase onto bookmark not found: {:?}", _0)]
|
||||
PushrebaseBookmarkNotFound(Bookmark),
|
||||
PushrebaseBookmarkNotFound(BookmarkName),
|
||||
#[fail(display = "Only one head is allowed in pushed set")]
|
||||
PushrebaseTooManyHeads,
|
||||
#[fail(
|
||||
display = "Error while uploading data for changesets, hashes: {:?}",
|
||||
_0
|
||||
)]
|
||||
PushrebaseNoCommonRoot(Bookmark, HashSet<ChangesetId>),
|
||||
PushrebaseNoCommonRoot(BookmarkName, HashSet<ChangesetId>),
|
||||
#[fail(display = "Internal error: root changeset {} not found", _0)]
|
||||
RootNotFound(ChangesetId),
|
||||
#[fail(display = "No pushrebase roots found")]
|
||||
@ -90,7 +90,7 @@ pub enum ErrorKind {
|
||||
display = "Forbid pushrebase because root ({}) is not a p1 of {} bookmark",
|
||||
_0, _1
|
||||
)]
|
||||
P2RootRebaseForbidden(HgChangesetId, Bookmark),
|
||||
P2RootRebaseForbidden(HgChangesetId, BookmarkName),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -150,7 +150,7 @@ pub struct PushrebaseSuccessResult {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct OntoBookmarkParams {
|
||||
pub bookmark: Bookmark,
|
||||
pub bookmark: BookmarkName,
|
||||
}
|
||||
|
||||
/// Does a pushrebase of a list of commits `pushed_set` onto `onto_bookmark`
|
||||
@ -306,7 +306,7 @@ fn do_rebase(
|
||||
root: ChangesetId,
|
||||
head: ChangesetId,
|
||||
bookmark_val: Option<ChangesetId>,
|
||||
onto_bookmark: Bookmark,
|
||||
onto_bookmark: BookmarkName,
|
||||
maybe_raw_bundle2_id: Option<RawBundle2Id>,
|
||||
) -> impl Future<Item = Option<(ChangesetId, Vec<PushrebaseChangesetPair>)>, Error = PushrebaseError>
|
||||
{
|
||||
@ -441,7 +441,7 @@ fn find_closest_ancestor_root(
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
config: PushrebaseParams,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
roots: HashMap<ChangesetId, ChildIndex>,
|
||||
onto_bookmark_cs_id: ChangesetId,
|
||||
) -> BoxFuture<ChangesetId, PushrebaseError> {
|
||||
@ -719,7 +719,7 @@ fn get_onto_bookmark_value(
|
||||
fn get_bookmark_value(
|
||||
ctx: CoreContext,
|
||||
repo: &BlobRepo,
|
||||
bookmark_name: &Bookmark,
|
||||
bookmark_name: &BookmarkName,
|
||||
) -> impl Future<Item = Option<ChangesetId>, Error = PushrebaseError> {
|
||||
repo.get_bonsai_bookmark(ctx, bookmark_name).from_err()
|
||||
}
|
||||
@ -857,7 +857,7 @@ fn find_rebased_set(
|
||||
fn try_update_bookmark(
|
||||
ctx: CoreContext,
|
||||
repo: &BlobRepo,
|
||||
bookmark_name: &Bookmark,
|
||||
bookmark_name: &BookmarkName,
|
||||
old_value: ChangesetId,
|
||||
new_value: ChangesetId,
|
||||
maybe_raw_bundle2_id: Option<RawBundle2Id>,
|
||||
@ -894,7 +894,7 @@ fn try_update_bookmark(
|
||||
fn try_create_bookmark(
|
||||
ctx: CoreContext,
|
||||
repo: &BlobRepo,
|
||||
bookmark_name: &Bookmark,
|
||||
bookmark_name: &BookmarkName,
|
||||
new_value: ChangesetId,
|
||||
maybe_raw_bundle2_id: Option<RawBundle2Id>,
|
||||
rebased_changesets: RebasedChangesets,
|
||||
@ -977,7 +977,7 @@ mod tests {
|
||||
use std::str::FromStr;
|
||||
use tests_utils::{create_commit, create_commit_with_date, store_files, store_rename};
|
||||
|
||||
fn set_bookmark(ctx: CoreContext, repo: BlobRepo, book: &Bookmark, cs_id: &str) {
|
||||
fn set_bookmark(ctx: CoreContext, repo: BlobRepo, book: &BookmarkName, cs_id: &str) {
|
||||
let head = HgChangesetId::from_str(cs_id).unwrap();
|
||||
let head = repo
|
||||
.get_bonsai_from_hg(ctx.clone(), head)
|
||||
@ -1002,7 +1002,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn master_bookmark() -> OntoBookmarkParams {
|
||||
let book = Bookmark::new("master").unwrap();
|
||||
let book = BookmarkName::new("master").unwrap();
|
||||
let book = OntoBookmarkParams { bookmark: book };
|
||||
book
|
||||
}
|
||||
@ -1925,7 +1925,7 @@ mod tests {
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
ancestor: HgChangesetId,
|
||||
descendant: Bookmark,
|
||||
descendant: BookmarkName,
|
||||
) -> impl Future<Item = usize, Error = Error> {
|
||||
let ancestor = repo
|
||||
.get_bonsai_from_hg(ctx.clone(), ancestor)
|
||||
@ -2065,7 +2065,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let book = Bookmark::new("newbook").unwrap();
|
||||
let book = BookmarkName::new("newbook").unwrap();
|
||||
let book = OntoBookmarkParams { bookmark: book };
|
||||
assert!(run_future(
|
||||
&mut runtime,
|
||||
@ -2088,7 +2088,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let parents = vec![p];
|
||||
|
||||
let book = Bookmark::new("newbook").unwrap();
|
||||
let book = BookmarkName::new("newbook").unwrap();
|
||||
let book = OntoBookmarkParams { bookmark: book };
|
||||
|
||||
let num_pushes = 10;
|
||||
|
@ -8,7 +8,7 @@ use std::collections::HashSet;
|
||||
|
||||
pub use failure_ext::{prelude::*, Fail};
|
||||
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use mercurial_types::HgChangesetId;
|
||||
use mononoke_types::ChangesetId;
|
||||
|
||||
@ -19,7 +19,7 @@ pub enum ErrorKind {
|
||||
#[fail(display = "Malformed treemanifest part: {}", _0)]
|
||||
MalformedTreemanifestPart(String),
|
||||
#[fail(display = "Pushrebase onto bookmark not found: {:?}", _0)]
|
||||
PushrebaseBookmarkNotFound(Bookmark),
|
||||
PushrebaseBookmarkNotFound(BookmarkName),
|
||||
#[fail(display = "Only one head is allowed in pushed set")]
|
||||
PushrebaseTooManyHeads,
|
||||
#[fail(
|
||||
@ -31,7 +31,7 @@ pub enum ErrorKind {
|
||||
display = "No common root found between: bookmark:{:?} roots:{:?}",
|
||||
_0, _1
|
||||
)]
|
||||
PushrebaseNoCommonRoot(Bookmark, HashSet<ChangesetId>),
|
||||
PushrebaseNoCommonRoot(BookmarkName, HashSet<ChangesetId>),
|
||||
#[fail(display = "Repo is marked as read-only: {}", _0)]
|
||||
RepoReadOnly(String),
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use ascii::AsciiString;
|
||||
use blobrepo::{
|
||||
BlobRepo, ChangesetHandle, ChangesetMetadata, ContentBlobInfo, CreateChangeset, HgBlobEntry,
|
||||
};
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason, BundleReplayData, Transaction};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason, BundleReplayData, Transaction};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
@ -300,7 +300,7 @@ fn resolve_pushrebase(
|
||||
Some(onto_bookmark) => {
|
||||
let v = Vec::from(onto_bookmark.as_ref());
|
||||
let onto_bookmark = String::from_utf8(v)?;
|
||||
let onto_bookmark = Bookmark::new(onto_bookmark)?;
|
||||
let onto_bookmark = BookmarkName::new(onto_bookmark)?;
|
||||
let onto_bookmark = pushrebase::OntoBookmarkParams {
|
||||
bookmark: onto_bookmark,
|
||||
};
|
||||
@ -536,13 +536,13 @@ enum Pushkey {
|
||||
#[derive(Debug)]
|
||||
struct BookmarkPush {
|
||||
part_id: PartId,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
old: Option<HgChangesetId>,
|
||||
new: Option<HgChangesetId>,
|
||||
}
|
||||
|
||||
struct BonsaiBookmarkPush {
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
old: Option<ChangesetId>,
|
||||
new: Option<ChangesetId>,
|
||||
}
|
||||
@ -868,7 +868,7 @@ impl Bundle2Resolver {
|
||||
let part_id = header.part_id();
|
||||
let mparams = header.mparams();
|
||||
let name = try_boxfuture!(get_ascii_param(mparams, "key"));
|
||||
let name = Bookmark::new_ascii(name);
|
||||
let name = BookmarkName::new_ascii(name);
|
||||
let old = try_boxfuture!(get_optional_changeset_param(mparams, "old"));
|
||||
let new = try_boxfuture!(get_optional_changeset_param(mparams, "new"));
|
||||
|
||||
@ -1180,7 +1180,7 @@ impl Bundle2Resolver {
|
||||
commonheads: CommonHeads,
|
||||
pushrebased_rev: ChangesetId,
|
||||
pushrebased_changesets: Vec<pushrebase::PushrebaseChangesetPair>,
|
||||
onto: Bookmark,
|
||||
onto: BookmarkName,
|
||||
lca_hint: Arc<dyn LeastCommonAncestorsHint>,
|
||||
phases: Arc<dyn Phases>,
|
||||
bookmark_push_part_id: Option<PartId>,
|
||||
@ -1403,7 +1403,7 @@ impl Bundle2Resolver {
|
||||
ctx: CoreContext,
|
||||
changesets: Changesets,
|
||||
pushvars: Option<HashMap<String, Bytes>>,
|
||||
onto_bookmark: &Bookmark,
|
||||
onto_bookmark: &BookmarkName,
|
||||
) -> BoxFuture<(), RunHooksError> {
|
||||
// TODO: should we also accept the Option<BookmarkPush> and run hooks on that?
|
||||
let mut futs = stream::FuturesUnordered::new();
|
||||
|
@ -19,7 +19,7 @@ extern crate metaconfig_types;
|
||||
extern crate revset;
|
||||
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use context::CoreContext;
|
||||
use futures::{Future, IntoFuture, Stream};
|
||||
use futures_ext::{spawn_future, BoxFuture, FutureExt};
|
||||
@ -31,13 +31,13 @@ use revset::AncestorsNodeStream;
|
||||
use slog::Logger;
|
||||
|
||||
mod errors {
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use mercurial_types::HgChangesetId;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum ErrorKind {
|
||||
#[fail(display = "Bookmark {} does not exist", _0)]
|
||||
BookmarkNotFound(Bookmark),
|
||||
BookmarkNotFound(BookmarkName),
|
||||
#[fail(display = "Bookmark value {} not found", _0)]
|
||||
BookmarkValueNotFound(HgChangesetId),
|
||||
}
|
||||
@ -125,7 +125,7 @@ fn changesets_warmup(
|
||||
fn do_cache_warmup(
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
commit_limit: usize,
|
||||
logger: Logger,
|
||||
) -> BoxFuture<(), Error> {
|
||||
|
@ -16,7 +16,7 @@ use serde_json::{json, to_string_pretty};
|
||||
use slog::Logger;
|
||||
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason};
|
||||
|
||||
use crate::common::{fetch_bonsai_changeset, format_bookmark_log_entry};
|
||||
|
||||
@ -120,7 +120,7 @@ fn handle_get<'a>(
|
||||
repo: BoxFuture<BlobRepo, Error>,
|
||||
) -> BoxFuture<(), Error> {
|
||||
let bookmark_name = args.value_of("BOOKMARK_NAME").unwrap().to_string();
|
||||
let bookmark = Bookmark::new(bookmark_name).unwrap();
|
||||
let bookmark = BookmarkName::new(bookmark_name).unwrap();
|
||||
let changeset_type = args.value_of("changeset-type").unwrap_or("hg");
|
||||
let json_flag: bool = args.is_present("json");
|
||||
|
||||
@ -155,7 +155,7 @@ fn handle_get<'a>(
|
||||
fn list_hg_bookmark_log_entries(
|
||||
repo: BlobRepo,
|
||||
ctx: CoreContext,
|
||||
name: Bookmark,
|
||||
name: BookmarkName,
|
||||
max_rec: u32,
|
||||
) -> impl Stream<
|
||||
Item = BoxFuture<(Option<HgChangesetId>, BookmarkUpdateReason, Timestamp), Error>,
|
||||
@ -180,7 +180,7 @@ fn handle_log<'a>(
|
||||
repo: BoxFuture<BlobRepo, Error>,
|
||||
) -> BoxFuture<(), Error> {
|
||||
let bookmark_name = args.value_of("BOOKMARK_NAME").unwrap().to_string();
|
||||
let bookmark = Bookmark::new(bookmark_name).unwrap();
|
||||
let bookmark = BookmarkName::new(bookmark_name).unwrap();
|
||||
let changeset_type = args.value_of("changeset-type").unwrap_or("hg");
|
||||
let json_flag = args.is_present("json");
|
||||
let output_limit_as_string = args.value_of("limit").unwrap_or("25");
|
||||
@ -252,7 +252,7 @@ fn handle_set<'a>(
|
||||
) -> BoxFuture<(), Error> {
|
||||
let bookmark_name = args.value_of("BOOKMARK_NAME").unwrap().to_string();
|
||||
let rev = args.value_of("HG_CHANGESET_ID").unwrap().to_string();
|
||||
let bookmark = Bookmark::new(bookmark_name).unwrap();
|
||||
let bookmark = BookmarkName::new(bookmark_name).unwrap();
|
||||
|
||||
repo.and_then(move |repo| {
|
||||
fetch_bonsai_changeset(ctx.clone(), &rev, &repo).and_then(move |bonsai_cs| {
|
||||
|
@ -5,7 +5,7 @@
|
||||
// GNU General Public License version 2 or any later version.
|
||||
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason};
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
use failure_ext::{err_msg, Error};
|
||||
@ -45,7 +45,7 @@ pub fn format_bookmark_log_entry(
|
||||
reason: BookmarkUpdateReason,
|
||||
timestamp: Timestamp,
|
||||
changeset_type: &str,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
bundle_id: Option<i64>,
|
||||
) -> String {
|
||||
let reason_str = reason.to_string();
|
||||
@ -76,7 +76,7 @@ pub fn resolve_hg_rev(
|
||||
repo: &BlobRepo,
|
||||
rev: &str,
|
||||
) -> impl Future<Item = HgChangesetId, Error = Error> {
|
||||
let book = Bookmark::new(&rev).unwrap();
|
||||
let book = BookmarkName::new(&rev).unwrap();
|
||||
let hash = HgChangesetId::from_str(rev);
|
||||
|
||||
repo.get_bookmark(ctx, &book).and_then({
|
||||
|
@ -4,7 +4,7 @@
|
||||
// This software may be used and distributed according to the terms of the
|
||||
// GNU General Public License version 2 or any later version.
|
||||
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use cloned::cloned;
|
||||
use cmdlib::args;
|
||||
use context::CoreContext;
|
||||
@ -60,7 +60,7 @@ fn main() {
|
||||
let bookmarks: Vec<_> = matches
|
||||
.values_of("BOOKMARK")
|
||||
.expect("No bookmarks to verify")
|
||||
.map(|bookmark| Bookmark::new(bookmark).expect("Bad bookmark to verify"))
|
||||
.map(|bookmark| BookmarkName::new(bookmark).expect("Bad bookmark to verify"))
|
||||
.collect();
|
||||
|
||||
let checkers = Checker::new();
|
||||
|
@ -13,7 +13,7 @@ extern crate failure_ext as failure;
|
||||
pub mod tailer;
|
||||
|
||||
use blobrepo_factory::open_blobrepo;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
@ -54,7 +54,7 @@ fn main() -> Result<()> {
|
||||
info!(logger, "Hook tailer is starting");
|
||||
let configs = get_config(&matches)?;
|
||||
let bookmark_name = matches.value_of("bookmark").unwrap();
|
||||
let bookmark = Bookmark::new(bookmark_name).unwrap();
|
||||
let bookmark = BookmarkName::new(bookmark_name).unwrap();
|
||||
let err: Error = ErrorKind::NoSuchRepo(repo_name.clone()).into();
|
||||
let config = configs.repos.get(&repo_name).ok_or(err)?;
|
||||
let init_revision = matches.value_of("init_revision").map(String::from);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
use super::HookResults;
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
use failure::{err_msg, Error, Result};
|
||||
@ -29,7 +29,7 @@ pub struct Tailer {
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
hook_manager: Arc<HookManager>,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
last_rev_key: String,
|
||||
manifold_client: ManifoldHttpClient,
|
||||
logger: Logger,
|
||||
@ -41,7 +41,7 @@ impl Tailer {
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
config: RepoConfig,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
manifold_client: ManifoldHttpClient,
|
||||
logger: Logger,
|
||||
excludes: HashSet<ChangesetId>,
|
||||
@ -84,7 +84,7 @@ impl Tailer {
|
||||
hm: Arc<HookManager>,
|
||||
last_rev: HgChangesetId,
|
||||
end_rev: HgChangesetId,
|
||||
bm: Bookmark,
|
||||
bm: BookmarkName,
|
||||
logger: Logger,
|
||||
excludes: HashSet<ChangesetId>,
|
||||
) -> BoxFuture<Vec<HookResults>, Error> {
|
||||
@ -289,7 +289,7 @@ fn run_hooks_for_changeset(
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
hm: Arc<HookManager>,
|
||||
bm: Bookmark,
|
||||
bm: BookmarkName,
|
||||
cs: ChangesetId,
|
||||
logger: Logger,
|
||||
) -> impl Future<Item = (HgChangesetId, HookResults), Error = Error> {
|
||||
@ -316,7 +316,7 @@ fn run_hooks_for_changeset(
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum ErrorKind {
|
||||
#[fail(display = "No such bookmark '{}'", _0)]
|
||||
NoSuchBookmark(Bookmark),
|
||||
NoSuchBookmark(BookmarkName),
|
||||
#[fail(display = "Cannot find last revision in blobstore")]
|
||||
NoLastRevision,
|
||||
#[fail(display = "Cannot find bonsai for {}", _0)]
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use context::CoreContext;
|
||||
use failure_ext::Error;
|
||||
use fixtures::many_files_dirs;
|
||||
@ -532,7 +532,7 @@ fn test_changeset_hook_context() {
|
||||
hook_name: "hook1".into(),
|
||||
config: Default::default(),
|
||||
data,
|
||||
bookmark: Bookmark::new("bm1").unwrap(),
|
||||
bookmark: BookmarkName::new("bm1").unwrap(),
|
||||
};
|
||||
let hooks: HashMap<String, Box<Hook<HookChangeset>>> = hashmap! {
|
||||
"hook1".to_string() => context_matching_changeset_hook(expected_context)
|
||||
@ -1041,7 +1041,7 @@ fn run_changeset_hooks_with_mgr(
|
||||
let fut = hook_manager.run_changeset_hooks_for_bookmark(
|
||||
ctx,
|
||||
default_changeset_id(),
|
||||
&Bookmark::new(bookmark_name).unwrap(),
|
||||
&BookmarkName::new(bookmark_name).unwrap(),
|
||||
None,
|
||||
);
|
||||
let res = fut.wait().unwrap();
|
||||
@ -1088,7 +1088,7 @@ fn run_file_hooks_with_mgr(
|
||||
.run_file_hooks_for_bookmark(
|
||||
ctx,
|
||||
default_changeset_id(),
|
||||
&Bookmark::new(bookmark_name).unwrap(),
|
||||
&BookmarkName::new(bookmark_name).unwrap(),
|
||||
None,
|
||||
);
|
||||
let res = fut.wait().unwrap();
|
||||
@ -1116,7 +1116,7 @@ fn setup_hook_manager(
|
||||
};
|
||||
for (bookmark_name, hook_names) in bookmarks {
|
||||
hook_manager
|
||||
.set_hooks_for_bookmark(Bookmark::new(bookmark_name).unwrap().into(), hook_names);
|
||||
.set_hooks_for_bookmark(BookmarkName::new(bookmark_name).unwrap().into(), hook_names);
|
||||
}
|
||||
for (regx, hook_names) in regexes {
|
||||
hook_manager.set_hooks_for_bookmark(Regex::new(®x).unwrap().into(), hook_names);
|
||||
@ -1220,7 +1220,7 @@ fn test_load_hooks() {
|
||||
let mut config = default_repo_config();
|
||||
config.bookmarks = vec![
|
||||
BookmarkParams {
|
||||
bookmark: Bookmark::new("bm1").unwrap().into(),
|
||||
bookmark: BookmarkName::new("bm1").unwrap().into(),
|
||||
hooks: vec!["hook1".into(), "hook2".into()],
|
||||
only_fast_forward: false,
|
||||
allowed_users: None,
|
||||
@ -1300,7 +1300,7 @@ fn test_verify_integrity_fast_failure() {
|
||||
#[test]
|
||||
fn test_load_hooks_no_such_hook() {
|
||||
async_unit::tokio_unit_test(|| {
|
||||
let book_or_rex = BookmarkOrRegex::Bookmark(Bookmark::new("bm1").unwrap());
|
||||
let book_or_rex = BookmarkOrRegex::Bookmark(BookmarkName::new("bm1").unwrap());
|
||||
let mut config = default_repo_config();
|
||||
config.bookmarks = vec![BookmarkParams {
|
||||
bookmark: book_or_rex.clone(),
|
||||
@ -1336,7 +1336,7 @@ fn test_load_hooks_bad_rust_hook() {
|
||||
async_unit::tokio_unit_test(|| {
|
||||
let mut config = default_repo_config();
|
||||
config.bookmarks = vec![BookmarkParams {
|
||||
bookmark: Bookmark::new("bm1").unwrap().into(),
|
||||
bookmark: BookmarkName::new("bm1").unwrap().into(),
|
||||
hooks: vec!["rust:hook1".into()],
|
||||
only_fast_forward: false,
|
||||
allowed_users: None,
|
||||
|
@ -23,7 +23,7 @@ pub mod rust_hook;
|
||||
use aclchecker::{AclChecker, Identity};
|
||||
use asyncmemo::{Asyncmemo, Filler, Weight};
|
||||
use blob_changeset::HgBlobChangeset;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use bytes::Bytes;
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
@ -54,7 +54,7 @@ pub struct HookManager {
|
||||
cache: Cache,
|
||||
changeset_hooks: ChangesetHooks,
|
||||
file_hooks: FileHooks,
|
||||
bookmark_hooks: HashMap<Bookmark, Vec<String>>,
|
||||
bookmark_hooks: HashMap<BookmarkName, Vec<String>>,
|
||||
regex_hooks: Vec<(Regex, Vec<String>)>,
|
||||
changeset_store: Box<ChangesetStore>,
|
||||
content_store: Arc<FileContentStore>,
|
||||
@ -161,7 +161,7 @@ impl HookManager {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn hooks_for_bookmark(&self, bookmark: &Bookmark) -> HashSet<String> {
|
||||
fn hooks_for_bookmark(&self, bookmark: &BookmarkName) -> HashSet<String> {
|
||||
let mut hooks: HashSet<_> = match self.bookmark_hooks.get(bookmark) {
|
||||
Some(hooks) => hooks.clone().into_iter().collect(),
|
||||
None => HashSet::new(),
|
||||
@ -183,7 +183,7 @@ impl HookManager {
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
changeset_id: HgChangesetId,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
maybe_pushvars: Option<HashMap<String, Bytes>>,
|
||||
) -> BoxFuture<Vec<(ChangesetHookExecutionID, HookExecution)>, Error> {
|
||||
let hooks: Vec<_> = self
|
||||
@ -211,7 +211,7 @@ impl HookManager {
|
||||
changeset_id: HgChangesetId,
|
||||
hooks: Vec<String>,
|
||||
maybe_pushvars: Option<HashMap<String, Bytes>>,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
) -> BoxFuture<Vec<(ChangesetHookExecutionID, HookExecution)>, Error> {
|
||||
let hooks: Result<Vec<(String, (Arc<Hook<HookChangeset>>, _))>, Error> = hooks
|
||||
.iter()
|
||||
@ -262,7 +262,7 @@ impl HookManager {
|
||||
ctx: CoreContext,
|
||||
changeset: HookChangeset,
|
||||
hooks: Vec<(String, Arc<Hook<HookChangeset>>, HookConfig)>,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
) -> BoxFuture<Vec<(String, HookExecution)>, Error> {
|
||||
futures::future::join_all(hooks.into_iter().map(move |(hook_name, hook, config)| {
|
||||
HookManager::run_changeset_hook(
|
||||
@ -296,7 +296,7 @@ impl HookManager {
|
||||
&self,
|
||||
ctx: CoreContext,
|
||||
changeset_id: HgChangesetId,
|
||||
bookmark: &Bookmark,
|
||||
bookmark: &BookmarkName,
|
||||
maybe_pushvars: Option<HashMap<String, Bytes>>,
|
||||
) -> BoxFuture<Vec<(FileHookExecutionID, HookExecution)>, Error> {
|
||||
debug!(
|
||||
@ -333,7 +333,7 @@ impl HookManager {
|
||||
hooks: Vec<(String, (Arc<Hook<HookFile>>, HookConfig))>,
|
||||
maybe_pushvars: Option<HashMap<String, Bytes>>,
|
||||
logger: Logger,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
) -> BoxFuture<Vec<(FileHookExecutionID, HookExecution)>, Error> {
|
||||
debug!(
|
||||
self.logger,
|
||||
@ -367,7 +367,7 @@ impl HookManager {
|
||||
hooks: Vec<String>,
|
||||
cache: Cache,
|
||||
logger: Logger,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
) -> BoxFuture<Vec<(FileHookExecutionID, HookExecution)>, Error> {
|
||||
let v: Vec<BoxFuture<Vec<(FileHookExecutionID, HookExecution)>, _>> = changeset
|
||||
.files
|
||||
@ -400,7 +400,7 @@ impl HookManager {
|
||||
hooks: Vec<String>,
|
||||
cache: Cache,
|
||||
logger: Logger,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
) -> BoxFuture<Vec<(FileHookExecutionID, HookExecution)>, Error> {
|
||||
let v: Vec<BoxFuture<(FileHookExecutionID, HookExecution), _>> = hooks
|
||||
.iter()
|
||||
@ -931,7 +931,7 @@ pub struct FileHookExecutionID {
|
||||
pub cs_id: HgChangesetId,
|
||||
pub hook_name: String,
|
||||
pub file: HookFile,
|
||||
pub bookmark: Bookmark,
|
||||
pub bookmark: BookmarkName,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Eq)]
|
||||
@ -976,14 +976,19 @@ where
|
||||
pub hook_name: String,
|
||||
pub config: HookConfig,
|
||||
pub data: T,
|
||||
pub bookmark: Bookmark,
|
||||
pub bookmark: BookmarkName,
|
||||
}
|
||||
|
||||
impl<T> HookContext<T>
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
fn new(hook_name: String, config: HookConfig, data: T, bookmark: Bookmark) -> HookContext<T> {
|
||||
fn new(
|
||||
hook_name: String,
|
||||
config: HookConfig,
|
||||
data: T,
|
||||
bookmark: BookmarkName,
|
||||
) -> HookContext<T> {
|
||||
HookContext {
|
||||
hook_name,
|
||||
config,
|
||||
|
@ -440,7 +440,7 @@ mod test {
|
||||
use aclchecker::AclChecker;
|
||||
use assert_matches::assert_matches;
|
||||
use async_unit;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use bytes::Bytes;
|
||||
use failure_ext::err_downcast;
|
||||
use futures::Future;
|
||||
@ -1615,7 +1615,7 @@ end"#;
|
||||
"testhook".into(),
|
||||
conf,
|
||||
default_changeset(),
|
||||
Bookmark::new("book").unwrap(),
|
||||
BookmarkName::new("book").unwrap(),
|
||||
)
|
||||
});
|
||||
});
|
||||
@ -1631,7 +1631,7 @@ end"#;
|
||||
"testhook".into(),
|
||||
conf,
|
||||
default_hook_added_file(),
|
||||
Bookmark::new("book").unwrap(),
|
||||
BookmarkName::new("book").unwrap(),
|
||||
)
|
||||
});
|
||||
});
|
||||
@ -1647,7 +1647,7 @@ end"#;
|
||||
hook.name.clone(),
|
||||
Default::default(),
|
||||
changeset,
|
||||
Bookmark::new("book").unwrap(),
|
||||
BookmarkName::new("book").unwrap(),
|
||||
);
|
||||
hook.run(ctx, context).wait()
|
||||
}
|
||||
@ -1662,7 +1662,7 @@ end"#;
|
||||
hook.name.clone(),
|
||||
Default::default(),
|
||||
hook_file,
|
||||
Bookmark::new("book").unwrap(),
|
||||
BookmarkName::new("book").unwrap(),
|
||||
);
|
||||
hook.run(ctx, context).wait()
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use std::{
|
||||
};
|
||||
|
||||
use crate::errors::*;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use failure_ext::ResultExt;
|
||||
use metaconfig_types::{
|
||||
BlobConfig, BlobstoreId, BookmarkOrRegex, BookmarkParams, Bundle2ReplayParams,
|
||||
@ -333,7 +333,8 @@ impl RepoConfigs {
|
||||
let scuba_table = this.scuba_table;
|
||||
let wireproto_scribe_category = this.wireproto_scribe_category;
|
||||
let cache_warmup = this.cache_warmup.map(|cache_warmup| CacheWarmupParams {
|
||||
bookmark: Bookmark::new(cache_warmup.bookmark).expect("bookmark name must be ascii"),
|
||||
bookmark: BookmarkName::new(cache_warmup.bookmark)
|
||||
.expect("bookmark name must be ascii"),
|
||||
commit_limit: cache_warmup.commit_limit.unwrap_or(200000),
|
||||
});
|
||||
let hook_manager_params = this.hook_manager_params.map(|params| HookManagerParams {
|
||||
@ -345,7 +346,9 @@ impl RepoConfigs {
|
||||
let mut bookmark_params = Vec::new();
|
||||
for bookmark in this.bookmarks.iter().cloned() {
|
||||
let bookmark_or_regex = match (bookmark.regex, bookmark.name) {
|
||||
(None, Some(name)) => BookmarkOrRegex::Bookmark(Bookmark::new(name).unwrap()),
|
||||
(None, Some(name)) => {
|
||||
BookmarkOrRegex::Bookmark(BookmarkName::new(name).unwrap())
|
||||
}
|
||||
(Some(regex), None) => BookmarkOrRegex::Regex(regex.0),
|
||||
_ => {
|
||||
return Err(ErrorKind::InvalidConfig(
|
||||
@ -947,7 +950,7 @@ mod test {
|
||||
repoid: 0,
|
||||
scuba_table: Some("scuba_table".to_string()),
|
||||
cache_warmup: Some(CacheWarmupParams {
|
||||
bookmark: Bookmark::new("master").unwrap(),
|
||||
bookmark: BookmarkName::new("master").unwrap(),
|
||||
commit_limit: 100,
|
||||
}),
|
||||
hook_manager_params: Some(HookManagerParams {
|
||||
@ -958,7 +961,7 @@ mod test {
|
||||
bookmarks_cache_ttl: Some(Duration::from_millis(5000)),
|
||||
bookmarks: vec![
|
||||
BookmarkParams {
|
||||
bookmark: Bookmark::new("master").unwrap().into(),
|
||||
bookmark: BookmarkName::new("master").unwrap().into(),
|
||||
hooks: vec![
|
||||
"hook1".to_string(),
|
||||
"hook2".to_string(),
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
use std::{collections::HashMap, num::NonZeroUsize, path::PathBuf, str, sync::Arc, time::Duration};
|
||||
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use regex::Regex;
|
||||
use scuba::ScubaValue;
|
||||
use serde_derive::Deserialize;
|
||||
@ -112,7 +112,7 @@ impl Default for RepoReadOnly {
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct CacheWarmupParams {
|
||||
/// Bookmark to warmup cache for at the startup. If not set then the cache will be cold.
|
||||
pub bookmark: Bookmark,
|
||||
pub bookmark: BookmarkName,
|
||||
/// Max number to fetch during commit warmup. If not set in the config, then set to a default
|
||||
/// value.
|
||||
pub commit_limit: usize,
|
||||
@ -145,14 +145,14 @@ impl Default for HookManagerParams {
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BookmarkOrRegex {
|
||||
/// Matches a single bookmark
|
||||
Bookmark(Bookmark),
|
||||
Bookmark(BookmarkName),
|
||||
/// Matches bookmarks with a regex
|
||||
Regex(Regex),
|
||||
}
|
||||
|
||||
impl BookmarkOrRegex {
|
||||
/// Checks whether a given Bookmark matches this bookmark or regex
|
||||
pub fn matches(&self, bookmark: &Bookmark) -> bool {
|
||||
pub fn matches(&self, bookmark: &BookmarkName) -> bool {
|
||||
match self {
|
||||
BookmarkOrRegex::Bookmark(ref bm) => bm.eq(bookmark),
|
||||
BookmarkOrRegex::Regex(ref re) => re.is_match(&bookmark.to_string()),
|
||||
@ -173,8 +173,8 @@ impl PartialEq for BookmarkOrRegex {
|
||||
}
|
||||
impl Eq for BookmarkOrRegex {}
|
||||
|
||||
impl From<Bookmark> for BookmarkOrRegex {
|
||||
fn from(b: Bookmark) -> Self {
|
||||
impl From<BookmarkName> for BookmarkOrRegex {
|
||||
fn from(b: BookmarkName) -> Self {
|
||||
BookmarkOrRegex::Bookmark(b)
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ impl BookmarkAttrs {
|
||||
/// select bookmark params matching provided bookmark
|
||||
pub fn select<'a>(
|
||||
&'a self,
|
||||
bookmark: &'a Bookmark,
|
||||
bookmark: &'a BookmarkName,
|
||||
) -> impl Iterator<Item = &'a BookmarkParams> {
|
||||
self.bookmark_params
|
||||
.iter()
|
||||
@ -210,13 +210,13 @@ impl BookmarkAttrs {
|
||||
}
|
||||
|
||||
/// check if provided bookmark is fast-forward only
|
||||
pub fn is_fast_forward_only(&self, bookmark: &Bookmark) -> bool {
|
||||
pub fn is_fast_forward_only(&self, bookmark: &BookmarkName) -> bool {
|
||||
self.select(bookmark).any(|params| params.only_fast_forward)
|
||||
}
|
||||
|
||||
/// Check if a bookmark config overrides whether date should be rewritten during pushrebase.
|
||||
/// Return None if there are no bookmark config overriding rewrite_dates.
|
||||
pub fn should_rewrite_dates(&self, bookmark: &Bookmark) -> Option<bool> {
|
||||
pub fn should_rewrite_dates(&self, bookmark: &BookmarkName) -> Option<bool> {
|
||||
for params in self.select(bookmark) {
|
||||
// NOTE: If there are multiple patterns matching the bookmark, the first match
|
||||
// overrides others. It might not be the most desired behavior, though.
|
||||
@ -228,7 +228,7 @@ impl BookmarkAttrs {
|
||||
}
|
||||
|
||||
/// check if provided unix name is allowed to move specified bookmark
|
||||
pub fn is_allowed_user(&self, user: &Option<String>, bookmark: &Bookmark) -> bool {
|
||||
pub fn is_allowed_user(&self, user: &Option<String>, bookmark: &BookmarkName) -> bool {
|
||||
match user {
|
||||
None => true,
|
||||
Some(user) => {
|
||||
|
@ -12,7 +12,7 @@ use failure::Error;
|
||||
use futures::Future;
|
||||
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use cloned::cloned;
|
||||
use context::CoreContext;
|
||||
use mercurial_types::manifest::Content;
|
||||
@ -34,17 +34,19 @@ pub fn get_content_by_path(
|
||||
move |changeset| repo.find_path_in_manifest(ctx, path, changeset.manifestid())
|
||||
})
|
||||
.and_then(|content| {
|
||||
content.ok_or_else(move || {
|
||||
ErrorKind::NotFound(path.map(|p| p.to_string()).unwrap_or("/".to_string())).into()
|
||||
})
|
||||
.map(|(content, _)| content)
|
||||
content
|
||||
.ok_or_else(move || {
|
||||
ErrorKind::NotFound(path.map(|p| p.to_string()).unwrap_or("/".to_string()))
|
||||
.into()
|
||||
})
|
||||
.map(|(content, _)| content)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_changeset_by_bookmark(
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
) -> impl Future<Item = HgChangesetId, Error = Error> {
|
||||
repo.get_bookmark(ctx, &bookmark)
|
||||
.map_err({
|
||||
|
@ -350,7 +350,7 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason};
|
||||
use fixtures::linear;
|
||||
use futures::Stream;
|
||||
use maplit::hashset;
|
||||
@ -389,7 +389,7 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn delete_bookmark(ctx: CoreContext, repo: BlobRepo, book: &Bookmark) {
|
||||
fn delete_bookmark(ctx: CoreContext, repo: BlobRepo, book: &BookmarkName) {
|
||||
let mut txn = repo.update_bookmark_transaction(ctx);
|
||||
txn.force_delete(
|
||||
&book,
|
||||
@ -401,7 +401,7 @@ mod tests {
|
||||
txn.commit().wait().unwrap();
|
||||
}
|
||||
|
||||
fn set_bookmark(ctx: CoreContext, repo: BlobRepo, book: &Bookmark, cs_id: &str) {
|
||||
fn set_bookmark(ctx: CoreContext, repo: BlobRepo, book: &BookmarkName, cs_id: &str) {
|
||||
let head = repo
|
||||
.get_bonsai_from_hg(ctx.clone(), HgChangesetId::from_str(cs_id).unwrap())
|
||||
.wait()
|
||||
@ -461,7 +461,7 @@ mod tests {
|
||||
set_bookmark(
|
||||
ctx.clone(),
|
||||
repo.clone(),
|
||||
&Bookmark::new("master").unwrap(),
|
||||
&BookmarkName::new("master").unwrap(),
|
||||
"eed3a8c0ec67b6a6fe2eb3543334df3f0b4f202b",
|
||||
);
|
||||
|
||||
|
@ -609,7 +609,7 @@ mod test {
|
||||
|
||||
use async_unit;
|
||||
use blobrepo::BlobRepo;
|
||||
use bookmarks::Bookmark;
|
||||
use bookmarks::BookmarkName;
|
||||
use chashmap::CHashMap;
|
||||
use context::CoreContext;
|
||||
use futures::stream::iter_ok;
|
||||
@ -2146,7 +2146,7 @@ mod test {
|
||||
sli: SkiplistIndex,
|
||||
) {
|
||||
let f = repo
|
||||
.get_bonsai_bookmark(ctx.clone(), &Bookmark::new("master").unwrap())
|
||||
.get_bonsai_bookmark(ctx.clone(), &BookmarkName::new("master").unwrap())
|
||||
.and_then({
|
||||
cloned!(ctx, repo);
|
||||
move |maybe_cs_id| {
|
||||
|
@ -8,7 +8,7 @@ use crate::errors::*;
|
||||
use crate::mononoke_repo::{MononokeRepo, SqlStreamingCloneConfig};
|
||||
use blobrepo::BlobRepo;
|
||||
use blobrepo::HgBlobChangeset;
|
||||
use bookmarks::{Bookmark, BookmarkPrefix};
|
||||
use bookmarks::{BookmarkName, BookmarkPrefix};
|
||||
use bundle2_resolver;
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use cloned::cloned;
|
||||
@ -395,9 +395,9 @@ impl RepoClient {
|
||||
if args.listkeys.contains(&b"bookmarks".to_vec()) {
|
||||
let items = blobrepo
|
||||
.get_bookmarks_maybe_stale(self.ctx.clone())
|
||||
.map(|(name, cs)| {
|
||||
.map(|(book, cs)| {
|
||||
let hash: Vec<u8> = cs.into_nodehash().to_hex().into();
|
||||
(name.to_string(), hash)
|
||||
(book.to_string(), hash)
|
||||
});
|
||||
bundle2_parts.push(parts::listkey_part("bookmarks", items)?);
|
||||
}
|
||||
@ -680,7 +680,7 @@ impl HgCommands for RepoClient {
|
||||
fn check_bookmark_exists(
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
bookmark: Bookmark,
|
||||
bookmark: BookmarkName,
|
||||
) -> HgCommandRes<Bytes> {
|
||||
repo.get_bookmark(ctx, &bookmark)
|
||||
.map(move |csid| match csid {
|
||||
@ -691,7 +691,7 @@ impl HgCommands for RepoClient {
|
||||
}
|
||||
|
||||
let node = HgChangesetId::from_str(&key).ok();
|
||||
let bookmark = Bookmark::new(&key).ok();
|
||||
let bookmark = BookmarkName::new(&key).ok();
|
||||
|
||||
let lookup_fut = match (node, bookmark) {
|
||||
(Some(node), Some(bookmark)) => {
|
||||
@ -898,13 +898,12 @@ impl HgCommands for RepoClient {
|
||||
info!(self.ctx.logger(), "listkeys: {}", namespace);
|
||||
if namespace == "bookmarks" {
|
||||
let mut scuba_logger = self.prepared_ctx(ops::LISTKEYS, None).scuba().clone();
|
||||
|
||||
self.repo
|
||||
.blobrepo()
|
||||
.get_bookmarks_maybe_stale(self.ctx.clone())
|
||||
.map(|(name, cs)| {
|
||||
.map(|(book, cs)| {
|
||||
let hash: Vec<u8> = cs.into_nodehash().to_hex().into();
|
||||
(name, hash)
|
||||
(book.to_string(), hash)
|
||||
})
|
||||
.collect()
|
||||
.map(|bookmarks| {
|
||||
@ -945,10 +944,10 @@ impl HgCommands for RepoClient {
|
||||
if namespace != "bookmarks" {
|
||||
info!(
|
||||
self.ctx.logger(),
|
||||
"unsupported listkyespatterns namespace: {}", namespace,
|
||||
"unsupported listkeyspatterns namespace: {}", namespace,
|
||||
);
|
||||
return future::err(format_err!(
|
||||
"unsupported listkyespatterns namespace: {}",
|
||||
"unsupported listkeyspatterns namespace: {}",
|
||||
namespace
|
||||
))
|
||||
.boxify();
|
||||
@ -972,7 +971,7 @@ impl HgCommands for RepoClient {
|
||||
.boxify()
|
||||
} else {
|
||||
// literal match
|
||||
let bookmark = try_boxfuture!(Bookmark::new(&pattern));
|
||||
let bookmark = try_boxfuture!(BookmarkName::new(&pattern));
|
||||
repo.get_bookmark(ctx.clone(), &bookmark)
|
||||
.map(move |cs_id| match cs_id {
|
||||
Some(cs_id) => vec![(pattern, cs_id)],
|
||||
|
24
tests/fixtures/src/lib.rs
vendored
24
tests/fixtures/src/lib.rs
vendored
@ -25,7 +25,7 @@ use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
use blobrepo::{save_bonsai_changesets, BlobRepo};
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason};
|
||||
use bytes::Bytes;
|
||||
use context::CoreContext;
|
||||
use futures::future::{join_all, Future};
|
||||
@ -117,7 +117,7 @@ fn create_bonsai_changeset_from_test_data(
|
||||
);
|
||||
}
|
||||
|
||||
fn set_bookmark(blobrepo: BlobRepo, hg_cs_id: &str, bookmark: Bookmark) {
|
||||
fn set_bookmark(blobrepo: BlobRepo, hg_cs_id: &str, bookmark: BookmarkName) {
|
||||
let ctx = CoreContext::test_mock();
|
||||
let hg_cs_id = HgChangesetId::from_str(hg_cs_id).unwrap();
|
||||
let bcs_id = blobrepo
|
||||
@ -287,7 +287,7 @@ pub mod linear {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"79a13814c5ce7330173ec04d279bf95ab3f652fb",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -387,7 +387,7 @@ pub mod branch_even {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"4f7f3fd428bec1a48f9314414b063c706d9c1aed",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -547,7 +547,7 @@ pub mod branch_uneven {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"264f01429683b3dd8042cb3979e8bf37007118bc",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -647,7 +647,7 @@ pub mod branch_wide {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"49f53ab171171b3180e125b918bd1cf0af7e5449",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -762,7 +762,7 @@ pub mod merge_even {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"6120679e1fedb0b2f3717bbf042e5fd718763042",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -832,7 +832,7 @@ pub mod many_files_dirs {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"051946ed218061e925fb120dac02634f9ad40ae2",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
let files = btreemap! {
|
||||
@ -849,7 +849,7 @@ pub mod many_files_dirs {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"5a28e25f924a5d209b82ce0713d8d83e68982bc8",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -1028,7 +1028,7 @@ pub mod merge_uneven {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"d0b4845e349f338361208f170ec13120080da37f",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -1211,7 +1211,7 @@ pub mod unshared_merge_even {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"7fe9947f101acb4acf7d945e69f0d6ce76a81113",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
@ -1459,7 +1459,7 @@ pub mod unshared_merge_uneven {
|
||||
set_bookmark(
|
||||
blobrepo.clone(),
|
||||
"dd993aab2bed7276e17c88470286ba8459ba6d94",
|
||||
Bookmark::new("master").unwrap(),
|
||||
BookmarkName::new("master").unwrap(),
|
||||
);
|
||||
|
||||
blobrepo
|
||||
|
@ -61,12 +61,12 @@ push new bookmark
|
||||
remote: bundle2_resolver error
|
||||
remote: Root cause:
|
||||
remote: ErrorMessage {
|
||||
remote: msg: "[push] This user `Some(\"aslpavel\")` is not allowed to move `Bookmark { bookmark: \"D\" }`"
|
||||
remote: msg: "[push] This user `Some(\"aslpavel\")` is not allowed to move `BookmarkName { bookmark: \"D\" }`"
|
||||
remote: }
|
||||
remote: Caused by:
|
||||
remote: While updating Bookmarks
|
||||
remote: Caused by:
|
||||
remote: [push] This user `Some("aslpavel")` is not allowed to move `Bookmark { bookmark: "D" }`
|
||||
remote: [push] This user `Some("aslpavel")` is not allowed to move `BookmarkName { bookmark: "D" }`
|
||||
abort: stream ended unexpectedly (got 0 bytes, expected 4)
|
||||
[255]
|
||||
$ MOCK_USERNAME="b" hgmn push -r . --create --to D
|
||||
@ -89,12 +89,12 @@ push updates existing bookmark
|
||||
remote: bundle2_resolver error
|
||||
remote: Root cause:
|
||||
remote: ErrorMessage {
|
||||
remote: msg: "[push] This user `Some(\"aslapvel\")` is not allowed to move `Bookmark { bookmark: \"A\" }`"
|
||||
remote: msg: "[push] This user `Some(\"aslapvel\")` is not allowed to move `BookmarkName { bookmark: \"A\" }`"
|
||||
remote: }
|
||||
remote: Caused by:
|
||||
remote: While updating Bookmarks
|
||||
remote: Caused by:
|
||||
remote: [push] This user `Some("aslapvel")` is not allowed to move `Bookmark { bookmark: "A" }`
|
||||
remote: [push] This user `Some("aslapvel")` is not allowed to move `BookmarkName { bookmark: "A" }`
|
||||
abort: stream ended unexpectedly (got 0 bytes, expected 4)
|
||||
[255]
|
||||
$ MOCK_USERNAME="a" hgmn push -r . --to A
|
||||
@ -119,10 +119,10 @@ pushrebase
|
||||
searching for changes
|
||||
remote: Command failed
|
||||
remote: Error:
|
||||
remote: [pushrebase] This user `Some("a")` is not allowed to move `Bookmark { bookmark: "C" }`
|
||||
remote: [pushrebase] This user `Some("a")` is not allowed to move `BookmarkName { bookmark: "C" }`
|
||||
remote: Root cause:
|
||||
remote: ErrorMessage {
|
||||
remote: msg: "[pushrebase] This user `Some(\"a\")` is not allowed to move `Bookmark { bookmark: \"C\" }`"
|
||||
remote: msg: "[pushrebase] This user `Some(\"a\")` is not allowed to move `BookmarkName { bookmark: \"C\" }`"
|
||||
remote: }
|
||||
abort: stream ended unexpectedly (got 0 bytes, expected 4)
|
||||
[255]
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
use bookmarks::{Bookmark, BookmarkUpdateReason, Bookmarks};
|
||||
use bookmarks::{BookmarkName, BookmarkUpdateReason, Bookmarks};
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use cmdlib::args;
|
||||
use context::CoreContext;
|
||||
@ -72,7 +72,7 @@ fn main() -> Result<()> {
|
||||
},
|
||||
};
|
||||
|
||||
let bookmark = Bookmark::new(name).unwrap();
|
||||
let bookmark = BookmarkName::new(name).unwrap();
|
||||
|
||||
let mut txn = bookmarks.create_transaction(ctx, repo_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user