Skip to content

Commit 45c378a

Browse files
author
fossdd
committed
Update pijul
1 parent 920665b commit 45c378a

25 files changed

+186
-181
lines changed

Cargo.lock

Lines changed: 31 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libpijul/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ diffs = "0.4"
112112
toml = "0.5"
113113
serde_json = "1.0"
114114
lazy_static = "1.4"
115-
xxhash-rust = { version = "0.8.2", features = [ "xxh64" ] }
115+
twox-hash = "1.6"
116116
crossbeam-deque = "0.8"
117117
crossbeam-utils = "0.8"
118118

119-
zstd-seekable = { version = "0.2.0", optional = true }
119+
zstd-seekable = { version = "0.1.7", optional = true }
120120
cfg-if = "1.0"
121121
memchr = "2.4"
122122

libpijul/src/change/change_file.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use super::*;
22

33
/// An open, seekable change file.
44
#[cfg(feature = "zstd")]
5-
pub struct ChangeFile {
6-
s: Option<zstd_seekable::Seekable<OffFile>>,
5+
pub struct ChangeFile<'a> {
6+
s: Option<zstd_seekable::Seekable<'a, OffFile>>,
77
hashed: Hashed<Hunk<Option<Hash>, Local>, Author>,
88
hash: Hash,
99
unhashed: Option<toml::Value>,
@@ -34,7 +34,7 @@ impl std::io::Seek for OffFile {
3434
}
3535

3636
#[cfg(feature = "zstd")]
37-
impl ChangeFile {
37+
impl<'a> ChangeFile<'a> {
3838
/// Open a change file from a path.
3939
pub fn open(hash: Hash, path: &str) -> Result<Self, ChangeError> {
4040
use std::io::Read;
@@ -84,13 +84,10 @@ impl ChangeFile {
8484
let s = if offsets.contents_off >= m.len() {
8585
None
8686
} else {
87-
Some(zstd_seekable::Seekable::init(
88-
OffFile {
89-
f: r,
90-
start: offsets.contents_off,
91-
},
92-
None,
93-
)?)
87+
Some(zstd_seekable::Seekable::init(Box::new(OffFile {
88+
f: r,
89+
start: offsets.contents_off,
90+
}))?)
9491
};
9592
Ok(ChangeFile {
9693
s,

libpijul/src/change/text_changes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ impl Hunk<Option<Hash>, Local> {
355355
change_contents: &[u8],
356356
mut w: &mut W,
357357
) -> Result<(), TextSerError<C::Error>> {
358-
359358
// let file_name = |local: &Local, _| -> String { format!("{}:{}", local.path, local.line) };
360359

361360
use self::text_changes::*;

libpijul/src/changestore/filesystem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
66

77
/// A file system change store.
88
pub struct FileSystem {
9-
change_cache: RefCell<lru_cache::LruCache<ChangeId, ChangeFile>>,
9+
change_cache: RefCell<lru_cache::LruCache<ChangeId, ChangeFile<'static>>>,
1010
changes_dir: PathBuf,
1111
}
1212

@@ -79,7 +79,7 @@ impl FileSystem {
7979
hash: F,
8080
change: ChangeId,
8181
) -> Result<
82-
std::cell::RefMut<lru_cache::LruCache<ChangeId, ChangeFile>>,
82+
std::cell::RefMut<lru_cache::LruCache<ChangeId, ChangeFile<'static>>>,
8383
crate::change::ChangeError,
8484
> {
8585
let mut change_cache = self.change_cache.borrow_mut();

libpijul/src/lib.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,7 @@ pub use crate::record::{Algorithm, InodeUpdate};
7373
pub use crate::unrecord::UnrecordError;
7474

7575
// Making hashmaps deterministic (for testing)
76-
pub struct Xxh64(xxhash_rust::xxh64::Xxh64);
77-
impl std::hash::Hasher for Xxh64 {
78-
fn write(&mut self, bytes: &[u8]) {
79-
self.0.write(bytes)
80-
}
81-
fn finish(&self) -> u64 {
82-
self.0.finish()
83-
}
84-
}
85-
impl Default for Xxh64 {
86-
fn default() -> Self {
87-
Xxh64(xxhash_rust::xxh64::Xxh64::new(0))
88-
}
89-
}
90-
91-
pub type Hasher = std::hash::BuildHasherDefault<Xxh64>;
76+
pub type Hasher = std::hash::BuildHasherDefault<twox_hash::XxHash64>;
9277
pub type HashMap<K, V> = std::collections::HashMap<K, V, Hasher>;
9378
pub type HashSet<K> = std::collections::HashSet<K, Hasher>;
9479
// pub type HashMap<K, V> = std::collections::HashMap<K, V, std::collections::hash_map::RandomState>;

libpijul/src/pristine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl RemoteId {
261261

262262
pub fn from_base32(b: &[u8]) -> Option<Self> {
263263
let mut bb = RemoteId([0; 16]);
264-
if b.len() != bb.0.len() {
264+
if b.len() != data_encoding::BASE32_NOPAD.encode_len(16) {
265265
return None;
266266
}
267267
if data_encoding::BASE32_NOPAD.decode_mut(b, &mut bb.0).is_ok() {

libpijul/src/tests/add_file.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::working_copy::WorkingCopyRead;
2+
13
use super::*;
24
use std::io::Write;
35

libpijul/src/tests/change.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,7 @@ fn text() -> Result<(), anyhow::Error> {
153153
fn text_test<C: ChangeStore>(c: &C, change0: &Change, h: Hash) {
154154
let mut v = Vec::new();
155155
// let channel = channel.borrow();
156-
change0
157-
.write(
158-
c,
159-
Some(h),
160-
|l, _p| format!("{}:{}", l.path, l.line),
161-
true,
162-
&mut v,
163-
)
164-
.unwrap();
156+
change0.write(c, Some(h), true, &mut v).unwrap();
165157
for i in std::str::from_utf8(&v).unwrap().lines() {
166158
debug!("{}", i);
167159
}

libpijul/src/tests/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use crate::working_copy::WorkingCopy;
2+
use crate::working_copy::{WorkingCopy, WorkingCopyRead};
33
use std::io::Write;
44

55
#[test]

0 commit comments

Comments
 (0)