From 03255529fa2b2881ffbc076f80cd56748ed39474 Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Mon, 16 Apr 2018 03:34:19 -0700 Subject: [PATCH] CODEMOD: rename mercurial::NodeHash to HgNodeHash Reviewed By: sid0 Differential Revision: D7619973 fbshipit-source-id: 229fea891788c33eb1f45446ba2333e945ca5553 --- bundle2-resolver/src/changegroup/changeset.rs | 28 +++--- bundle2-resolver/src/changegroup/filelog.rs | 26 +++--- bundle2-resolver/src/resolver.rs | 10 +-- bundle2-resolver/src/wirepackparser.rs | 16 ++-- cmds/blobimport/convert.rs | 36 ++++---- cmds/blobimport/manifest.rs | 4 +- cmds/new_blobimport/main.rs | 14 +-- hgproto/src/commands.rs | 22 ++--- hgproto/src/lib.rs | 20 ++--- hgproto/src/sshproto/request.rs | 18 ++-- mercurial-bundles/src/changegroup/mod.rs | 12 +-- mercurial-bundles/src/changegroup/unpacker.rs | 10 +-- mercurial-bundles/src/parts/mod.rs | 12 +-- mercurial-bundles/src/quickcheck_types.rs | 12 +-- mercurial-bundles/src/test.rs | 20 ++--- mercurial-bundles/src/utils.rs | 8 +- mercurial-bundles/src/wirepack/mod.rs | 26 +++--- .../src/wirepack/quickcheck_types.rs | 14 +-- mercurial-types/mocks/nodehash.rs | 2 +- mercurial-types/src/hash.rs | 1 - mercurial-types/src/lib.rs | 2 +- mercurial-types/src/nodehash.rs | 8 +- mercurial/src/blobnode.rs | 30 +++---- mercurial/src/changeset/mod.rs | 4 +- mercurial/src/changeset/test.rs | 20 ++--- mercurial/src/lib.rs | 4 +- mercurial/src/manifest/revlog.rs | 4 +- mercurial/src/mocks.rs | 32 +++---- mercurial/src/nodehash.rs | 90 +++++++++---------- mercurial/src/revlog/mod.rs | 20 ++--- mercurial/src/revlog/parser.rs | 10 +-- mercurial/src/revlogrepo.rs | 12 +-- mercurial/src/sql_types.rs | 6 +- server/src/repo.rs | 18 ++-- 34 files changed, 278 insertions(+), 293 deletions(-) diff --git a/bundle2-resolver/src/changegroup/changeset.rs b/bundle2-resolver/src/changegroup/changeset.rs index 36ce7ab590..82fbb50af0 100644 --- a/bundle2-resolver/src/changegroup/changeset.rs +++ b/bundle2-resolver/src/changegroup/changeset.rs @@ -8,7 +8,7 @@ use futures::Stream; use futures_ext::{BoxStream, StreamExt}; use bytes::Bytes; -use mercurial::{BlobNode, NodeHash, NULL_HASH}; +use mercurial::{BlobNode, HgNodeHash, NULL_HASH}; use mercurial::changeset::RevlogChangeset; use mercurial_bundles::changegroup::CgDeltaChunk; use mercurial_types::{delta, HgBlob}; @@ -20,7 +20,9 @@ pub struct ChangesetDeltaed { pub chunk: CgDeltaChunk, } -pub fn convert_to_revlog_changesets(deltaed: S) -> BoxStream<(NodeHash, RevlogChangeset), Error> +pub fn convert_to_revlog_changesets( + deltaed: S, +) -> BoxStream<(HgNodeHash, RevlogChangeset), Error> where S: Stream + Send + 'static, { @@ -67,11 +69,11 @@ mod tests { use self::CheckResult::*; fn check_null_changeset( - node: NodeHash, - linknode: NodeHash, - base: NodeHash, - p1: NodeHash, - p2: NodeHash, + node: HgNodeHash, + linknode: HgNodeHash, + base: HgNodeHash, + p1: HgNodeHash, + p2: HgNodeHash, ) -> CheckResult { let blobnode = BlobNode::new( RevlogChangeset::new_null() @@ -108,11 +110,11 @@ mod tests { quickcheck!{ fn null_changeset_random( - node: NodeHash, - linknode: NodeHash, - base: NodeHash, - p1: NodeHash, - p2: NodeHash + node: HgNodeHash, + linknode: HgNodeHash, + base: HgNodeHash, + p1: HgNodeHash, + p2: HgNodeHash ) -> bool { match check_null_changeset(node, linknode, base, p1, p2) { ExpectedOk(true) | ExpectedErr(true) => true, @@ -120,7 +122,7 @@ mod tests { } } - fn null_changeset_correct(node: NodeHash, p1: NodeHash, p2: NodeHash) -> bool { + fn null_changeset_correct(node: HgNodeHash, p1: HgNodeHash, p2: HgNodeHash) -> bool { match check_null_changeset(node.clone(), node, NULL_HASH, p1, p2) { ExpectedOk(true) => true, _ => false diff --git a/bundle2-resolver/src/changegroup/filelog.rs b/bundle2-resolver/src/changegroup/filelog.rs index 880381a9c5..0637882754 100644 --- a/bundle2-resolver/src/changegroup/filelog.rs +++ b/bundle2-resolver/src/changegroup/filelog.rs @@ -17,7 +17,7 @@ use heapsize::HeapSizeOf; use quickcheck::{Arbitrary, Gen}; use blobrepo::{BlobEntry, BlobRepo}; -use mercurial; +use mercurial::{self, HgNodeHash}; use mercurial_bundles::changegroup::CgDeltaChunk; use mercurial_types::{delta, manifest, Delta, FileType, HgBlob, MPath, RepoPath}; @@ -34,9 +34,9 @@ pub struct FilelogDeltaed { #[derive(Debug, Clone, Eq, PartialEq)] pub struct Filelog { pub node_key: mercurial::HgNodeKey, - pub p1: Option, - pub p2: Option, - pub linknode: mercurial::NodeHash, + pub p1: Option, + pub p2: Option, + pub linknode: HgNodeHash, pub data: Bytes, } @@ -95,7 +95,7 @@ where struct DeltaCache { repo: Arc, - bytes_cache: HashMap>>>, + bytes_cache: HashMap>>>, } impl DeltaCache { @@ -108,8 +108,8 @@ impl DeltaCache { fn decode( &mut self, - node: mercurial::NodeHash, - base: Option, + node: HgNodeHash, + base: Option, delta: Delta, ) -> BoxFuture { let bytes = match self.bytes_cache.get(&node).cloned() { @@ -169,11 +169,11 @@ impl Arbitrary for Filelog { Filelog { node_key: mercurial::HgNodeKey { path: RepoPath::FilePath(MPath::arbitrary(g)), - hash: mercurial::NodeHash::arbitrary(g), + hash: HgNodeHash::arbitrary(g), }, - p1: mercurial::NodeHash::arbitrary(g).into_option(), - p2: mercurial::NodeHash::arbitrary(g).into_option(), - linknode: mercurial::NodeHash::arbitrary(g), + p1: HgNodeHash::arbitrary(g).into_option(), + p2: HgNodeHash::arbitrary(g).into_option(), + linknode: HgNodeHash::arbitrary(g), data: Bytes::from(Vec::::arbitrary(g)), } } @@ -245,13 +245,13 @@ mod tests { } } - fn next(&mut self) -> mercurial::NodeHash { + fn next(&mut self) -> HgNodeHash { for i in 0..self.bytes.len() { if self.bytes[i] == 255 { self.bytes[i] = 0; } else { self.bytes[i] = self.bytes[i] + 1; - return mercurial::NodeHash::from_bytes(self.bytes.as_slice()).unwrap(); + return HgNodeHash::from_bytes(self.bytes.as_slice()).unwrap(); } } diff --git a/bundle2-resolver/src/resolver.rs b/bundle2-resolver/src/resolver.rs index ba0b40b934..c8ce35e455 100644 --- a/bundle2-resolver/src/resolver.rs +++ b/bundle2-resolver/src/resolver.rs @@ -16,7 +16,7 @@ use futures::{Future, IntoFuture, Stream}; use futures::future::{err, ok}; use futures::stream; use futures_ext::{BoxFuture, BoxStream, FutureExt, StreamExt}; -use mercurial; +use mercurial::{self, HgNodeHash}; use mercurial::changeset::RevlogChangeset; use mercurial::manifest::ManifestContent; use mercurial_bundles::{parts, Bundle2EncodeBuilder, Bundle2Item}; @@ -30,10 +30,10 @@ use upload_blobs::{upload_hg_blobs, UploadBlobsType, UploadableHgBlob}; use wirepackparser::{TreemanifestBundle2Parser, TreemanifestEntry}; type PartId = u32; -type Changesets = Vec<(mercurial::NodeHash, RevlogChangeset)>; +type Changesets = Vec<(HgNodeHash, RevlogChangeset)>; type Filelogs = HashMap::Value>; type Manifests = HashMap::Value>; -type UploadedChangesets = HashMap; +type UploadedChangesets = HashMap; /// The resolve function takes a bundle2, interprets it's content as Changesets, Filelogs and /// Manifests and uploades all of them to the provided BlobRepo in the correct order. @@ -334,7 +334,7 @@ impl Bundle2Resolver { ) -> BoxFuture<(), Error> { fn upload_changeset( repo: Arc, - node: mercurial::NodeHash, + node: HgNodeHash, revlog_cs: RevlogChangeset, mut uploaded_changesets: UploadedChangesets, filelogs: &Filelogs, @@ -455,7 +455,7 @@ impl Bundle2Resolver { fn get_parent( repo: &BlobRepo, map: &UploadedChangesets, - p: Option, + p: Option, ) -> BoxFuture, Error> { match p { None => ok(None).boxify(), diff --git a/bundle2-resolver/src/wirepackparser.rs b/bundle2-resolver/src/wirepackparser.rs index 7de9c3426f..6993a55f7f 100644 --- a/bundle2-resolver/src/wirepackparser.rs +++ b/bundle2-resolver/src/wirepackparser.rs @@ -14,7 +14,7 @@ use futures::future::Shared; use futures_ext::{BoxFuture, FutureExt}; use blobrepo::{BlobEntry, BlobRepo}; -use mercurial; +use mercurial::{self, HgNodeHash}; use mercurial::manifest::ManifestContent; use mercurial_bundles::wirepack::{DataEntry, HistoryEntry, Part}; use mercurial_bundles::wirepack::converter::{WirePackConverter, WirePackPartProcessor}; @@ -60,8 +60,8 @@ where pub struct TreemanifestEntry { pub node_key: mercurial::HgNodeKey, pub data: Bytes, - pub p1: Option, - pub p2: Option, + pub p1: Option, + pub p2: Option, pub manifest_content: ManifestContent, } @@ -69,8 +69,8 @@ impl TreemanifestEntry { fn new( node_key: mercurial::HgNodeKey, data: Bytes, - p1: mercurial::NodeHash, - p2: mercurial::NodeHash, + p1: HgNodeHash, + p2: HgNodeHash, ) -> Result { let manifest_content = ManifestContent::parse(data.as_ref())?; @@ -114,9 +114,9 @@ impl UploadableHgBlob for TreemanifestEntry { } struct TreemanifestPartProcessor { - node: Option, - p1: Option, - p2: Option, + node: Option, + p1: Option, + p2: Option, path: Option, } diff --git a/cmds/blobimport/convert.rs b/cmds/blobimport/convert.rs index 83ef66809c..dcb5dfcc2c 100644 --- a/cmds/blobimport/convert.rs +++ b/cmds/blobimport/convert.rs @@ -22,7 +22,7 @@ use filenodes::FilenodeInfo; use futures::sync::mpsc::UnboundedSender; use futures_ext::{BoxFuture, BoxStream, FutureExt, StreamExt}; use heads::Heads; -use mercurial::{self, RevlogManifest, RevlogRepo}; +use mercurial::{self, HgNodeHash, RevlogManifest, RevlogRepo}; use mercurial::revlog::RevIdx; use mercurial::revlogrepo::RevlogRepoBlobimportExt; use mercurial_types::{DBlobNode, DFileNodeId, HgBlob, RepoPath, RepositoryId}; @@ -59,19 +59,18 @@ where let skip = self.skip; let commits_limit = self.commits_limit; - let changesets: BoxStream = if let Some(skip) = skip - { + let changesets: BoxStream = if let Some(skip) = skip { self.repo.changesets().skip(skip).boxify() } else { self.repo.changesets().boxify() }; - let changesets: BoxStream = - if let Some(limit) = commits_limit { - changesets.take(limit).boxify() - } else { - changesets.boxify() - }; + let changesets: BoxStream = if let Some(limit) = commits_limit + { + changesets.take(limit).boxify() + } else { + changesets.boxify() + }; // Generate stream of changesets. For each changeset, save the cs blob, and the manifest // blob, and the files. @@ -148,13 +147,12 @@ where .boxify() } - fn get_changesets_stream(&self) -> BoxStream { - let changesets: BoxStream = - if let Some(skip) = self.skip { - self.repo.changesets().skip(skip).boxify() - } else { - self.repo.changesets().boxify() - }; + fn get_changesets_stream(&self) -> BoxStream { + let changesets: BoxStream = if let Some(skip) = self.skip { + self.repo.changesets().skip(skip).boxify() + } else { + self.repo.changesets().boxify() + }; if let Some(limit) = self.commits_limit { changesets.take(limit).boxify() @@ -231,7 +229,7 @@ fn put_blobs( revlog_repo: RevlogRepo, sender: SyncSender, filenodes: UnboundedSender, - mfid: mercurial::NodeHash, + mfid: HgNodeHash, linkrev: RevIdx, ) -> impl Future + Send + 'static { let cs_entry_fut = revlog_repo @@ -317,10 +315,10 @@ fn put_blobs( fn create_filenode( blob: HgBlob, - filenode_hash: mercurial::NodeHash, + filenode_hash: HgNodeHash, parents: mercurial::Parents, repopath: RepoPath, - linknode: mercurial::NodeHash, + linknode: HgNodeHash, ) -> FilenodeInfo { let (p1, p2) = parents.get_nodes(); let p1 = p1.map(|p| p.into_mononoke()); diff --git a/cmds/blobimport/manifest.rs b/cmds/blobimport/manifest.rs index e3eb143efc..68914ece11 100644 --- a/cmds/blobimport/manifest.rs +++ b/cmds/blobimport/manifest.rs @@ -15,7 +15,7 @@ use futures::{self, stream, Future, IntoFuture, Stream}; use blobrepo::RawNodeBlob; use futures_ext::StreamExt; -use mercurial::{self, RevlogEntry, RevlogRepo}; +use mercurial::{self, HgNodeHash, RevlogEntry, RevlogRepo}; use mercurial::revlog::RevIdx; use mercurial::revlogrepo::RevlogRepoBlobimportExt; use mercurial_types::{DParents, HgBlob, HgBlobHash, MPath, RepoPath, Type}; @@ -24,7 +24,7 @@ use BlobstoreEntry; pub(crate) fn put_entry( sender: SyncSender, - entry_hash: mercurial::NodeHash, + entry_hash: HgNodeHash, blob: HgBlob, parents: mercurial::Parents, ) -> impl Future + Send + 'static diff --git a/cmds/new_blobimport/main.rs b/cmds/new_blobimport/main.rs index 29f0c4eb41..d36f174689 100644 --- a/cmds/new_blobimport/main.rs +++ b/cmds/new_blobimport/main.rs @@ -39,19 +39,12 @@ use tokio_core::reactor::Core; use blobrepo::{BlobEntry, BlobRepo, ChangesetHandle}; use changesets::SqliteChangesets; -use mercurial::{RevlogChangeset, RevlogEntry, RevlogRepo}; +use mercurial::{HgNodeHash, RevlogChangeset, RevlogEntry, RevlogRepo}; use mercurial_types::{HgBlob, MPath, RepoPath, RepositoryId, Type}; struct ParseChangeset { revlogcs: BoxFuture, Error>, - rootmf: BoxFuture< - ( - HgBlob, - Option, - Option, - ), - Error, - >, + rootmf: BoxFuture<(HgBlob, Option, Option), Error>, entries: BoxStream<(Option, RevlogEntry), Error>, } @@ -285,8 +278,7 @@ fn main() { bad => panic!("unexpected blobstore type: {}", bad), }; - let mut parent_changeset_handles: HashMap = - HashMap::new(); + let mut parent_changeset_handles: HashMap = HashMap::new(); let csstream = revlogrepo .changesets() diff --git a/hgproto/src/commands.rs b/hgproto/src/commands.rs index ade8f788fb..10f0fa5b7c 100644 --- a/hgproto/src/commands.rs +++ b/hgproto/src/commands.rs @@ -22,9 +22,9 @@ use futures::future::{self, err, ok, Either, Future}; use futures::stream::{self, futures_ordered, once, Stream}; use futures::sync::oneshot; +use HgNodeHash; use dechunker::Dechunker; use futures_ext::{BoxFuture, BoxStream, BytesStream, FutureExt, StreamExt}; -use mercurial::NodeHash; use mercurial_bundles::Bundle2Item; use mercurial_bundles::bundle2::{self, Bundle2Stream, StreamEvent}; use mercurial_types::MPath; @@ -253,7 +253,7 @@ struct GetfilesArgDecoder {} // Parses one (hash, path) pair impl Decoder for GetfilesArgDecoder { // If None has been decoded, then that means that client has sent all the data - type Item = Option<(NodeHash, MPath)>; + type Item = Option<(HgNodeHash, MPath)>; type Error = Error; fn decode(&mut self, src: &mut BytesMut) -> Result> { @@ -290,7 +290,7 @@ impl Decoder for GetfilesArgDecoder { Err(err_msg("Expected non-empty file")) } else { let nodehashstr = String::from_utf8(nodehashbytes.to_vec())?; - let nodehash = NodeHash::from_str(&nodehashstr)?; + let nodehash = HgNodeHash::from_str(&nodehashstr)?; // Some here means that new entry has been parsed let parsed_res = Some((nodehash, MPath::new(&buf)?)); // 'Ok' means no error, 'Some' means that no more bytes needed. @@ -310,7 +310,7 @@ impl Decoder for GetfilesArgDecoder { fn decode_getfiles_arg_stream( input: BytesStream, ) -> ( - BoxStream<(NodeHash, MPath), Error>, + BoxStream<(HgNodeHash, MPath), Error>, BoxFuture, Error>, ) where @@ -453,12 +453,12 @@ pub type HgCommandRes = BoxFuture; // TODO: placeholder types are generally `()` pub trait HgCommands { // @wireprotocommand('between', 'pairs') - fn between(&self, _pairs: Vec<(NodeHash, NodeHash)>) -> HgCommandRes>> { + fn between(&self, _pairs: Vec<(HgNodeHash, HgNodeHash)>) -> HgCommandRes>> { unimplemented("between") } // @wireprotocommand('branchmap') - fn branchmap(&self) -> HgCommandRes>> { + fn branchmap(&self) -> HgCommandRes>> { // We have no plans to support mercurial branches and hence no plans for branchmap, // so just return fake response. future::ok(HashMap::new()).boxify() @@ -476,7 +476,7 @@ pub trait HgCommands { } // @wireprotocommand('heads') - fn heads(&self) -> HgCommandRes> { + fn heads(&self) -> HgCommandRes> { unimplemented("heads") } @@ -496,7 +496,7 @@ pub trait HgCommands { } // @wireprotocommand('known', 'nodes *') - fn known(&self, _nodes: Vec) -> HgCommandRes> { + fn known(&self, _nodes: Vec) -> HgCommandRes> { unimplemented("known") } @@ -515,7 +515,7 @@ pub trait HgCommands { } // @wireprotocommand('getfiles', 'files*') - fn getfiles(&self, _params: BoxStream<(NodeHash, MPath), Error>) -> BoxStream { + fn getfiles(&self, _params: BoxStream<(HgNodeHash, MPath), Error>) -> BoxStream { once(Err(ErrorKind::Unimplemented("getfiles".into()).into())).boxify() } } @@ -542,11 +542,11 @@ mod test { vs.into_iter().next().unwrap() } - fn hash_ones() -> NodeHash { + fn hash_ones() -> HgNodeHash { "1111111111111111111111111111111111111111".parse().unwrap() } - fn hash_twos() -> NodeHash { + fn hash_twos() -> HgNodeHash { "2222222222222222222222222222222222222222".parse().unwrap() } diff --git a/hgproto/src/lib.rs b/hgproto/src/lib.rs index 2202b2ba41..60c25812c7 100644 --- a/hgproto/src/lib.rs +++ b/hgproto/src/lib.rs @@ -48,7 +48,7 @@ use std::fmt::{self, Debug}; use bytes::Bytes; -use mercurial::NodeHash; +use mercurial::HgNodeHash; mod batch; mod dechunker; @@ -66,7 +66,7 @@ pub enum Request { #[derive(Debug, Eq, PartialEq)] pub enum SingleRequest { Between { - pairs: Vec<(NodeHash, NodeHash)>, + pairs: Vec<(HgNodeHash, HgNodeHash)>, }, Branchmap, Capabilities, @@ -85,7 +85,7 @@ pub enum SingleRequest { key: String, }, Known { - nodes: Vec, + nodes: Vec, }, Unbundle { heads: Vec, @@ -98,8 +98,8 @@ pub enum SingleRequest { /// the convenience of callers. #[derive(Eq, PartialEq)] pub struct GetbundleArgs { - pub heads: Vec, - pub common: Vec, + pub heads: Vec, + pub common: Vec, pub bundlecaps: Vec>, pub listkeys: Vec>, } @@ -131,9 +131,9 @@ pub struct GettreepackArgs { /// "root of the repo". pub rootdir: Bytes, /// The manifest nodes of the specified root directory to send. - pub mfnodes: Vec, + pub mfnodes: Vec, /// The manifest nodes of the rootdir that are already on the client. - pub basemfnodes: Vec, + pub basemfnodes: Vec, /// The fullpath (not relative path) of directories underneath /// the rootdir that should be sent. pub directories: Vec, @@ -147,12 +147,12 @@ pub enum Response { #[derive(Debug)] pub enum SingleResponse { - Between(Vec>), - Branchmap(HashMap>), + Between(Vec>), + Branchmap(HashMap>), Capabilities(Vec), Debugwireargs(Bytes), Getbundle(Bytes), - Heads(HashSet), + Heads(HashSet), Hello(HashMap>), Listkeys(HashMap, Vec>), Lookup(Bytes), diff --git a/hgproto/src/sshproto/request.rs b/hgproto/src/sshproto/request.rs index e42db753f1..1f8b8e8ea2 100644 --- a/hgproto/src/sshproto/request.rs +++ b/hgproto/src/sshproto/request.rs @@ -11,7 +11,7 @@ use std::str::{self, FromStr}; use bytes::{Bytes, BytesMut}; use nom::{is_alphanumeric, is_digit, ErrorKind, FindSubstring, IResult, Needed, Slice}; -use mercurial::NodeHash; +use HgNodeHash; use {GetbundleArgs, GettreepackArgs, Request, SingleRequest}; use batch; @@ -166,25 +166,25 @@ named_args!(batch_params(_count: usize), Vec>>, /// A nodehash is simply 40 hex digits. named!( - nodehash, + nodehash, map_res!(take!(40), |v: &[u8]| str::parse(str::from_utf8(v)?)) ); /// A pair of nodehashes, separated by '-' named!( - pair<(NodeHash, NodeHash)>, + pair<(HgNodeHash, HgNodeHash)>, do_parse!(a: nodehash >> tag!("-") >> b: nodehash >> ((a, b))) ); /// A space-separated list of pairs. named!( - pairlist>, + pairlist>, separated_list_complete!(tag!(" "), pair) ); /// A space-separated list of node hashes named!( - hashlist>, + hashlist>, separated_list_complete!(tag!(" "), nodehash) ); @@ -972,19 +972,19 @@ mod test_parse { use super::*; use std::fmt::Debug; - fn hash_ones() -> NodeHash { + fn hash_ones() -> HgNodeHash { "1111111111111111111111111111111111111111".parse().unwrap() } - fn hash_twos() -> NodeHash { + fn hash_twos() -> HgNodeHash { "2222222222222222222222222222222222222222".parse().unwrap() } - fn hash_threes() -> NodeHash { + fn hash_threes() -> HgNodeHash { "3333333333333333333333333333333333333333".parse().unwrap() } - fn hash_fours() -> NodeHash { + fn hash_fours() -> HgNodeHash { "4444444444444444444444444444444444444444".parse().unwrap() } diff --git a/mercurial-bundles/src/changegroup/mod.rs b/mercurial-bundles/src/changegroup/mod.rs index 49489c99a1..21fccd0033 100644 --- a/mercurial-bundles/src/changegroup/mod.rs +++ b/mercurial-bundles/src/changegroup/mod.rs @@ -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 mercurial::NodeHash; +use mercurial::HgNodeHash; use mercurial_types::{Delta, MPath}; pub mod packer; @@ -35,11 +35,11 @@ impl Part { #[derive(Clone, Debug, Eq, PartialEq)] pub struct CgDeltaChunk { - pub node: NodeHash, - pub p1: NodeHash, - pub p2: NodeHash, - pub base: NodeHash, - pub linknode: NodeHash, + pub node: HgNodeHash, + pub p1: HgNodeHash, + pub p2: HgNodeHash, + pub base: HgNodeHash, + pub linknode: HgNodeHash, pub delta: Delta, } diff --git a/mercurial-bundles/src/changegroup/unpacker.rs b/mercurial-bundles/src/changegroup/unpacker.rs index 906cfadfd7..b66896fc2d 100644 --- a/mercurial-bundles/src/changegroup/unpacker.rs +++ b/mercurial-bundles/src/changegroup/unpacker.rs @@ -191,11 +191,11 @@ impl Cg2Unpacker { // A chunk header has: // --- - // node: NodeHash (20 bytes) - // p1: NodeHash (20 bytes) - // p2: NodeHash (20 bytes) -- NULL_HASH if only 1 parent - // base node: NodeHash (20 bytes) (new in changegroup2) - // link node: NodeHash (20 bytes) + // node: HgNodeHash (20 bytes) + // p1: HgNodeHash (20 bytes) + // p2: HgNodeHash (20 bytes) -- NULL_HASH if only 1 parent + // base node: HgNodeHash (20 bytes) (new in changegroup2) + // link node: HgNodeHash (20 bytes) // --- let node = buf.drain_node(); diff --git a/mercurial-bundles/src/parts/mod.rs b/mercurial-bundles/src/parts/mod.rs index a4dfa3ae51..eb3bf7e567 100644 --- a/mercurial-bundles/src/parts/mod.rs +++ b/mercurial-bundles/src/parts/mod.rs @@ -17,7 +17,7 @@ use super::wirepack; use super::wirepack::packer::WirePackPacker; use errors::*; -use mercurial::{BlobNode, NodeHash, NULL_HASH}; +use mercurial::{BlobNode, HgNodeHash, NULL_HASH}; use mercurial_types::{Delta, MPath, MPathElement, RepoPath}; use part_encode::PartEncodeBuilder; use part_header::PartHeaderType; @@ -50,7 +50,7 @@ where pub fn changegroup_part(changelogentries: S) -> Result where - S: Stream + Send + 'static, + S: Stream + Send + 'static, { let mut builder = PartEncodeBuilder::mandatory(PartHeaderType::Changegroup)?; builder.add_mparam("version", "02")?; @@ -95,12 +95,12 @@ where } pub struct TreepackPartInput { - pub node: NodeHash, - pub p1: Option, - pub p2: Option, + pub node: HgNodeHash, + pub p1: Option, + pub p2: Option, pub content: Bytes, pub name: Option, - pub linknode: NodeHash, + pub linknode: HgNodeHash, pub basepath: Option, } diff --git a/mercurial-bundles/src/quickcheck_types.rs b/mercurial-bundles/src/quickcheck_types.rs index c5dd799d90..f5a8876aab 100644 --- a/mercurial-bundles/src/quickcheck_types.rs +++ b/mercurial-bundles/src/quickcheck_types.rs @@ -19,7 +19,7 @@ use bytes::Bytes; use futures::stream; use quickcheck::{empty_shrinker, Arbitrary, Gen}; -use mercurial::NodeHash; +use mercurial::HgNodeHash; use mercurial_types::{Delta, MPath}; use changegroup; @@ -192,11 +192,11 @@ impl Arbitrary for changegroup::CgDeltaChunk { fn arbitrary(g: &mut G) -> Self { // TODO: should these be more structured? e.g. base = p1 some of the time changegroup::CgDeltaChunk { - node: NodeHash::arbitrary(g), - p1: NodeHash::arbitrary(g), - p2: NodeHash::arbitrary(g), - base: NodeHash::arbitrary(g), - linknode: NodeHash::arbitrary(g), + node: HgNodeHash::arbitrary(g), + p1: HgNodeHash::arbitrary(g), + p2: HgNodeHash::arbitrary(g), + base: HgNodeHash::arbitrary(g), + linknode: HgNodeHash::arbitrary(g), delta: Delta::arbitrary(g), } } diff --git a/mercurial-bundles/src/test.rs b/mercurial-bundles/src/test.rs index 28befb20fa..1cfc2c5e19 100644 --- a/mercurial-bundles/src/test.rs +++ b/mercurial-bundles/src/test.rs @@ -20,7 +20,7 @@ use tokio_io::AsyncRead; use async_compression::{Bzip2Compression, CompressorType, FlateCompression}; use async_compression::membuf::MemBuf; -use mercurial::{NodeHash, NULL_HASH}; +use mercurial::{HgNodeHash, NULL_HASH}; use mercurial_types::{MPath, RepoPath}; use partial_io::{GenWouldBlock, PartialAsyncRead, PartialWithErrors}; use quickcheck::{QuickCheck, StdGen}; @@ -253,7 +253,7 @@ fn verify_cg2(core: &mut Core, stream: BoxStream) { let chunk = res.chunk(); // Verify that changesets parsed correctly. - let changeset1_hash = NodeHash::from_str(CHANGESET1_HASH_STR).unwrap(); + let changeset1_hash = HgNodeHash::from_str(CHANGESET1_HASH_STR).unwrap(); assert_eq!(chunk.node, changeset1_hash); assert_eq!(chunk.p1, NULL_HASH); assert_eq!(chunk.p2, NULL_HASH); @@ -271,7 +271,7 @@ fn verify_cg2(core: &mut Core, stream: BoxStream) { assert_eq!(*res.section(), changegroup::Section::Changeset); let chunk = res.chunk(); - let changeset2_hash = NodeHash::from_str(CHANGESET2_HASH_STR).unwrap(); + let changeset2_hash = HgNodeHash::from_str(CHANGESET2_HASH_STR).unwrap(); assert_eq!(chunk.node, changeset2_hash); assert_eq!(chunk.p1, changeset1_hash); assert_eq!(chunk.p2, NULL_HASH); @@ -298,7 +298,7 @@ fn verify_cg2(core: &mut Core, stream: BoxStream) { assert_eq!(*res.section(), changegroup::Section::Manifest); let chunk = res.chunk(); - let manifest1_hash = NodeHash::from_str(MANIFEST1_HASH_STR).unwrap(); + let manifest1_hash = HgNodeHash::from_str(MANIFEST1_HASH_STR).unwrap(); assert_eq!(chunk.node, manifest1_hash); assert_eq!(chunk.p1, NULL_HASH); assert_eq!(chunk.p2, NULL_HASH); @@ -311,7 +311,7 @@ fn verify_cg2(core: &mut Core, stream: BoxStream) { assert_eq!(*res.section(), changegroup::Section::Manifest); let chunk = res.chunk(); - let manifest2_hash = NodeHash::from_str(MANIFEST2_HASH_STR).unwrap(); + let manifest2_hash = HgNodeHash::from_str(MANIFEST2_HASH_STR).unwrap(); assert_eq!(chunk.node, manifest2_hash); assert_eq!(chunk.p1, manifest1_hash); assert_eq!(chunk.p2, NULL_HASH); @@ -333,7 +333,7 @@ fn verify_cg2(core: &mut Core, stream: BoxStream) { assert_eq!(*res.section(), changegroup::Section::Filelog(path(b"abc"))); let chunk = res.chunk(); - let abch = NodeHash::from_str(ABC_HASH_STR).unwrap(); + let abch = HgNodeHash::from_str(ABC_HASH_STR).unwrap(); assert_eq!(chunk.node, abch); assert_eq!(chunk.p1, NULL_HASH); assert_eq!(chunk.p2, NULL_HASH); @@ -354,7 +354,7 @@ fn verify_cg2(core: &mut Core, stream: BoxStream) { assert_eq!(*res.section(), changegroup::Section::Filelog(path(b"def"))); let chunk = res.chunk(); - let defh = NodeHash::from_str(DEF_HASH_STR).unwrap(); + let defh = HgNodeHash::from_str(DEF_HASH_STR).unwrap(); assert_eq!(chunk.node, defh); assert_eq!(chunk.p1, NULL_HASH); assert_eq!(chunk.p2, NULL_HASH); @@ -428,9 +428,9 @@ fn parse_wirepack(read_ops: PartialWithErrors) { // These are a few identifiers present in the bundle. let baz_dir = RepoPath::dir("baz").unwrap(); - let baz_hash = NodeHash::from_str("dcb9fa4bb7cdb673cd5752088b48d4c3f9c1fc23").unwrap(); - let root_hash = NodeHash::from_str("7d315c7a04cce5404f7ef16bf55eb7f4e90d159f").unwrap(); - let root_p1 = NodeHash::from_str("e313fc172615835d205f5881f8f34dd9bb0f0092").unwrap(); + let baz_hash = HgNodeHash::from_str("dcb9fa4bb7cdb673cd5752088b48d4c3f9c1fc23").unwrap(); + let root_hash = HgNodeHash::from_str("7d315c7a04cce5404f7ef16bf55eb7f4e90d159f").unwrap(); + let root_p1 = HgNodeHash::from_str("e313fc172615835d205f5881f8f34dd9bb0f0092").unwrap(); let (res, wirepacks) = core.next_stream(wirepacks); let res = res.expect("expected part"); diff --git a/mercurial-bundles/src/utils.rs b/mercurial-bundles/src/utils.rs index 94f31908a9..d44d4705b8 100644 --- a/mercurial-bundles/src/utils.rs +++ b/mercurial-bundles/src/utils.rs @@ -13,7 +13,7 @@ use byteorder::{BigEndian, ByteOrder}; use bytes::{Bytes, BytesMut}; use async_compression::{CompressorType, DecompressorType}; -use mercurial::NodeHash; +use mercurial::HgNodeHash; use mercurial_types::MPath; use errors::*; @@ -44,7 +44,7 @@ pub trait BytesExt { fn drain_i32(&mut self) -> i32; fn drain_str(&mut self, len: usize) -> Result; fn drain_path(&mut self, len: usize) -> Result; - fn drain_node(&mut self) -> NodeHash; + fn drain_node(&mut self) -> HgNodeHash; fn peek_u16(&self) -> u16; fn peek_u32(&self) -> u32; fn peek_i32(&self) -> i32; @@ -94,10 +94,10 @@ where } #[inline] - fn drain_node(&mut self) -> NodeHash { + fn drain_node(&mut self) -> HgNodeHash { // This only fails if the size of input passed in isn't 20 // bytes. drain_to would have panicked in that case anyway. - NodeHash::from_bytes(self.split_to(20).as_ref()).unwrap() + HgNodeHash::from_bytes(self.split_to(20).as_ref()).unwrap() } #[inline] diff --git a/mercurial-bundles/src/wirepack/mod.rs b/mercurial-bundles/src/wirepack/mod.rs index 915e4cbbb5..a017d711ae 100644 --- a/mercurial-bundles/src/wirepack/mod.rs +++ b/mercurial-bundles/src/wirepack/mod.rs @@ -11,7 +11,7 @@ use std::fmt; use byteorder::{BigEndian, ByteOrder}; use bytes::{BufMut, BytesMut}; -use mercurial::{NodeHash, NULL_HASH}; +use mercurial::{HgNodeHash, NULL_HASH}; use mercurial_types::{Delta, RepoPath}; use delta; @@ -96,11 +96,11 @@ const DATA_HEADER_SIZE: usize = DATA_DELTA_OFFSET + 8; // TODO: move to mercurial-types #[derive(Clone, Debug, Eq, PartialEq)] pub struct HistoryEntry { - pub node: NodeHash, + pub node: HgNodeHash, // TODO: replace with Parents? - pub p1: NodeHash, - pub p2: NodeHash, - pub linknode: NodeHash, + pub p1: HgNodeHash, + pub p2: HgNodeHash, + pub linknode: HgNodeHash, pub copy_from: Option, } @@ -112,10 +112,10 @@ impl HistoryEntry { // A history revision has: // --- - // node: NodeHash (20 bytes) - // p1: NodeHash (20 bytes) - // p2: NodeHash (20 bytes) - // link node: NodeHash (20 bytes) + // node: HgNodeHash (20 bytes) + // p1: HgNodeHash (20 bytes) + // p2: HgNodeHash (20 bytes) + // link node: HgNodeHash (20 bytes) // copy from len: u16 (2 bytes) -- 0 if this revision is not a copy // copy from: RepoPath ( bytes) // --- @@ -218,8 +218,8 @@ impl HistoryEntry { #[derive(Clone, Debug, Eq, PartialEq)] pub struct DataEntry { - pub node: NodeHash, - pub delta_base: NodeHash, + pub node: HgNodeHash, + pub delta_base: HgNodeHash, pub delta: Delta, } @@ -231,8 +231,8 @@ impl DataEntry { // A data revision has: // --- - // node: NodeHash (20 bytes) - // delta base: NodeHash (20 bytes) -- NULL_HASH if full text + // node: HgNodeHash (20 bytes) + // delta base: HgNodeHash (20 bytes) -- NULL_HASH if full text // delta len: u64 (8 bytes) // delta: Delta ( bytes) // --- diff --git a/mercurial-bundles/src/wirepack/quickcheck_types.rs b/mercurial-bundles/src/wirepack/quickcheck_types.rs index 13ea834893..da3e846b16 100644 --- a/mercurial-bundles/src/wirepack/quickcheck_types.rs +++ b/mercurial-bundles/src/wirepack/quickcheck_types.rs @@ -8,7 +8,7 @@ use quickcheck::{Arbitrary, Gen}; -use mercurial::{NodeHash, NULL_HASH}; +use mercurial::{HgNodeHash, NULL_HASH}; use mercurial_types::{Delta, MPath, RepoPath}; use super::{DataEntry, HistoryEntry, Kind}; @@ -114,10 +114,10 @@ impl HistoryEntry { Kind::Tree => None, }; Self { - node: NodeHash::arbitrary(g), - p1: NodeHash::arbitrary(g), - p2: NodeHash::arbitrary(g), - linknode: NodeHash::arbitrary(g), + node: HgNodeHash::arbitrary(g), + p1: HgNodeHash::arbitrary(g), + p2: HgNodeHash::arbitrary(g), + linknode: HgNodeHash::arbitrary(g), copy_from: copy_from, } } @@ -140,12 +140,12 @@ impl Arbitrary for DataEntry { } else { let mut delta_base = NULL_HASH; while delta_base == NULL_HASH { - delta_base = NodeHash::arbitrary(g); + delta_base = HgNodeHash::arbitrary(g); } (delta_base, Delta::arbitrary(g)) }; Self { - node: NodeHash::arbitrary(g), + node: HgNodeHash::arbitrary(g), delta_base, delta, } diff --git a/mercurial-types/mocks/nodehash.rs b/mercurial-types/mocks/nodehash.rs index 89ae9d654b..a97caab7f3 100644 --- a/mercurial-types/mocks/nodehash.rs +++ b/mercurial-types/mocks/nodehash.rs @@ -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. -// Ignore deprecation of NodeHash::new +// Ignore deprecation of HgNodeHash::new #![allow(deprecated)] use mercurial_types::{DChangesetId, DFileNodeId, DManifestId, DNodeHash}; diff --git a/mercurial-types/src/hash.rs b/mercurial-types/src/hash.rs index ea59fa043f..c34a7a81d9 100644 --- a/mercurial-types/src/hash.rs +++ b/mercurial-types/src/hash.rs @@ -161,7 +161,6 @@ impl Context { } } - #[cfg(test)] mod test { use super::{Sha1, NULL}; diff --git a/mercurial-types/src/lib.rs b/mercurial-types/src/lib.rs index 6b505911c8..2520471791 100644 --- a/mercurial-types/src/lib.rs +++ b/mercurial-types/src/lib.rs @@ -27,7 +27,7 @@ //! //! Changesets, manifests and files are uniformly represented by a `Node`. A `Node` has //! 0-2 parents and some content. A node's identity is computed by hashing over (p1, p2, content), -//! resulting in `NodeHash` (TODO: rename NodeHash -> NodeId?). This means manifests and files +//! resulting in `HgNodeHash` (TODO: rename HgNodeHash -> NodeId?). This means manifests and files //! have a notion of history independent of the changeset(s) they're embedded in. //! //! Nodes are stored as blobs in the blobstore, but with their content in a separate blob. This diff --git a/mercurial-types/src/nodehash.rs b/mercurial-types/src/nodehash.rs index 05aa467b2a..9d7ba0d537 100644 --- a/mercurial-types/src/nodehash.rs +++ b/mercurial-types/src/nodehash.rs @@ -24,9 +24,9 @@ pub const NULL_CSID: DChangesetId = DChangesetId(D_NULL_HASH); /// This structure represents Sha1 based hashes that are used in Mononoke. It is a temporary /// structure that will be entirely replaced by structures from mononoke-types::typed_hash. -/// It's current distinction from mercurial::NodeHash serves two purposes: +/// It's current distinction from HgNodeHash serves two purposes: /// - make it relatively straightforward to replace it in future with typed_hash -/// - easily distinguish between the NodeHash values provided by Mercurial client that might +/// - easily distinguish between the HgNodeHash values provided by Mercurial client that might /// require remapping, f.e. hashes of Changeset and hashes of Root Manifests since the client /// provides Flat Manifest hashes as aliases for Root Manifest hashes #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] @@ -35,7 +35,7 @@ pub struct DNodeHash(pub(crate) Sha1); impl DNodeHash { #[deprecated(note = "This constructor is only used in two places: \ - conversion from mercurial NodeHash and creation of NodeHash mocks")] + conversion from mercurial HgNodeHash and creation of HgNodeHash mocks")] pub const fn new(sha1: Sha1) -> Self { DNodeHash(sha1) } @@ -63,7 +63,7 @@ impl DNodeHash { } #[deprecated(note = "This method is used only to have a \ - zero-cost conversion to mercurial::NodeHash")] + zero-cost conversion to HgNodeHash")] pub fn into_sha1(self) -> Sha1 { self.0 } diff --git a/mercurial/src/blobnode.rs b/mercurial/src/blobnode.rs index 5c7f1b7933..c9feeacb7a 100644 --- a/mercurial/src/blobnode.rs +++ b/mercurial/src/blobnode.rs @@ -7,18 +7,18 @@ use mercurial_types::HgBlob; use mercurial_types::hash::{self, Context}; -use nodehash::NodeHash; +use nodehash::HgNodeHash; #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[derive(Serialize, Deserialize, HeapSizeOf)] pub enum Parents { None, - One(NodeHash), - Two(NodeHash, NodeHash), + One(HgNodeHash), + Two(HgNodeHash, HgNodeHash), } impl Parents { - pub fn new(p1: Option<&NodeHash>, p2: Option<&NodeHash>) -> Self { + pub fn new(p1: Option<&HgNodeHash>, p2: Option<&HgNodeHash>) -> Self { match (p1, p2) { (None, None) => Parents::None, (Some(p1), None) => Parents::One(*p1), @@ -28,7 +28,7 @@ impl Parents { } } - pub fn get_nodes(&self) -> (Option<&NodeHash>, Option<&NodeHash>) { + pub fn get_nodes(&self) -> (Option<&HgNodeHash>, Option<&HgNodeHash>) { match self { &Parents::None => (None, None), &Parents::One(ref p1) => (Some(p1), None), @@ -39,7 +39,7 @@ impl Parents { impl<'a> IntoIterator for &'a Parents { type IntoIter = ParentIter; - type Item = NodeHash; + type Item = HgNodeHash; fn into_iter(self) -> ParentIter { ParentIter(*self) } @@ -49,7 +49,7 @@ impl<'a> IntoIterator for &'a Parents { pub struct ParentIter(Parents); impl Iterator for ParentIter { - type Item = NodeHash; + type Item = HgNodeHash; fn next(&mut self) -> Option { let (ret, new) = match self.0 { Parents::None => (None, Parents::None), @@ -81,7 +81,7 @@ impl BlobNode { /// parent that's copied. /// * If both p1 and p2 are None, it shouldn't really be possible to have copy info. But /// the Mercurial Python client tries to parse metadata anyway, so match that behavior. - pub fn new(blob: B, p1: Option<&NodeHash>, p2: Option<&NodeHash>) -> BlobNode + pub fn new(blob: B, p1: Option<&HgNodeHash>, p2: Option<&HgNodeHash>) -> BlobNode where B: Into, { @@ -112,7 +112,7 @@ impl BlobNode { // Annoyingly, filenode is defined as sha1(p1 || p2 || content), not // sha1(p1 || p2 || sha1(content)), so we can't compute a filenode for // a blob we don't have - pub fn nodeid(&self) -> Option { + pub fn nodeid(&self) -> Option { let null = hash::NULL; let (h1, h2) = match &self.parents { @@ -129,7 +129,7 @@ impl BlobNode { ctxt.update(h2); ctxt.update(data); - NodeHash(ctxt.finish()) + HgNodeHash(ctxt.finish()) }) } } @@ -153,19 +153,19 @@ mod test { let p = &BlobNode::new(blob.clone(), None, None); assert!(p.maybe_copied); { - let pid: Option = p.nodeid(); + let pid: Option = p.nodeid(); let n = BlobNode::new(blob.clone(), pid.as_ref(), None); assert_eq!(n.parents, Parents::One(pid.unwrap())); assert!(!n.maybe_copied); } { - let pid: Option = p.nodeid(); + let pid: Option = p.nodeid(); let n = BlobNode::new(blob.clone(), None, pid.as_ref()); assert_eq!(n.parents, Parents::One(pid.unwrap())); assert!(n.maybe_copied); } { - let pid: Option = p.nodeid(); + let pid: Option = p.nodeid(); let n = BlobNode::new(blob.clone(), pid.as_ref(), pid.as_ref()); assert_eq!(n.parents, Parents::One(pid.unwrap())); assert!(!n.maybe_copied); @@ -184,8 +184,8 @@ mod test { mem::swap(&mut p1, &mut p2); } - let pid1: Option = (&p1).nodeid(); - let pid2: Option = (&p2).nodeid(); + let pid1: Option = (&p1).nodeid(); + let pid2: Option = (&p2).nodeid(); let node1 = { let n = BlobNode::new( diff --git a/mercurial/src/changeset/mod.rs b/mercurial/src/changeset/mod.rs index 99d7852da5..b38067d2a9 100644 --- a/mercurial/src/changeset/mod.rs +++ b/mercurial/src/changeset/mod.rs @@ -15,7 +15,7 @@ use mercurial_types::MPath; use mercurial_types::changeset::Time; use blobnode::{BlobNode, Parents}; -use nodehash::{HgManifestId, NodeHash, NULL_HASH}; +use nodehash::{HgManifestId, HgNodeHash, NULL_HASH}; #[cfg(test)] mod test; @@ -242,7 +242,7 @@ impl RevlogChangeset { .ok_or(failure::err_msg("node has no data"))?; let mut lines = data.split(|b| *b == b'\n'); - let nodehash = parseline(&mut lines, |l| NodeHash::from_str(str::from_utf8(l)?)) + let nodehash = parseline(&mut lines, |l| HgNodeHash::from_str(str::from_utf8(l)?)) .context("can't get hash")?; ret.manifestid = HgManifestId::new(nodehash); ret.user = diff --git a/mercurial/src/changeset/test.rs b/mercurial/src/changeset/test.rs index 85c97e38e0..ebdbd7cb3a 100644 --- a/mercurial/src/changeset/test.rs +++ b/mercurial/src/changeset/test.rs @@ -12,7 +12,7 @@ use mercurial_types::{HgBlob, MPath}; use blobnode::BlobNode; use changeset::{escape, serialize_extras, unescape, Extra, RevlogChangeset, Time}; -use nodehash::{HgManifestId, NodeHash}; +use nodehash::{HgManifestId, HgNodeHash}; use bytes::Bytes; @@ -21,8 +21,8 @@ const CHANGESET_NOEXTRA: &[u8] = include_bytes!("cset_noextra.bin"); #[test] fn test_parse() { - let csid: NodeHash = "0849d280663e46b3e247857f4a68fabd2ba503c3".parse().unwrap(); - let p1: NodeHash = "169cb9e47f8e86079ee9fd79972092f78fbf68b1".parse().unwrap(); + let csid: HgNodeHash = "0849d280663e46b3e247857f4a68fabd2ba503c3".parse().unwrap(); + let p1: HgNodeHash = "169cb9e47f8e86079ee9fd79972092f78fbf68b1".parse().unwrap(); let node = BlobNode::new(HgBlob::Dirty(Bytes::from(CHANGESET)), Some(&p1), None); let cset = RevlogChangeset::parse(node.clone()).expect("parsed"); @@ -54,8 +54,8 @@ the user expected."#.into(), } ); - let csid: NodeHash = "526722d24ee5b3b860d4060e008219e083488356".parse().unwrap(); - let p1: NodeHash = "db5eb6a86179ce819db03da9ef2090b32f8e3fc4".parse().unwrap(); + let csid: HgNodeHash = "526722d24ee5b3b860d4060e008219e083488356".parse().unwrap(); + let p1: HgNodeHash = "db5eb6a86179ce819db03da9ef2090b32f8e3fc4".parse().unwrap(); let node = BlobNode::new( HgBlob::Dirty(Bytes::from(CHANGESET_NOEXTRA)), Some(&p1), @@ -88,7 +88,7 @@ clean up html code for w3c validation #[test] fn test_generate() { - fn test(csid: NodeHash, p1: Option<&NodeHash>, blob: HgBlob, cs: &[u8]) { + fn test(csid: HgNodeHash, p1: Option<&HgNodeHash>, blob: HgBlob, cs: &[u8]) { let node = BlobNode::new(blob, p1, None); let cset = RevlogChangeset::parse(node.clone()).expect("parsed"); @@ -101,8 +101,8 @@ fn test_generate() { assert_eq!(new, cs); } - let csid: NodeHash = "0849d280663e46b3e247857f4a68fabd2ba503c3".parse().unwrap(); - let p1: NodeHash = "169cb9e47f8e86079ee9fd79972092f78fbf68b1".parse().unwrap(); + let csid: HgNodeHash = "0849d280663e46b3e247857f4a68fabd2ba503c3".parse().unwrap(); + let p1: HgNodeHash = "169cb9e47f8e86079ee9fd79972092f78fbf68b1".parse().unwrap(); test( csid, Some(&p1), @@ -110,8 +110,8 @@ fn test_generate() { CHANGESET, ); - let csid: NodeHash = "526722d24ee5b3b860d4060e008219e083488356".parse().unwrap(); - let p1: NodeHash = "db5eb6a86179ce819db03da9ef2090b32f8e3fc4".parse().unwrap(); + let csid: HgNodeHash = "526722d24ee5b3b860d4060e008219e083488356".parse().unwrap(); + let p1: HgNodeHash = "db5eb6a86179ce819db03da9ef2090b32f8e3fc4".parse().unwrap(); test( csid, Some(&p1), diff --git a/mercurial/src/lib.rs b/mercurial/src/lib.rs index 3c4ca0109e..53758ce163 100644 --- a/mercurial/src/lib.rs +++ b/mercurial/src/lib.rs @@ -72,6 +72,6 @@ pub use errors::*; pub use blobnode::{BlobNode, Parents}; pub use changeset::RevlogChangeset; pub use manifest::{EntryContent, RevlogEntry}; -pub use nodehash::{EntryId, HgChangesetId, HgManifestId, HgNodeKey, NodeHash, NodeHashConversion, - NULL_HASH}; +pub use nodehash::{EntryId, HgChangesetId, HgManifestId, HgNodeHash, HgNodeKey, + NodeHashConversion, NULL_HASH}; pub use revlogrepo::{RevlogManifest, RevlogRepo, RevlogRepoOptions}; diff --git a/mercurial/src/manifest/revlog.rs b/mercurial/src/manifest/revlog.rs index 96bc0d68e3..0898161a40 100644 --- a/mercurial/src/manifest/revlog.rs +++ b/mercurial/src/manifest/revlog.rs @@ -21,7 +21,7 @@ use mercurial_types::{FileType, HgBlob, MPath, MPathElement, RepoPath}; use mercurial_types::manifest::Type; use blobnode::{BlobNode, Parents}; -use nodehash::{EntryId, NodeHash}; +use nodehash::{EntryId, HgNodeHash}; use RevlogRepo; @@ -210,7 +210,7 @@ impl Details { let (hash, flags) = data.split_at(40); let hash = str::from_utf8(hash) .map_err(|err| Error::from(err)) - .and_then(|hash| hash.parse::()) + .and_then(|hash| hash.parse::()) .with_context(|_| format!("malformed hash: {:?}", hash))?; let entryid = EntryId::new(hash); diff --git a/mercurial/src/mocks.rs b/mercurial/src/mocks.rs index 9ee1de4884..630b52365b 100644 --- a/mercurial/src/mocks.rs +++ b/mercurial/src/mocks.rs @@ -6,21 +6,21 @@ use mercurial_types_mocks::hash; -use nodehash::NodeHash; +use nodehash::HgNodeHash; // Definitions for hashes 1111...ffff. -pub const ONES_HASH: NodeHash = NodeHash(hash::ONES); -pub const TWOS_HASH: NodeHash = NodeHash(hash::TWOS); -pub const THREES_HASH: NodeHash = NodeHash(hash::THREES); -pub const FOURS_HASH: NodeHash = NodeHash(hash::FOURS); -pub const FIVES_HASH: NodeHash = NodeHash(hash::FIVES); -pub const SIXES_HASH: NodeHash = NodeHash(hash::SIXES); -pub const SEVENS_HASH: NodeHash = NodeHash(hash::SEVENS); -pub const EIGHTS_HASH: NodeHash = NodeHash(hash::EIGHTS); -pub const NINES_HASH: NodeHash = NodeHash(hash::NINES); -pub const AS_HASH: NodeHash = NodeHash(hash::AS); -pub const BS_HASH: NodeHash = NodeHash(hash::BS); -pub const CS_HASH: NodeHash = NodeHash(hash::CS); -pub const DS_HASH: NodeHash = NodeHash(hash::DS); -pub const ES_HASH: NodeHash = NodeHash(hash::ES); -pub const FS_HASH: NodeHash = NodeHash(hash::FS); +pub const ONES_HASH: HgNodeHash = HgNodeHash(hash::ONES); +pub const TWOS_HASH: HgNodeHash = HgNodeHash(hash::TWOS); +pub const THREES_HASH: HgNodeHash = HgNodeHash(hash::THREES); +pub const FOURS_HASH: HgNodeHash = HgNodeHash(hash::FOURS); +pub const FIVES_HASH: HgNodeHash = HgNodeHash(hash::FIVES); +pub const SIXES_HASH: HgNodeHash = HgNodeHash(hash::SIXES); +pub const SEVENS_HASH: HgNodeHash = HgNodeHash(hash::SEVENS); +pub const EIGHTS_HASH: HgNodeHash = HgNodeHash(hash::EIGHTS); +pub const NINES_HASH: HgNodeHash = HgNodeHash(hash::NINES); +pub const AS_HASH: HgNodeHash = HgNodeHash(hash::AS); +pub const BS_HASH: HgNodeHash = HgNodeHash(hash::BS); +pub const CS_HASH: HgNodeHash = HgNodeHash(hash::CS); +pub const DS_HASH: HgNodeHash = HgNodeHash(hash::DS); +pub const ES_HASH: HgNodeHash = HgNodeHash(hash::ES); +pub const FS_HASH: HgNodeHash = HgNodeHash(hash::FS); diff --git a/mercurial/src/nodehash.rs b/mercurial/src/nodehash.rs index 4a6c15fd40..821662c370 100644 --- a/mercurial/src/nodehash.rs +++ b/mercurial/src/nodehash.rs @@ -19,20 +19,20 @@ use mercurial_types::hash::{self, Sha1}; use serde; use sql_types::{HgChangesetIdSql, HgManifestIdSql}; -pub const NULL_HASH: NodeHash = NodeHash(hash::NULL); +pub const NULL_HASH: HgNodeHash = HgNodeHash(hash::NULL); /// This structure represents Sha1 based hashes that are used in Mercurial, but the Sha1 /// structure is private outside this crate to keep it an implementation detail. /// This is why the main constructors to create this structure are from_bytes and from_ascii_str -/// which parses raw bytes or hex string to create NodeHash. +/// which parses raw bytes or hex string to create HgNodeHash. #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[derive(HeapSizeOf)] -pub struct NodeHash(pub(crate) Sha1); +pub struct HgNodeHash(pub(crate) Sha1); -impl NodeHash { - /// Constructor to be used to parse 20 raw bytes that represent a sha1 hash into NodeHash - pub fn from_bytes(bytes: &[u8]) -> Result { - Sha1::from_bytes(bytes).map(NodeHash) +impl HgNodeHash { + /// Constructor to be used to parse 20 raw bytes that represent a sha1 hash into HgNodeHash + pub fn from_bytes(bytes: &[u8]) -> Result { + Sha1::from_bytes(bytes).map(HgNodeHash) } /// Returns the underlying 20 raw bytes that represent a sha1 hash @@ -40,10 +40,10 @@ impl NodeHash { self.0.as_ref() } - /// Constructor to be used to parse 40 hex digits that represent a sha1 hash into NodeHash + /// Constructor to be used to parse 40 hex digits that represent a sha1 hash into HgNodeHash #[inline] - pub fn from_ascii_str(s: &AsciiStr) -> Result { - Sha1::from_ascii_str(s).map(NodeHash) + pub fn from_ascii_str(s: &AsciiStr) -> Result { + Sha1::from_ascii_str(s).map(HgNodeHash) } /// Returns a 40 hex digits representation of the sha1 hash @@ -61,7 +61,7 @@ impl NodeHash { } } - /// Method used to convert a Mercurial Sha1 based NodeHash into Mononoke Sha1 based NodeHash + /// Method used to convert a Mercurial Sha1 based HgNodeHash into Mononoke Sha1 based HgNodeHash /// without performing lookups in a remapping tables. It should be used only on Filenodes and /// Manifests that are not Root Manifests. /// This method is temporary (as the mercurial_types hashes are) and will go away once @@ -78,26 +78,26 @@ impl NodeHash { } } -/// Trait to convieniently track the places where Mononoke to Mercurial NodeHash coversion is +/// Trait to convieniently track the places where Mononoke to Mercurial HgNodeHash coversion is /// taking place without performing a lookup in remapping tables. pub trait NodeHashConversion { - fn into_mercurial(self) -> NodeHash; + fn into_mercurial(self) -> HgNodeHash; } impl NodeHashConversion for DNodeHash { - /// Method used to convert a Mononoke Sha1 based NodeHash into Mercurial Sha1 based NodeHash + /// Method used to convert a Mononoke Sha1 based HgNodeHash into Mercurial Sha1 based HgNodeHash /// without performing lookups in a remapping tables. It should be used only on Filenodes and /// Manifests that are not Root Manifests. /// This method is temporary (as the mercurial_types hashes are) and will go away once /// transision to BonsaiChangesets is complete - fn into_mercurial(self) -> NodeHash { + fn into_mercurial(self) -> HgNodeHash { #![allow(deprecated)] - NodeHash(self.into_sha1()) + HgNodeHash(self.into_sha1()) } } -impl From> for NodeHash { - fn from(h: Option) -> Self { +impl From> for HgNodeHash { + fn from(h: Option) -> Self { match h { None => NULL_HASH, Some(h) => h, @@ -129,7 +129,7 @@ impl<'de> serde::de::Visitor<'de> for StringVisitor { } } -impl serde::ser::Serialize for NodeHash { +impl serde::ser::Serialize for HgNodeHash { fn serialize(&self, serializer: S) -> ::std::result::Result where S: serde::Serializer, @@ -138,42 +138,42 @@ impl serde::ser::Serialize for NodeHash { } } -impl<'de> serde::de::Deserialize<'de> for NodeHash { - fn deserialize(deserializer: D) -> ::std::result::Result +impl<'de> serde::de::Deserialize<'de> for HgNodeHash { + fn deserialize(deserializer: D) -> ::std::result::Result where D: serde::de::Deserializer<'de>, { let hex = deserializer.deserialize_string(StringVisitor)?; match Sha1::from_str(hex.as_str()) { - Ok(sha1) => Ok(NodeHash(sha1)), + Ok(sha1) => Ok(HgNodeHash(sha1)), Err(error) => Err(serde::de::Error::custom(error)), } } } -impl AsRef<[u8]> for NodeHash { +impl AsRef<[u8]> for HgNodeHash { fn as_ref(&self) -> &[u8] { self.0.as_ref() } } -impl FromStr for NodeHash { +impl FromStr for HgNodeHash { type Err = ::Err; - fn from_str(s: &str) -> result::Result { - Sha1::from_str(s).map(NodeHash) + fn from_str(s: &str) -> result::Result { + Sha1::from_str(s).map(HgNodeHash) } } -impl Display for NodeHash { +impl Display for HgNodeHash { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(fmt) } } -impl Arbitrary for NodeHash { +impl Arbitrary for HgNodeHash { fn arbitrary(g: &mut G) -> Self { - NodeHash(Sha1::arbitrary(g)) + HgNodeHash(Sha1::arbitrary(g)) } fn shrink(&self) -> Box> { @@ -184,24 +184,24 @@ impl Arbitrary for NodeHash { #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[derive(HeapSizeOf, FromSqlRow, AsExpression)] #[sql_type = "HgChangesetIdSql"] -pub struct HgChangesetId(NodeHash); +pub struct HgChangesetId(HgNodeHash); impl HgChangesetId { #[inline] pub fn from_ascii_str(s: &AsciiStr) -> Result { - NodeHash::from_ascii_str(s).map(HgChangesetId) + HgNodeHash::from_ascii_str(s).map(HgChangesetId) } #[inline] - pub(crate) fn as_nodehash(&self) -> &NodeHash { + pub(crate) fn as_nodehash(&self) -> &HgNodeHash { &self.0 } - pub fn into_nodehash(self) -> NodeHash { + pub fn into_nodehash(self) -> HgNodeHash { self.0 } - pub const fn new(hash: NodeHash) -> Self { + pub const fn new(hash: HgNodeHash) -> Self { HgChangesetId(hash) } @@ -212,10 +212,10 @@ impl HgChangesetId { } impl FromStr for HgChangesetId { - type Err = ::Err; + type Err = ::Err; fn from_str(s: &str) -> result::Result { - NodeHash::from_str(s).map(HgChangesetId) + HgNodeHash::from_str(s).map(HgChangesetId) } } @@ -240,7 +240,7 @@ impl<'de> serde::de::Deserialize<'de> for HgChangesetId { D: serde::de::Deserializer<'de>, { let hex = deserializer.deserialize_string(StringVisitor)?; - match NodeHash::from_str(hex.as_str()) { + match HgNodeHash::from_str(hex.as_str()) { Ok(hash) => Ok(HgChangesetId::new(hash)), Err(error) => Err(serde::de::Error::custom(error)), } @@ -250,19 +250,19 @@ impl<'de> serde::de::Deserialize<'de> for HgChangesetId { #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[derive(HeapSizeOf, FromSqlRow, AsExpression)] #[sql_type = "HgManifestIdSql"] -pub struct HgManifestId(NodeHash); +pub struct HgManifestId(HgNodeHash); impl HgManifestId { #[inline] - pub(crate) fn as_nodehash(&self) -> &NodeHash { + pub(crate) fn as_nodehash(&self) -> &HgNodeHash { &self.0 } - pub fn into_nodehash(self) -> NodeHash { + pub fn into_nodehash(self) -> HgNodeHash { self.0 } - pub const fn new(hash: NodeHash) -> Self { + pub const fn new(hash: HgNodeHash) -> Self { HgManifestId(hash) } } @@ -276,14 +276,14 @@ impl Display for HgManifestId { /// TODO: (jsgf) T25576292 EntryId should be a (Type, NodeId) tuple #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] #[derive(HeapSizeOf)] -pub struct EntryId(NodeHash); +pub struct EntryId(HgNodeHash); impl EntryId { - pub fn into_nodehash(self) -> NodeHash { + pub fn into_nodehash(self) -> HgNodeHash { self.0 } - pub fn new(hash: NodeHash) -> Self { + pub fn new(hash: HgNodeHash) -> Self { EntryId(hash) } } @@ -299,5 +299,5 @@ impl Display for EntryId { #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct HgNodeKey { pub path: RepoPath, - pub hash: NodeHash, + pub hash: HgNodeHash, } diff --git a/mercurial/src/revlog/mod.rs b/mercurial/src/revlog/mod.rs index 3421c9be37..ce59d35f8e 100644 --- a/mercurial/src/revlog/mod.rs +++ b/mercurial/src/revlog/mod.rs @@ -24,7 +24,7 @@ pub use mercurial_types::{delta, HgBlob}; pub use mercurial_types::bdiff::{self, Delta}; use blobnode::BlobNode; -use nodehash::{EntryId, NodeHash}; +use nodehash::{EntryId, HgNodeHash}; // Submodules mod parser; @@ -92,8 +92,8 @@ struct RevlogInner { header: Header, idx: Datafile, data: Option, - idxoff: BTreeMap, // cache of index -> offset - nodeidx: HashMap, // cache of nodeid -> index + idxoff: BTreeMap, // cache of index -> offset + nodeidx: HashMap, // cache of nodeid -> index } impl PartialEq for Revlog { @@ -212,7 +212,7 @@ impl Revlog { } /// Return the ordinal index of an entry with the given nodeid. - pub fn get_idx_by_nodeid(&self, nodeid: &NodeHash) -> Result { + pub fn get_idx_by_nodeid(&self, nodeid: &HgNodeHash) -> Result { self.inner.get_idx_by_nodeid(nodeid) } @@ -236,12 +236,12 @@ impl Revlog { self.inner.get_rev(tgtidx) } - pub fn get_rev_by_nodeid(&self, id: &NodeHash) -> Result { + pub fn get_rev_by_nodeid(&self, id: &HgNodeHash) -> Result { self.inner.get_rev_by_nodeid(id) } /// Return the set of head revisions in a revlog - pub fn get_heads(&self) -> Result> { + pub fn get_heads(&self) -> Result> { self.inner.get_heads() } } @@ -319,14 +319,14 @@ impl RevlogInner { } /// Return the ordinal index of an entry with the given nodeid. - fn get_idx_by_nodeid(&self, nodeid: &NodeHash) -> Result { + fn get_idx_by_nodeid(&self, nodeid: &HgNodeHash) -> Result { match self.nodeidx.get(nodeid).cloned() { Some(idx) => Ok(idx), // cache hit None => Err(ErrorKind::Revlog(format!("nodeid {} not found", nodeid)).into()), } } - fn get_entry_by_nodeid(&self, nodeid: &NodeHash) -> Result { + fn get_entry_by_nodeid(&self, nodeid: &HgNodeHash) -> Result { self.get_idx_by_nodeid(nodeid) .and_then(|idx| self.get_entry(idx)) } @@ -521,7 +521,7 @@ impl RevlogInner { self.make_node(&entry, HgBlob::from(Bytes::from(data))) } - fn get_rev_by_nodeid(&self, id: &NodeHash) -> Result { + fn get_rev_by_nodeid(&self, id: &HgNodeHash) -> Result { self.get_idx_by_nodeid(&id).and_then(move |idx| { self.get_rev(idx) .with_context(|_| format!("can't get rev for id {}", id)) @@ -530,7 +530,7 @@ impl RevlogInner { } /// Return the set of head revisions in a revlog - fn get_heads(&self) -> Result> { + fn get_heads(&self) -> Result> { // Current set of candidate heads let mut heads = HashMap::new(); diff --git a/mercurial/src/revlog/parser.rs b/mercurial/src/revlog/parser.rs index 4cad941e96..1f00009063 100644 --- a/mercurial/src/revlog/parser.rs +++ b/mercurial/src/revlog/parser.rs @@ -14,7 +14,7 @@ use nom::{ErrorKind, IResult, Needed, be_u16, be_u32}; use mercurial_types::bdiff::Delta; -use nodehash::NodeHash; +use nodehash::HgNodeHash; use revlog::revidx::RevIdx; use super::lz4; @@ -81,11 +81,11 @@ pub struct Entry { pub linkrev: RevIdx, // changeset id pub p1: Option, // parent p1 pub p2: Option, // parent p2 - pub nodeid: NodeHash, // nodeid + pub nodeid: HgNodeHash, // nodeid } impl Entry { - pub fn nodeid(&self) -> &NodeHash { + pub fn nodeid(&self) -> &HgNodeHash { &self.nodeid } } @@ -140,7 +140,7 @@ named!(pub indexng, linkrev: linkrev.into(), p1: if p1 == !0 { None } else { Some(p1.into()) }, p2: if p2 == !0 { None } else { Some(p2.into()) }, - nodeid: NodeHash::from_bytes(&hash[..20]).expect("bad bytes for sha"), + nodeid: HgNodeHash::from_bytes(&hash[..20]).expect("bad bytes for sha"), } }) ) @@ -171,7 +171,7 @@ named!(pub index0, linkrev: linkrev.into(), p1: if p1 == !0 { None } else { Some(p1.into()) }, p2: if p2 == !0 { None } else { Some(p2.into()) }, - nodeid: NodeHash::from_bytes(&hash[..20]).expect("bad bytes for sha"), + nodeid: HgNodeHash::from_bytes(&hash[..20]).expect("bad bytes for sha"), } }) ) diff --git a/mercurial/src/revlogrepo.rs b/mercurial/src/revlogrepo.rs index e0cc356536..d629a0c650 100644 --- a/mercurial/src/revlogrepo.rs +++ b/mercurial/src/revlogrepo.rs @@ -29,7 +29,7 @@ use blobnode::BlobNode; pub use changeset::RevlogChangeset; use errors::*; pub use manifest::RevlogManifest; -use nodehash::{EntryId, HgChangesetId, HgManifestId, NodeHash, NULL_HASH}; +use nodehash::{EntryId, HgChangesetId, HgManifestId, HgNodeHash, NULL_HASH}; use revlog::{self, RevIdx, Revlog, RevlogIter}; const DEFAULT_LOGS_CAPACITY: usize = 1000000; @@ -176,7 +176,7 @@ impl RevlogRepo { }) } - pub fn get_heads(&self) -> BoxStream { + pub fn get_heads(&self) -> BoxStream { match self.changelog.get_heads() { Err(e) => stream::once(Err(e)).boxify(), Ok(set) => stream::iter_ok(set.into_iter()).boxify(), @@ -324,7 +324,7 @@ pub trait RevlogRepoBlobimportExt { fn get_changelog_entry_by_idx(&self, revidx: RevIdx) -> Result; - fn get_manifest_blob_by_id(&self, nodeid: &NodeHash) -> Result; + fn get_manifest_blob_by_id(&self, nodeid: &HgNodeHash) -> Result; fn get_path_revlog(&self, path: &RepoPath) -> Result; } @@ -339,7 +339,7 @@ impl RevlogRepoBlobimportExt for RevlogRepo { self.changelog.get_entry(revidx) } - fn get_manifest_blob_by_id(&self, nodeid: &NodeHash) -> Result { + fn get_manifest_blob_by_id(&self, nodeid: &HgNodeHash) -> Result { // It's possible that commit has null pointer to manifest hash. // In that case we want to return empty blobnode if nodeid == &NULL_HASH { @@ -366,10 +366,10 @@ impl ChangesetStream { } impl Stream for ChangesetStream { - type Item = NodeHash; + type Item = HgNodeHash; type Error = Error; - fn poll(&mut self) -> Poll, Error> { + fn poll(&mut self) -> Poll, Error> { match self.0.next() { Some((_, e)) => Ok(Async::Ready(Some(e.nodeid))), None => Ok(Async::Ready(None)), diff --git a/mercurial/src/sql_types.rs b/mercurial/src/sql_types.rs index b13bfac066..3cc7565090 100644 --- a/mercurial/src/sql_types.rs +++ b/mercurial/src/sql_types.rs @@ -14,7 +14,7 @@ use diesel::serialize::{self, IsNull, Output, ToSql}; use diesel::sql_types::Binary; use errors::*; -use nodehash::{HgChangesetId, HgManifestId, NodeHash}; +use nodehash::{HgChangesetId, HgManifestId, HgNodeHash}; #[derive(QueryId, SqlType)] #[mysql_type = "Blob"] @@ -41,7 +41,7 @@ where // Using unsafe here saves on a heap allocation. See https://goo.gl/K6hapb. let raw_bytes: *const [u8] = FromSql::::from_sql(bytes)?; let raw_bytes: &[u8] = unsafe { &*raw_bytes }; - let hash = NodeHash::from_bytes(raw_bytes).compat()?; + let hash = HgNodeHash::from_bytes(raw_bytes).compat()?; Ok(Self::new(hash)) } } @@ -61,7 +61,7 @@ where // Using unsafe here saves on a heap allocation. See https://goo.gl/K6hapb. let raw_bytes: *const [u8] = FromSql::::from_sql(bytes)?; let raw_bytes: &[u8] = unsafe { &*raw_bytes }; - let hash = NodeHash::from_bytes(raw_bytes).compat()?; + let hash = HgNodeHash::from_bytes(raw_bytes).compat()?; Ok(Self::new(hash)) } } diff --git a/server/src/repo.rs b/server/src/repo.rs index 1e967bf148..e62246ca1e 100644 --- a/server/src/repo.rs +++ b/server/src/repo.rs @@ -35,7 +35,7 @@ use slog_scuba::ScubaDrain; use blobrepo::BlobChangeset; use bundle2_resolver; -use mercurial::{self, NodeHashConversion, RevlogChangeset}; +use mercurial::{self, HgNodeHash, NodeHashConversion, RevlogChangeset}; use mercurial_bundles::{parts, Bundle2EncodeBuilder, Bundle2Item}; use mercurial_types::{percent_encode, Changeset, DChangesetId, DManifestId, DNodeHash, DParents, Entry, MPath, RepoPath, RepositoryId, Type, D_NULL_HASH}; @@ -486,10 +486,7 @@ impl RepoClient { impl HgCommands for RepoClient { // @wireprotocommand('between', 'pairs') - fn between( - &self, - pairs: Vec<(mercurial::NodeHash, mercurial::NodeHash)>, - ) -> HgCommandRes>> { + fn between(&self, pairs: Vec<(HgNodeHash, HgNodeHash)>) -> HgCommandRes>> { info!(self.logger, "between pairs {:?}", pairs); struct ParentStream { @@ -573,7 +570,7 @@ impl HgCommands for RepoClient { } // @wireprotocommand('heads') - fn heads(&self) -> HgCommandRes> { + fn heads(&self) -> HgCommandRes> { // Get a stream of heads and collect them into a HashSet // TODO: directly return stream of heads let logger = self.logger.clone(); @@ -599,7 +596,7 @@ impl HgCommands for RepoClient { let scuba = self.repo.scuba.clone(); let sample = self.repo.scuba_sample(ops::LOOKUP); let remote = self.repo.remote.clone(); - mercurial::NodeHash::from_str(&key) + HgNodeHash::from_str(&key) .into_future() .map(|h| (h, h.into_mononoke())) .and_then(move |(mercurial_node, node)| { @@ -630,7 +627,7 @@ impl HgCommands for RepoClient { } // @wireprotocommand('known', 'nodes *'), but the '*' is ignored - fn known(&self, nodes: Vec) -> HgCommandRes> { + fn known(&self, nodes: Vec) -> HgCommandRes> { info!(self.logger, "known: {:?}", nodes); let hgrepo = self.repo.hgrepo.clone(); let scuba = self.repo.scuba.clone(); @@ -751,10 +748,7 @@ impl HgCommands for RepoClient { } // @wireprotocommand('getfiles', 'files*') - fn getfiles( - &self, - params: BoxStream<(mercurial::NodeHash, MPath), Error>, - ) -> BoxStream { + fn getfiles(&self, params: BoxStream<(HgNodeHash, MPath), Error>) -> BoxStream { let logger = self.logger.clone(); info!(logger, "getfiles"); let repo = self.repo.clone();