Converting to the new patch format "online"
[?]
Jun 3, 2021, 10:09 AM
SMMBFECLGSUKRZW5YPOQPOQCOY2CH2OTZXBSZ3KG2N3J3HQZ5PSACDependencies
- [2]
RRCSHAYZFormatting - [3]
EEBKW7VTKeys and identities - [4]
PSKXR4QEDo not load the entire change in memory in log - [5]
CCLLB7OIUpgrading to Sanakirja 0.15 + version bump - [6]
SLJ3OHD4unrecord: show list of changes if none were given as arguments - [7]
3S6LU2U5abstract out FileMetadata (de)serialistion - [8]
CIEUBH46Fixing an index-out-of-bounds error when serialising bad changes - [9]
CCFJ7VO3Renaming "Record" to "Hunk" in the changes - [10]
6YMDOZIBRefactoring apply - [11]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [12]
VO5OQW4WRemoving anyhow in libpijul - [13]
YN63NUZOSanakirja 1.0 - [14]
I24UEJQLVarious post-fire fixes - [15]
QL6K2ZM3Tags - [16]
AAXP2534Tags: completing the subcommand - [17]
5OGOE4VWStore the current channel in the pristine - [18]
TFPETWTVAdd config options for patch message templates - [19]
UNZXTNSJChange text format: order dependencies in the order they were on the channel at record time - [20]
ZRUPLBBTColours in diff and change: separating concerns and dependencies - [21]
ZSF3YFZTencoded file deletion - [22]
SE4RJYBZNo pager on Windows (really not) - [*]
L4JXJHWXpijul/*: reorganize imports and remove extern crate
Change contents
- replacement in pijul/src/commands/tag.rs at line 158
authors.push(a.to_string());authors.push(a.to_string().into()); - replacement in pijul/src/commands/tag.rs at line 163
authors.push(k.key)authors.push(k.key.into()) - replacement in pijul/src/commands/record.rs at line 221
authors.push(a.clone());authors.push(a.clone().into()); - replacement in pijul/src/commands/record.rs at line 226
authors.push(k.key)authors.push(k.key.into())} else {bail!("No identity configured yet. Please use `pijul key` to create one") - replacement in pijul/src/commands/mod.rs at line 188
write!(v, "{}", a).unwrap();write!(v, "{}", a.name).unwrap(); - edit in pijul/src/commands/mod.rs at line 217
}use serde_derive::*;#[derive(Debug, Serialize, Deserialize)]pub struct Identity {public_key: libpijul::key::PublicKey,name: String,#[serde(default, skip_serializing_if = "String::is_empty")]origin: String,#[serde(default, skip_serializing_if = "Option::is_none")]email: Option<String>, - edit in pijul/src/commands/log.rs at line 1[4.134376][24.2043]
use std::collections::hash_map::Entry;use std::collections::HashMap; - edit in pijul/src/commands/log.rs at line 56
let mut authors = HashMap::new();let mut id_path = if let Some(mut dir) = crate::config::global_config_dir() {dir.push("identities");Some(dir)} else {None}; - replacement in pijul/src/commands/log.rs at line 70
writeln!(stdout, "Author: {:?}", header.authors)?;write!(stdout, "Author: ")?;let mut is_first = true;for auth in header.authors.into_iter() {let auth = match authors.entry(auth.name) {Entry::Occupied(e) => e.into_mut(),Entry::Vacant(e) => {let mut id = None;if let Some(ref mut p) = id_path {p.push(e.key());if let Ok(f) = std::fs::File::open(&p) {if let Ok(id_) =serde_json::from_reader::<_, super::Identity>(f){id = Some(id_)}}p.pop();}if let Some(id) = id {e.insert(id.name)} else {let k = e.key().to_string();e.insert(k)}}};if is_first {is_first = false;write!(stdout, "{}", auth)?;} else {write!(stdout, ", {}", auth)?;}}writeln!(stdout)?; - replacement in pijul/src/commands/key.rs at line 17
Generate {},Generate {#[clap(long = "email")]email: Option<String>,name: String,}, - replacement in pijul/src/commands/key.rs at line 27
Some(SubCommand::Generate {}) => {Some(SubCommand::Generate { email, name }) => { - edit in pijul/src/commands/key.rs at line 29
std::fs::create_dir_all(&dir)?; - edit in pijul/src/commands/key.rs at line 51
- edit in pijul/src/commands/key.rs at line 54
- replacement in pijul/src/commands/key.rs at line 58
serde_json::to_writer_pretty(&mut f, &k.public_key())?;let pk = k.public_key();serde_json::to_writer_pretty(&mut f, &pk)?;f.write_all(b"\n")?;dir.pop();dir.push("identities");std::fs::create_dir_all(&dir)?;dir.push(&pk.key);debug!("creating file {:?}", dir);let mut f = std::fs::File::create(&dir)?;serde_json::to_writer_pretty(&mut f,&super::Identity {public_key: pk,origin: String::new(),name,email,},)?; - replacement in libpijul/src/tag.rs at line 82
pub const VERSION: u64 = 5;pub const VERSION: u64 = 7;pub const VERSION_NOENC: u64 = 5; - edit in libpijul/src/key.rs at line 36
#[serde(default, skip_serializing_if = "Option::is_none")] - edit in libpijul/src/key.rs at line 114
let secret = ed25519_dalek::SecretKey::from_bytes(&key).unwrap(); - replacement in libpijul/src/key.rs at line 116
key: ed25519_dalek::Keypair::from_bytes(&key).unwrap(),key: ed25519_dalek::Keypair {public: (&secret).into(),secret,}, - edit in libpijul/src/key.rs at line 363
}#[derive(Clone, Copy)]pub struct SerializedKey {pub(crate) t: u8,k: K,}impl From<ed25519_dalek::PublicKey> for SerializedKey {fn from(k: ed25519_dalek::PublicKey) -> Self {SerializedKey {t: 0,k: K {ed25519: k.as_bytes().clone(),},}}}impl From<SerializedKey> for ed25519_dalek::PublicKey {fn from(k: SerializedKey) -> Self {assert_eq!(k.t, 0);unsafe { ed25519_dalek::PublicKey::from_bytes(&k.k.ed25519).unwrap() }} - edit in libpijul/src/key.rs at line 388[3.16322]
#[derive(Clone, Copy)]pub(crate) union K {ed25519: [u8; 32],} - replacement in libpijul/src/changestore/mod.rs at line 101
bincode::deserialize(buf).unwrap()if let Ok(m) = bincode::deserialize(buf) {m} else {let (a, b) = buf.split_at(2);use byteorder::ByteOrder;FileMetadata {metadata: InodeMetadata(byteorder::BigEndian::read_u16(a)),basename: std::str::from_utf8(b).unwrap(),encoding: None,}} - edit in libpijul/src/change.rs at line 17
mod noenc; - replacement in libpijul/src/change.rs at line 22
#[error("Version mismatch")]VersionMismatch,#[error("Version mismatch: got {}", got)]VersionMismatch { got: u64 }, - replacement in libpijul/src/change.rs at line 113
pub authors: Vec<String>,pub authors: Vec<Author>,}#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]pub struct Author {pub name: String,#[serde(default)]pub full_name: Option<String>,#[serde(default)]pub email: Option<String>,}impl From<String> for Author {fn from(name: String) -> Author {Author {name,..Author::default()}} - replacement in libpijul/src/change.rs at line 146
pub struct LocalChange<Local> {pub struct LocalChange<Hunk> { - replacement in libpijul/src/change.rs at line 148
pub hashed: Hashed<Local>,pub hashed: Hashed<Hunk>, - replacement in libpijul/src/change.rs at line 155
impl std::ops::Deref for LocalChange<Local> {type Target = Hashed<Local>;impl std::ops::Deref for LocalChange<Hunk<Option<Hash>, Local>> {type Target = Hashed<Hunk<Option<Hash>, Local>>; - replacement in libpijul/src/change.rs at line 162
impl std::ops::DerefMut for LocalChange<Local> {impl std::ops::DerefMut for LocalChange<Hunk<Option<Hash>, Local>> { - replacement in libpijul/src/change.rs at line 168
// Beware of change the version, tags also use that.pub const VERSION: u64 = 5;// Beware of changes in the version, tags also use that.pub const VERSION: u64 = 6;pub const VERSION_NOENC: u64 = 4; - replacement in libpijul/src/change.rs at line 173
pub struct Hashed<Local> {pub struct Hashed<Hunk> { - replacement in libpijul/src/change.rs at line 185
pub changes: Vec<Hunk<Option<Hash>, Local>>,pub changes: Vec<Hunk>, - replacement in libpijul/src/change.rs at line 191
pub type Change = LocalChange<Local>;pub type Change = LocalChange<Hunk<Option<Hash>, Local>>; - replacement in libpijul/src/change.rs at line 1204
impl<L> LocalChange<L> {impl LocalChange<Hunk<Option<Hash>, Local>> { - replacement in libpijul/src/change.rs at line 1211
changes: Vec<Hunk<Option<Hash>, L>>,changes: Vec<Hunk<Option<Hash>, Local>>, - replacement in libpijul/src/change.rs at line 1290
if off.version != VERSION {return Err(ChangeError::VersionMismatch);if off.version != VERSION && off.version != VERSION_NOENC {return Err(ChangeError::VersionMismatch { got: off.version }); - replacement in libpijul/src/change.rs at line 1352
return Err(ChangeError::VersionMismatch);return Err(ChangeError::VersionMismatch {got: offsets.version,}); - replacement in libpijul/src/change.rs at line 1377
let hashed: Hashed<Local> = bincode::deserialize(&buf_)?;let hashed: Hashed<Hunk<Option<Hash>, Local>> = bincode::deserialize(&buf_)?; - replacement in libpijul/src/change.rs at line 1408
if offsets.version != VERSION {return Err(ChangeError::VersionMismatch);if offsets.version == VERSION_NOENC {return Self::deserialize_noenc(offsets, r, hash);} else if offsets.version != VERSION {return Err(ChangeError::VersionMismatch {got: offsets.version,}); - replacement in libpijul/src/change.rs at line 1420
let hashed: Hashed<Local> = {let hashed: Hashed<Hunk<Option<Hash>, Local>> = { - replacement in libpijul/src/change.rs at line 1446
Some(serde_json::from_slice(&out)?)debug!("parsing unhashed: {:?}", std::str::from_utf8(&out));serde_json::from_slice(&out).ok() - replacement in libpijul/src/change/text_changes.rs at line 38
impl LocalChange<Local> {impl LocalChange<Hunk<Option<Hash>, Local>> { - file addition: noenc.rs[4.931000]
use super::{Atom, Change, ChangeError, Hashed, Local, LocalChange, Offsets};use crate::pristine::Hasher;use crate::Hash;#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]pub enum Hunk<Hash, Local> {FileMove {del: Atom<Hash>,add: Atom<Hash>,path: String,},FileDel {del: Atom<Hash>,contents: Option<Atom<Hash>>,path: String,},FileUndel {undel: Atom<Hash>,contents: Option<Atom<Hash>>,path: String,},FileAdd {add_name: Atom<Hash>,add_inode: Atom<Hash>,contents: Option<Atom<Hash>>,path: String,},SolveNameConflict {name: Atom<Hash>,path: String,},UnsolveNameConflict {name: Atom<Hash>,path: String,},Edit {change: Atom<Hash>,local: Local,},Replacement {change: Atom<Hash>,replacement: Atom<Hash>,local: Local,},SolveOrderConflict {change: Atom<Hash>,local: Local,},UnsolveOrderConflict {change: Atom<Hash>,local: Local,},ResurrectZombies {change: Atom<Hash>,local: Local,},}impl<H, L> From<Hunk<H, L>> for super::Hunk<H, L> {fn from(h: Hunk<H, L>) -> Self {match h {Hunk::FileMove { del, add, path } => super::Hunk::FileMove { del, add, path },Hunk::FileDel {del,contents,path,} => super::Hunk::FileDel {del,contents,path,encoding: None,},Hunk::FileUndel {undel,contents,path,} => super::Hunk::FileUndel {undel,contents,path,encoding: None,},Hunk::FileAdd {add_name,add_inode,contents,path,} => super::Hunk::FileAdd {add_name,add_inode,contents,path,encoding: None,},Hunk::SolveNameConflict { name, path } => super::Hunk::SolveNameConflict { name, path },Hunk::UnsolveNameConflict { name, path } => {super::Hunk::UnsolveNameConflict { name, path }}Hunk::Edit { change, local } => super::Hunk::Edit {change,local,encoding: None,},Hunk::Replacement {change,replacement,local,} => super::Hunk::Replacement {change,replacement,local,encoding: None,},Hunk::SolveOrderConflict { change, local } => {super::Hunk::SolveOrderConflict { change, local }}Hunk::UnsolveOrderConflict { change, local } => {super::Hunk::UnsolveOrderConflict { change, local }}Hunk::ResurrectZombies { change, local } => super::Hunk::ResurrectZombies {change,local,encoding: None,},}}}impl Change {/// Deserialise a change from the file given as input `file`.#[cfg(feature = "zstd")]pub(super) fn deserialize_noenc(offsets: Offsets,mut r: std::fs::File,hash: Option<&Hash>,) -> Result<Self, ChangeError> {use std::io::Read;debug!("offsets = {:?}", offsets);let mut buf = vec![0u8; (offsets.unhashed_off - Self::OFFSETS_SIZE) as usize];r.read_exact(&mut buf)?;let hashed: Hashed<Hunk<Option<Hash>, Local>> = {let mut s = zstd_seekable::Seekable::init_buf(&buf[..])?;let mut out = vec![0u8; offsets.hashed_len as usize];s.decompress(&mut out[..], 0)?;let mut hasher = Hasher::default();hasher.update(&out);let computed_hash = hasher.finish();if let Some(hash) = hash {if &computed_hash != hash {return Err(super::ChangeError::ChangeHashMismatch {claimed: *hash,computed: computed_hash,});}}bincode::deserialize_from(&out[..])?};buf.clear();buf.resize((offsets.contents_off - offsets.unhashed_off) as usize, 0);let unhashed = if buf.is_empty() {None} else {r.read_exact(&mut buf)?;let mut s = zstd_seekable::Seekable::init_buf(&buf[..])?;let mut out = vec![0u8; offsets.unhashed_len as usize];s.decompress(&mut out[..], 0)?;serde_json::from_slice(&out).ok()};debug!("unhashed = {:?}", unhashed);buf.clear();buf.resize((offsets.total - offsets.contents_off) as usize, 0);let contents = if r.read_exact(&mut buf).is_ok() {let mut s = zstd_seekable::Seekable::init_buf(&buf[..])?;let mut contents = vec![0u8; offsets.contents_len as usize];s.decompress(&mut contents[..], 0)?;contents} else {Vec::new()};debug!("contents = {:?}", contents);Ok(LocalChange {offsets,hashed: hashed.into(),unhashed,contents,})}}impl From<Hashed<Hunk<Option<Hash>, Local>>> for Hashed<super::Hunk<Option<Hash>, Local>> {fn from(hashed: Hashed<Hunk<Option<Hash>, Local>>) -> Self {Hashed {contents_hash: hashed.contents_hash,dependencies: hashed.dependencies,extra_known: hashed.extra_known,header: hashed.header,metadata: hashed.metadata,version: hashed.version,changes: hashed.changes.into_iter().map(|x| x.into()).collect(),}}} - replacement in libpijul/src/change/change_file.rs at line 7
hashed: Hashed<Local>,hashed: Hashed<Hunk<Option<Hash>, Local>>, - replacement in libpijul/src/change/change_file.rs at line 46
if offsets.version != VERSION {return Err(ChangeError::VersionMismatch);if offsets.version != VERSION && offsets.version != VERSION_NOENC {return Err(ChangeError::VersionMismatch {got: offsets.version,}); - replacement in libpijul/src/change/change_file.rs at line 56
let hashed: Hashed<Local> = {let hashed: Hashed<Hunk<Option<Hash>, Local>> = if offsets.version == VERSION { - edit in libpijul/src/change/change_file.rs at line 59
debug!("deserialize current version {:?}", buf2.len()); - edit in libpijul/src/change/change_file.rs at line 61
} else {assert_eq!(offsets.version, VERSION_NOENC);let mut s = zstd_seekable::Seekable::init_buf(&buf)?;s.decompress(&mut buf2, 0)?;debug!("deserialize noenc {:?}", buf2.len());let h: Hashed<noenc::Hunk<Option<Hash>, Local>> = bincode::deserialize(&buf2)?;h.into() - replacement in libpijul/src/change/change_file.rs at line 78
Some(toml::de::from_slice(&buf2)?)debug!("parsing unhashed: {:?}", std::str::from_utf8(&buf2));serde_json::from_slice(&buf2).ok() - replacement in libpijul/src/change/change_file.rs at line 115
pub fn hashed(&self) -> &Hashed<Local> {pub fn hashed(&self) -> &Hashed<Hunk<Option<Hash>, Local>> {