mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
convert from put_X::<BigEndian> -> put_X_be
Summary: Replace all occurrences of the deprecated put_X::<BigEndian> methods with put_X_be in the files marked with T29077977, and remove any allow deprecation lines in the files and unused imports that might be introduced. Reviewed By: jsgf Differential Revision: D7928695 fbshipit-source-id: 8f16915f6b08aa55521637fff58a6cc27c13321a
This commit is contained in:
parent
5c2f0c675c
commit
9e5f08cf6b
@ -14,8 +14,6 @@
|
||||
//! rather than restricting all codec operations to `AsyncRead`/`AsyncWrite` operations on
|
||||
//! an underlying transport.
|
||||
|
||||
#![allow(deprecated)] // TODO: T29077977 convert from put_X::<BigEndian> -> put_X_be
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::{Async, Poll, Stream};
|
||||
use tokio_io::codec::Encoder;
|
||||
@ -109,7 +107,7 @@ mod test {
|
||||
|
||||
fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
||||
dst.reserve(2);
|
||||
dst.put_u16::<BigEndian>(item);
|
||||
dst.put_u16_be(item);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
// This software may be used and distributed according to the terms of the
|
||||
// GNU General Public License version 2 or any later version.
|
||||
|
||||
#![allow(deprecated)] // TODO: T29077977 convert from put_X::<BigEndian> -> put_X_be
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::io::{self, Cursor};
|
||||
use std::mem;
|
||||
@ -116,7 +114,7 @@ where
|
||||
|
||||
header_buf.put_slice(b"HG20");
|
||||
// Reserve 4 bytes for the length.
|
||||
header_buf.put_u32::<BigEndian>(0);
|
||||
header_buf.put_u32_be(0);
|
||||
// Now write out the stream header.
|
||||
|
||||
let params = mparams
|
||||
|
@ -4,9 +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.
|
||||
|
||||
#![allow(deprecated)] // TODO: T29077977 convert from put_X::<BigEndian> -> put_X_be
|
||||
|
||||
use bytes::{BigEndian, BufMut, Bytes, BytesMut};
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use tokio_io::codec::{Decoder, Encoder};
|
||||
|
||||
use errors::*;
|
||||
@ -104,12 +102,12 @@ impl Encoder for ChunkEncoder {
|
||||
match item.0 {
|
||||
ChunkInner::Normal(bytes) => {
|
||||
dst.reserve(4 + bytes.len());
|
||||
dst.put_i32::<BigEndian>(bytes.len() as i32);
|
||||
dst.put_i32_be(bytes.len() as i32);
|
||||
dst.put_slice(&bytes);
|
||||
}
|
||||
ChunkInner::Error => {
|
||||
dst.reserve(4);
|
||||
dst.put_i32::<BigEndian>(-1);
|
||||
dst.put_i32_be(-1);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -166,7 +164,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_empty_chunk() {
|
||||
let mut buf = BytesMut::with_capacity(4);
|
||||
buf.put_i32::<BigEndian>(0);
|
||||
buf.put_i32_be(0);
|
||||
|
||||
let mut decoder = ChunkDecoder;
|
||||
let chunk = decoder.decode(&mut buf).unwrap().unwrap();
|
||||
@ -180,7 +178,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_error_chunk() {
|
||||
let mut buf = BytesMut::with_capacity(4);
|
||||
buf.put_i32::<BigEndian>(-1);
|
||||
buf.put_i32_be(-1);
|
||||
|
||||
let mut decoder = ChunkDecoder;
|
||||
let chunk = decoder.decode(&mut buf).unwrap().unwrap();
|
||||
@ -194,7 +192,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_invalid_chunk() {
|
||||
let mut buf = BytesMut::with_capacity(4);
|
||||
buf.put_i32::<BigEndian>(-2);
|
||||
buf.put_i32_be(-2);
|
||||
|
||||
let mut decoder = ChunkDecoder;
|
||||
let chunk_err = decoder.decode(&mut buf);
|
||||
|
@ -6,9 +6,7 @@
|
||||
|
||||
//! Code to deal with deltas received or sent over the wire.
|
||||
|
||||
#![allow(deprecated)] // TODO: T29077977 convert from put_X::<BigEndian> -> put_X_be
|
||||
|
||||
use bytes::{BigEndian, BufMut, BytesMut};
|
||||
use bytes::{BufMut, BytesMut};
|
||||
|
||||
use bytes_ext::SizeCounter;
|
||||
use mercurial_types::delta::{Delta, Fragment};
|
||||
@ -76,9 +74,9 @@ pub fn encoded_len(delta: &Delta) -> usize {
|
||||
|
||||
pub fn encode_delta<B: BufMut>(delta: &Delta, out: &mut B) {
|
||||
for fragment in delta.fragments() {
|
||||
out.put_i32::<BigEndian>(fragment.start as i32);
|
||||
out.put_i32::<BigEndian>(fragment.end as i32);
|
||||
out.put_i32::<BigEndian>(fragment.content.len() as i32);
|
||||
out.put_i32_be(fragment.start as i32);
|
||||
out.put_i32_be(fragment.end as i32);
|
||||
out.put_i32_be(fragment.content.len() as i32);
|
||||
out.put_slice(&fragment.content[..]);
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,9 @@
|
||||
|
||||
//! Construct and serialize headers for bundle2 parts.
|
||||
|
||||
#![allow(deprecated)] // TODO: T29077977 convert from put_X::<BigEndian> -> put_X_be
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use bytes::{BigEndian, BufMut, Bytes};
|
||||
use bytes::{BufMut, Bytes};
|
||||
use quickcheck::{Arbitrary, Gen};
|
||||
|
||||
use chunk::Chunk;
|
||||
@ -153,7 +151,7 @@ impl PartHeader {
|
||||
out_buf.put_slice(part_type);
|
||||
|
||||
// part id
|
||||
out_buf.put_u32::<BigEndian>(self.part_id);
|
||||
out_buf.put_u32_be(self.part_id);
|
||||
|
||||
// mandatory/advisory params
|
||||
let num_mparams = self.mparams.len() as u8;
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
//! Wire packs. The format is currently undocumented.
|
||||
|
||||
#![allow(deprecated)] // TODO: T29077977 convert from put_X::<BigEndian> -> put_X_be
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
@ -174,7 +172,7 @@ impl HistoryEntry {
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
buf.put_u16::<BigEndian>(path_vec.len() as u16);
|
||||
buf.put_u16_be(path_vec.len() as u16);
|
||||
buf.put_slice(&path_vec);
|
||||
Ok(())
|
||||
}
|
||||
@ -277,10 +275,10 @@ impl DataEntry {
|
||||
let fulltext = self.delta
|
||||
.maybe_fulltext()
|
||||
.expect("verify will have already checked that the delta is a fulltext");
|
||||
buf.put_u64::<BigEndian>(fulltext.len() as u64);
|
||||
buf.put_u64_be(fulltext.len() as u64);
|
||||
buf.put_slice(fulltext);
|
||||
} else {
|
||||
buf.put_u64::<BigEndian>(delta::encoded_len(&self.delta) as u64);
|
||||
buf.put_u64_be(delta::encoded_len(&self.delta) as u64);
|
||||
delta::encode_delta(&self.delta, buf);
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user