mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
mononoke: support blaclisting magic string in getpack wireproto requests
Summary: We need this to not break clients with `remotefilelog.fetchpacks=True`. Reviewed By: krallin Differential Revision: D16735900 fbshipit-source-id: a993610c2e95cfde95a8be1e31eaad825f95dc15
This commit is contained in:
parent
9b453addd5
commit
b68d21b5b3
@ -8,7 +8,7 @@ use censoredblob::ErrorKind::Censored;
|
||||
use failure::Error;
|
||||
use futures::{future, Future};
|
||||
use futures_ext::FutureExt;
|
||||
use mercurial_types::{FileBytes, RevFlags};
|
||||
use mercurial_types::{FileBytes, HgBlob, RevFlags};
|
||||
|
||||
/// Tombstone string to replace the content of blacklisted files with
|
||||
const CENSORED_CONTENT: &str =
|
||||
@ -38,3 +38,7 @@ pub fn tombstone_filebytes_revflags() -> (FileBytes, RevFlags) {
|
||||
RevFlags::REVIDX_DEFAULT_FLAGS,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn tombstone_hgblob() -> HgBlob {
|
||||
HgBlob::from(CENSORED_CONTENT.as_bytes().to_vec())
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use blobrepo::HgBlobChangeset;
|
||||
use bookmarks::{Bookmark, BookmarkName, BookmarkPrefix};
|
||||
use bundle2_resolver;
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use censorship::{hide_censorship_error, tombstone_hgblob};
|
||||
use cloned::cloned;
|
||||
use context::{CoreContext, Metric};
|
||||
use failure::{err_msg, format_err};
|
||||
@ -532,11 +533,18 @@ impl RepoClient {
|
||||
let contents: Vec<_> = filenodes
|
||||
.iter()
|
||||
.map(|filenode| {
|
||||
repo.get_raw_hg_content(ctx.clone(), *filenode, validate_hash)
|
||||
.map({
|
||||
cloned!(filenode);
|
||||
move |content| (filenode, content.into_inner())
|
||||
})
|
||||
hide_censorship_error(
|
||||
repo.clone().get_raw_hg_content(
|
||||
ctx.clone(),
|
||||
filenode.clone(),
|
||||
validate_hash,
|
||||
),
|
||||
tombstone_hgblob,
|
||||
)
|
||||
.map({
|
||||
cloned!(filenode);
|
||||
move |content| (filenode, content.into_inner())
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -26,6 +26,19 @@ setup repo-pull and repo-push
|
||||
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo-push2 --noupdate
|
||||
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo-push3 --noupdate
|
||||
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo-pull --noupdate
|
||||
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo-pull-fetchpacksv1 --noupdate
|
||||
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo-pull-fetchpacksv2 --noupdate
|
||||
$ cat >> repo-pull-fetchpacksv1/.hg/hgrc << EOF
|
||||
> [remotefilelog]
|
||||
> fetchpacks=True
|
||||
> getpackversion=1
|
||||
> EOF
|
||||
$ cat >> repo-pull-fetchpacksv2/.hg/hgrc << EOF
|
||||
> [remotefilelog]
|
||||
> fetchpacks=True
|
||||
> getpackversion=2
|
||||
> EOF
|
||||
|
||||
|
||||
blobimport
|
||||
$ blobimport repo-hg/.hg repo
|
||||
@ -353,3 +366,17 @@ Updating from a commit that contains a blacklisted file to another commit should
|
||||
File should contain the uncommited change: bb
|
||||
$ cat b
|
||||
bb
|
||||
|
||||
Updating to a commit with censored files works in getpackv1 repo
|
||||
$ cd $TESTTMP/repo-pull-fetchpacksv1
|
||||
$ hgmn pull -q
|
||||
$ hgmn up -q 064d994d0240
|
||||
$ cat c
|
||||
This version of the file is blacklisted and you are not allowed to access it. Update or rebase to a newer commit.
|
||||
|
||||
Updating to a commit with censored files works in getpackv2 repo
|
||||
$ cd $TESTTMP/repo-pull-fetchpacksv2
|
||||
$ hgmn pull -q
|
||||
$ hgmn up -q 064d994d0240
|
||||
$ cat c
|
||||
This version of the file is blacklisted and you are not allowed to access it. Update or rebase to a newer commit.
|
||||
|
Loading…
Reference in New Issue
Block a user