From 7e05a01ce52f77a95002502050e32a34c6d72d84 Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Mon, 16 Apr 2018 03:34:03 -0700 Subject: [PATCH] CODEMOD: rename mercurial_types::HgManifestId to DManifestId Summary: mercurial_types::DManifestId should be replaced by types from mononoke_types in most cases and by mercurial::HgManifestId in others. This rename should help with tracking this Reviewed By: sid0 Differential Revision: D7619062 fbshipit-source-id: 447224194c6555334b64dc29ebabe3ef0d0cb87e --- blobrepo/src/changeset.rs | 10 +++++----- blobrepo/src/file.rs | 4 ++-- blobrepo/src/manifest.rs | 4 ++-- blobrepo/src/repo.rs | 6 +++--- blobrepo/src/repo_commit.rs | 12 ++++++------ blobrepo/test/main.rs | 10 +++++----- mercurial-types/mocks/nodehash.rs | 32 +++++++++++++++---------------- mercurial-types/src/changeset.rs | 6 +++--- mercurial-types/src/lib.rs | 2 +- mercurial-types/src/nodehash.rs | 12 ++++++------ mercurial-types/src/sql_types.rs | 8 ++++---- server/src/repo.rs | 5 ++--- 12 files changed, 55 insertions(+), 56 deletions(-) diff --git a/blobrepo/src/changeset.rs b/blobrepo/src/changeset.rs index 12c3ff8e04..943d40ddb6 100644 --- a/blobrepo/src/changeset.rs +++ b/blobrepo/src/changeset.rs @@ -20,7 +20,7 @@ use mercurial::{self, NodeHashConversion}; use mercurial::changeset::Extra; use mercurial::revlogrepo::RevlogChangeset; use mercurial_types::{BlobNode, Changeset, HgBlob, MPath, Parents, Time}; -use mercurial_types::nodehash::{DChangesetId, HgManifestId, D_NULL_HASH}; +use mercurial_types::nodehash::{DChangesetId, DManifestId, D_NULL_HASH}; use errors::*; @@ -39,7 +39,7 @@ struct RawCSBlob<'a> { pub struct ChangesetContent { parents: Parents, - manifestid: HgManifestId, + manifestid: DManifestId, user: Vec, time: Time, extra: Extra, @@ -56,7 +56,7 @@ impl From for ChangesetContent { Parents::new(p1.as_ref(), p2.as_ref()) }; - let manifestid = HgManifestId::new(revlogcs.manifestid.into_nodehash().into_mononoke()); + let manifestid = DManifestId::new(revlogcs.manifestid.into_nodehash().into_mononoke()); Self { parents, @@ -73,7 +73,7 @@ impl From for ChangesetContent { impl ChangesetContent { pub fn new_from_parts( parents: Parents, - manifestid: HgManifestId, + manifestid: DManifestId, user: Vec, time: Time, extra: BTreeMap, Vec>, @@ -218,7 +218,7 @@ impl BlobChangeset { } impl Changeset for BlobChangeset { - fn manifestid(&self) -> &HgManifestId { + fn manifestid(&self) -> &DManifestId { &self.content.manifestid } diff --git a/blobrepo/src/file.rs b/blobrepo/src/file.rs index efeb69156c..88109da249 100644 --- a/blobrepo/src/file.rs +++ b/blobrepo/src/file.rs @@ -13,7 +13,7 @@ use futures::future::Future; use futures_ext::{BoxFuture, FutureExt}; use mercurial::file; -use mercurial_types::{BlobNode, DNodeHash, FileType, HgBlob, HgManifestId, MPath, MPathElement, +use mercurial_types::{BlobNode, DManifestId, DNodeHash, FileType, HgBlob, MPath, MPathElement, Parents}; use mercurial_types::manifest::{Content, Entry, Manifest, Type}; use mercurial_types::nodehash::EntryId; @@ -82,7 +82,7 @@ impl BlobEntry { }) } - pub fn new_root(blobstore: Arc, manifestid: HgManifestId) -> Self { + pub fn new_root(blobstore: Arc, manifestid: DManifestId) -> Self { Self { blobstore, name: None, diff --git a/blobrepo/src/manifest.rs b/blobrepo/src/manifest.rs index 123134dc06..190af0b9bb 100644 --- a/blobrepo/src/manifest.rs +++ b/blobrepo/src/manifest.rs @@ -15,7 +15,7 @@ use futures::stream::{self, Stream}; use futures_ext::{BoxFuture, BoxStream, FutureExt, StreamExt}; use mercurial_types::{Entry, FileType, MPathElement, Manifest, Type}; -use mercurial_types::nodehash::{DNodeHash, EntryId, HgManifestId, D_NULL_HASH}; +use mercurial_types::nodehash::{DManifestId, DNodeHash, EntryId, D_NULL_HASH}; use blobstore::Blobstore; @@ -92,7 +92,7 @@ pub struct BlobManifest { impl BlobManifest { pub fn load( blobstore: &Arc, - manifestid: &HgManifestId, + manifestid: &DManifestId, ) -> BoxFuture, Error> { let nodehash = manifestid.clone().into_nodehash(); if nodehash == D_NULL_HASH { diff --git a/blobrepo/src/repo.rs b/blobrepo/src/repo.rs index f5cdfbfce2..d4a0f7c93c 100644 --- a/blobrepo/src/repo.rs +++ b/blobrepo/src/repo.rs @@ -40,7 +40,7 @@ use memheads::MemHeads; use mercurial_types::{BlobNode, Changeset, DChangesetId, DNodeHash, Entry, HgBlob, HgFileNodeId, Manifest, Parents, RepoPath, RepositoryId, Time}; use mercurial_types::manifest; -use mercurial_types::nodehash::HgManifestId; +use mercurial_types::nodehash::DManifestId; use rocksblob::Rocksblob; use rocksdb; use tokio_core::reactor::Remote; @@ -292,14 +292,14 @@ impl BlobRepo { nodeid: &DNodeHash, ) -> BoxFuture, Error> { let nodeid = *nodeid; - let manifestid = HgManifestId::new(nodeid); + let manifestid = DManifestId::new(nodeid); BlobManifest::load(&self.blobstore, &manifestid) .and_then(move |mf| mf.ok_or(ErrorKind::ManifestMissing(nodeid).into())) .map(|m| m.boxed()) .boxify() } - pub fn get_root_entry(&self, manifestid: &HgManifestId) -> Box { + pub fn get_root_entry(&self, manifestid: &DManifestId) -> Box { Box::new(BlobEntry::new_root(self.blobstore.clone(), *manifestid)) } diff --git a/blobrepo/src/repo_commit.rs b/blobrepo/src/repo_commit.rs index b3fcd595f4..ac4ff2ee62 100644 --- a/blobrepo/src/repo_commit.rs +++ b/blobrepo/src/repo_commit.rs @@ -26,7 +26,7 @@ use mercurial_types::{BlobNode, Changeset, DChangesetId, DNodeHash, Entry, Entry Manifest, Parents, RepoPath, RepositoryId, Time}; use mercurial_types::manifest::{self, Content}; use mercurial_types::manifest_utils::{changed_entry_stream, EntryStatus}; -use mercurial_types::nodehash::{HgFileNodeId, HgManifestId}; +use mercurial_types::nodehash::{DManifestId, HgFileNodeId}; use BlobChangeset; use BlobRepo; @@ -42,13 +42,13 @@ use utils::get_node_key; /// See `get_completed_changeset()` for the public API you can use to extract the final changeset #[derive(Clone)] pub struct ChangesetHandle { - can_be_parent: Shared>, + can_be_parent: Shared>, completion_future: Shared>>, } impl ChangesetHandle { pub fn new_pending( - can_be_parent: Shared>, + can_be_parent: Shared>, completion_future: Shared>>, ) -> Self { Self { @@ -362,7 +362,7 @@ pub fn process_entries( entry_processor: &UploadEntries, root_manifest: BoxFuture<(BlobEntry, RepoPath), Error>, new_child_entries: BoxStream<(BlobEntry, RepoPath), Error>, -) -> BoxFuture<(Box, HgManifestId), Error> { +) -> BoxFuture<(Box, DManifestId), Error> { root_manifest .and_then({ let entry_processor = entry_processor.clone(); @@ -388,7 +388,7 @@ pub fn process_entries( }) .and_then(move |root_hash| { repo.get_manifest_by_nodeid(&root_hash) - .map(move |m| (m, HgManifestId::new(root_hash))) + .map(move |m| (m, DManifestId::new(root_hash))) }) .timed(move |stats, result| { if result.is_ok() { @@ -482,7 +482,7 @@ pub fn handle_parents( pub fn make_new_changeset( parents: Parents, - root_hash: HgManifestId, + root_hash: DManifestId, user: String, time: Time, extra: BTreeMap, Vec>, diff --git a/blobrepo/test/main.rs b/blobrepo/test/main.rs index c05f3ceaaa..9d3f3e5781 100644 --- a/blobrepo/test/main.rs +++ b/blobrepo/test/main.rs @@ -29,8 +29,8 @@ use bytes::Bytes; use futures::Future; use blobrepo::{compute_changed_files, BlobRepo}; -use mercurial_types::{manifest, Changeset, DChangesetId, Entry, EntryId, FileType, HgBlob, - HgManifestId, MPath, MPathElement, RepoPath}; +use mercurial_types::{manifest, Changeset, DChangesetId, DManifestId, Entry, EntryId, FileType, + HgBlob, MPath, MPathElement, RepoPath}; mod stats_units; #[macro_use] @@ -143,7 +143,7 @@ fn create_one_changeset(repo: BlobRepo) { ); let cs = run_future(commit.get_completed_changeset()).unwrap(); - assert!(cs.manifestid() == &HgManifestId::new(roothash)); + assert!(cs.manifestid() == &DManifestId::new(roothash)); assert!(cs.user() == author.as_bytes()); assert!(cs.parents().get_nodes() == (None, None)); let files: Vec<_> = cs.files().into(); @@ -197,7 +197,7 @@ fn create_two_changesets(repo: BlobRepo) { .join(commit2.get_completed_changeset()), ).unwrap(); - assert!(commit2.manifestid() == &HgManifestId::new(roothash)); + assert!(commit2.manifestid() == &DManifestId::new(roothash)); assert!(commit2.user() == utf_author.as_bytes()); let files: Vec<_> = commit2.files().into(); let expected_files = vec![MPath::new("dir/file").unwrap(), MPath::new("file").unwrap()]; @@ -337,7 +337,7 @@ fn check_linknode_creation(repo: BlobRepo) { let commit = create_changeset_no_parents(&repo, root_manifest_future, uploads); let cs = run_future(commit.get_completed_changeset()).unwrap(); - assert!(cs.manifestid() == &HgManifestId::new(roothash)); + assert!(cs.manifestid() == &DManifestId::new(roothash)); assert!(cs.user() == author.as_bytes()); assert!(cs.parents().get_nodes() == (None, None)); diff --git a/mercurial-types/mocks/nodehash.rs b/mercurial-types/mocks/nodehash.rs index d08c843056..cd22f753be 100644 --- a/mercurial-types/mocks/nodehash.rs +++ b/mercurial-types/mocks/nodehash.rs @@ -7,7 +7,7 @@ // Ignore deprecation of NodeHash::new #![allow(deprecated)] -use mercurial_types::{DChangesetId, DNodeHash, HgFileNodeId, HgManifestId}; +use mercurial_types::{DChangesetId, DManifestId, DNodeHash, HgFileNodeId}; // D_NULL_HASH is exported for convenience. pub use mercurial_types::D_NULL_HASH; @@ -48,21 +48,21 @@ pub const ES_CSID: DChangesetId = DChangesetId::new(ES_HASH); pub const FS_CSID: DChangesetId = DChangesetId::new(FS_HASH); // Definitions for manifest IDs 1111...ffff -pub const ONES_MID: HgManifestId = HgManifestId::new(ONES_HASH); -pub const TWOS_MID: HgManifestId = HgManifestId::new(TWOS_HASH); -pub const THREES_MID: HgManifestId = HgManifestId::new(THREES_HASH); -pub const FOURS_MID: HgManifestId = HgManifestId::new(FOURS_HASH); -pub const FIVES_MID: HgManifestId = HgManifestId::new(FIVES_HASH); -pub const SIXES_MID: HgManifestId = HgManifestId::new(SIXES_HASH); -pub const SEVENS_MID: HgManifestId = HgManifestId::new(SEVENS_HASH); -pub const EIGHTS_MID: HgManifestId = HgManifestId::new(EIGHTS_HASH); -pub const NINES_MID: HgManifestId = HgManifestId::new(NINES_HASH); -pub const AS_MID: HgManifestId = HgManifestId::new(AS_HASH); -pub const BS_MID: HgManifestId = HgManifestId::new(BS_HASH); -pub const CS_MID: HgManifestId = HgManifestId::new(CS_HASH); -pub const DS_MID: HgManifestId = HgManifestId::new(DS_HASH); -pub const ES_MID: HgManifestId = HgManifestId::new(ES_HASH); -pub const FS_MID: HgManifestId = HgManifestId::new(FS_HASH); +pub const ONES_MID: DManifestId = DManifestId::new(ONES_HASH); +pub const TWOS_MID: DManifestId = DManifestId::new(TWOS_HASH); +pub const THREES_MID: DManifestId = DManifestId::new(THREES_HASH); +pub const FOURS_MID: DManifestId = DManifestId::new(FOURS_HASH); +pub const FIVES_MID: DManifestId = DManifestId::new(FIVES_HASH); +pub const SIXES_MID: DManifestId = DManifestId::new(SIXES_HASH); +pub const SEVENS_MID: DManifestId = DManifestId::new(SEVENS_HASH); +pub const EIGHTS_MID: DManifestId = DManifestId::new(EIGHTS_HASH); +pub const NINES_MID: DManifestId = DManifestId::new(NINES_HASH); +pub const AS_MID: DManifestId = DManifestId::new(AS_HASH); +pub const BS_MID: DManifestId = DManifestId::new(BS_HASH); +pub const CS_MID: DManifestId = DManifestId::new(CS_HASH); +pub const DS_MID: DManifestId = DManifestId::new(DS_HASH); +pub const ES_MID: DManifestId = DManifestId::new(ES_HASH); +pub const FS_MID: DManifestId = DManifestId::new(FS_HASH); // Definitions for filenode IDs 1111...ffff pub const ONES_FNID: HgFileNodeId = HgFileNodeId::new(ONES_HASH); diff --git a/mercurial-types/src/changeset.rs b/mercurial-types/src/changeset.rs index 5f279311d4..14de24f8ca 100644 --- a/mercurial-types/src/changeset.rs +++ b/mercurial-types/src/changeset.rs @@ -9,10 +9,10 @@ use std::collections::BTreeMap; use mononoke_types::MPath; use blobnode::Parents; -use nodehash::HgManifestId; +use nodehash::DManifestId; pub trait Changeset: Send + 'static { - fn manifestid(&self) -> &HgManifestId; + fn manifestid(&self) -> &DManifestId; fn user(&self) -> &[u8]; fn extra(&self) -> &BTreeMap, Vec>; fn comments(&self) -> &[u8]; @@ -29,7 +29,7 @@ pub trait Changeset: Send + 'static { } impl Changeset for Box { - fn manifestid(&self) -> &HgManifestId { + fn manifestid(&self) -> &DManifestId { (**self).manifestid() } diff --git a/mercurial-types/src/lib.rs b/mercurial-types/src/lib.rs index 5bc5cd7288..ecf4c9f33b 100644 --- a/mercurial-types/src/lib.rs +++ b/mercurial-types/src/lib.rs @@ -101,7 +101,7 @@ pub use delta::Delta; pub use fsencode::{fncache_fsencode, simple_fsencode}; pub use manifest::{Entry, Manifest, Type}; pub use node::Node; -pub use nodehash::{DChangesetId, DNodeHash, EntryId, HgFileNodeId, HgManifestId, D_NULL_HASH}; +pub use nodehash::{DChangesetId, DManifestId, DNodeHash, EntryId, HgFileNodeId, D_NULL_HASH}; pub use repo::RepositoryId; pub use utils::percent_encode; diff --git a/mercurial-types/src/nodehash.rs b/mercurial-types/src/nodehash.rs index 7dc385c816..74bd3a607b 100644 --- a/mercurial-types/src/nodehash.rs +++ b/mercurial-types/src/nodehash.rs @@ -17,7 +17,7 @@ use quickcheck::{single_shrinker, Arbitrary, Gen}; use errors::*; use hash::{self, Sha1}; use serde; -use sql_types::{DChangesetIdSql, HgFileNodeIdSql, HgManifestIdSql}; +use sql_types::{DChangesetIdSql, DManifestIdSql, HgFileNodeIdSql}; pub const D_NULL_HASH: DNodeHash = DNodeHash(hash::NULL); pub const NULL_CSID: DChangesetId = DChangesetId(D_NULL_HASH); @@ -213,10 +213,10 @@ impl<'de> serde::de::Deserialize<'de> for DChangesetId { #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[derive(HeapSizeOf, FromSqlRow, AsExpression)] -#[sql_type = "HgManifestIdSql"] -pub struct HgManifestId(DNodeHash); +#[sql_type = "DManifestIdSql"] +pub struct DManifestId(DNodeHash); -impl HgManifestId { +impl DManifestId { #[inline] pub(crate) fn as_nodehash(&self) -> &DNodeHash { &self.0 @@ -227,11 +227,11 @@ impl HgManifestId { } pub const fn new(hash: DNodeHash) -> Self { - HgManifestId(hash) + DManifestId(hash) } } -impl Display for HgManifestId { +impl Display for DManifestId { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(fmt) } diff --git a/mercurial-types/src/sql_types.rs b/mercurial-types/src/sql_types.rs index bfe8e46c2b..62dc68902d 100644 --- a/mercurial-types/src/sql_types.rs +++ b/mercurial-types/src/sql_types.rs @@ -13,7 +13,7 @@ use diesel::deserialize::{self, FromSql}; use diesel::serialize::{self, IsNull, Output, ToSql}; use diesel::sql_types::{Binary, Integer}; -use {DChangesetId, DNodeHash, HgFileNodeId, HgManifestId, RepositoryId}; +use {DChangesetId, DManifestId, DNodeHash, HgFileNodeId, RepositoryId}; use errors::*; #[derive(QueryId, SqlType)] @@ -24,7 +24,7 @@ pub struct DChangesetIdSql; #[derive(QueryId, SqlType)] #[mysql_type = "Blob"] #[sqlite_type = "Binary"] -pub struct HgManifestIdSql; +pub struct DManifestIdSql; #[derive(QueryId, SqlType)] #[mysql_type = "Blob"] @@ -51,14 +51,14 @@ where } } -impl ToSql for HgManifestId { +impl ToSql for DManifestId { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_all(self.as_nodehash().0.as_ref())?; Ok(IsNull::No) } } -impl FromSql for HgManifestId +impl FromSql for DManifestId where *const [u8]: FromSql, { diff --git a/server/src/repo.rs b/server/src/repo.rs index cdc32e4eb1..c865916d88 100644 --- a/server/src/repo.rs +++ b/server/src/repo.rs @@ -37,7 +37,7 @@ use blobrepo::BlobChangeset; use bundle2_resolver; use mercurial::{self, NodeHashConversion, RevlogChangeset}; use mercurial_bundles::{parts, Bundle2EncodeBuilder, Bundle2Item}; -use mercurial_types::{percent_encode, Changeset, DChangesetId, DNodeHash, Entry, HgManifestId, +use mercurial_types::{percent_encode, Changeset, DChangesetId, DManifestId, DNodeHash, Entry, MPath, Parents, RepoPath, RepositoryId, Type, D_NULL_HASH}; use mercurial_types::manifest_utils::{changed_entry_stream, EntryStatus}; use metaconfig::repoconfig::RepoType; @@ -819,8 +819,7 @@ fn get_changed_entry_stream( }); // Append root manifest - let root_entry_stream = - stream::once(Ok((repo.get_root_entry(&HgManifestId::new(*mfid)), None))); + let root_entry_stream = stream::once(Ok((repo.get_root_entry(&DManifestId::new(*mfid)), None))); changed_entries.chain(root_entry_stream).boxify() }