Fix most clippy warnings

laumann
Oct 10, 2023, 7:49 PM
CV3S2Z2RTSL5F3RW3CZTGABGF7R6TRTO24LH45V6H2JHOWYZKJUAC

Dependencies

  • [2] KPGRBRHS export only the files touched by each change
  • [3] EBE4NGXW Add progress-interval flag
  • [4] R3XMFPCY import and export marks
  • [5] ATRA7XTT RIIR: factor out Repository struct
  • [6] OZUZ5H6D Use marks for commits
  • [7] D467LQZ6 Load identities
  • [8] T3IX7GG7 Pass deletions and renames to Git
  • [9] YELSOJNY Avoid exporting files twice
  • [10] FIIUZR4L Include file content
  • [11] RVRUZGHU Factor out load_channel function
  • [12] FRQZB7LJ quote and escape filenames
  • [13] IKID4WPY Include "state" for each change.
  • [14] YNZMKRJD include more information in log
  • [15] VK2ZYIOF deduplicate blobs
  • [16] QWLMNP5F new ChangeStore implementation
  • [17] UFSP7C7B Export metadata
  • [18] W7HZ5VFM RIIR: list changes
  • [*] TQBJZLD7 RIIR: hello, world

Change contents

  • edit in src/repo.rs at line 1
    [4.32]
    [2.0]
    use std::cmp::Ordering;
  • replacement in src/repo.rs at line 99
    [4.818][4.81:149]()
    let change_store = EagerChangeStore::from_root(&repo_path);
    [4.818]
    [4.818]
    let change_store = EagerChangeStore::from_root(repo_path);
  • replacement in src/repo.rs at line 103
    [4.481][4.481:778]()
    match env::var("HOME") {
    Ok(home) => {
    Self::load_identities(
    &mut identities,
    &Path::new(&home).join(".config/pijul/identities"),
    )
    .unwrap_or(());
    }
    Err(..) => {}
    [4.481]
    [4.778]
    if let Ok(home) = env::var("HOME") {
    Self::load_identities(
    &mut identities,
    &Path::new(&home).join(".config/pijul/identities"),
    )
    .unwrap_or(());
  • replacement in src/repo.rs at line 111
    [4.789][4.443:474](),[4.819][4.443:474]()
    return Ok(Repository {
    [4.789]
    [4.610]
    Ok(Repository {
  • replacement in src/repo.rs at line 116
    [4.814][4.522:534](),[4.522][4.522:534]()
    });
    [4.814]
    [4.121]
    })
  • replacement in src/repo.rs at line 125
    [4.1015][4.1015:1423]()
    match fs::read_to_string(dir.join(file?.path()).join("identity.toml")) {
    Ok(content) => {
    let id: Identity = toml::from_str(&content)?;
    identities.insert(
    id.public_key.key,
    format!("{} <{}>", id.display_name, id.email),
    );
    }
    Err(..) => {}
    [4.1015]
    [4.1423]
    if let Ok(content) = fs::read_to_string(dir.join(file?.path()).join("identity.toml")) {
    let id: Identity = toml::from_str(&content)?;
    identities.insert(
    id.public_key.key,
    format!("{} <{}>", id.display_name, id.email),
    );
  • replacement in src/repo.rs at line 133
    [4.1447][4.1447:1470]()
    return Ok(());
    [4.1447]
    [4.1470]
    Ok(())
  • replacement in src/repo.rs at line 154
    [4.1522][4.1522:1770]()
    match self.identities.get(key) {
    Some(name) => {
    return name.to_string();
    }
    None => {
    return format!("{} <>", key);
    }
    }
    [4.1522]
    [4.1770]
    return self
    .identities
    .get(key)
    .map_or_else(|| format!("{} <>", key), Into::into);
  • replacement in src/repo.rs at line 161
    [4.633][4.633:798]()
    if let Some(email) = a.0.get("email") {
    return format!("{} <{}>", name, email);
    }
    return format!("{} <>", name);
    [4.633]
    [4.798]
    return format!(
    "{} <{}>",
    name,
    a.0.get("email").map(|e| e.as_str()).unwrap_or("")
    );
  • replacement in src/repo.rs at line 172
    [4.1008][4.1008:1041]()
    return "<>".to_string();
    [4.1008]
    [4.1041]
    "<>".into()
  • replacement in src/repo.rs at line 188
    [4.1260][4.1260:1309]()
    .map(|a| self.author_string(&a))
    [4.1260]
    [4.1309]
    .map(|a| self.author_string(a))
  • replacement in src/repo.rs at line 201
    [4.1434][4.1434:1462]()
    return Ok(changes);
    [4.1434]
    [4.647]
    Ok(changes)
  • replacement in src/repo.rs at line 205
    [4.725][4.150:230]()
    let change_store = EagerChangeStore::from_root(&Path::new(&self.path));
    [4.725]
    [4.851]
    let change_store = EagerChangeStore::from_root(Path::new(&self.path));
  • replacement in src/repo.rs at line 208
    [4.984][4.984:1012]()
    return Ok(Sandbox {
    [4.984]
    [4.1012]
    Ok(Sandbox {
  • replacement in src/repo.rs at line 212
    [4.1076][4.1076:1088]()
    });
    [4.1076]
    [4.1088]
    })
  • replacement in src/repo.rs at line 237
    [4.1912][4.1912:1935]()
    return Ok(());
    [4.1912]
    [4.1935]
    Ok(())
  • replacement in src/repo.rs at line 250
    [2.433][2.433:561]()
    if int_ < int {
    continue;
    } else if int_ > int {
    break;
    [2.433]
    [2.561]
    match int_.cmp(int) {
    Ordering::Less => continue,
    Ordering::Greater => break,
    Ordering::Equal => {
    if let Some((path, _)) = libpijul::fs::find_path(
    &self.change_store,
    &*txn,
    &*self.channel.read(),
    false,
    *inode,
    )? {
    touched_paths.insert(path);
    } else {
    touched_paths.clear();
    break;
    }
    }
  • edit in src/repo.rs at line 268
    [2.579][2.579:992]()
    if let Some((path, _)) = libpijul::fs::find_path(
    &self.change_store,
    &*txn,
    &*self.channel.read(),
    false,
    *inode,
    )? {
    touched_paths.insert(path);
    } else {
    touched_paths.clear();
    break;
    }
  • replacement in src/repo.rs at line 280
    [2.1232][2.1232:1664]()
    match last {
    Some(last_path) => {
    // If `last_path` is a prefix (in the path sense) of `path`, skip.
    if last_path.len() < path.len() {
    let (pre_last, post_last) = path.split_at(last_path.len());
    if pre_last == last_path && post_last.starts_with("/") {
    continue;
    }
    [2.1232]
    [2.1664]
    if let Some(last_path) = last {
    // If `last_path` is a prefix (in the path sense) of `path`, skip.
    if last_path.len() < path.len() {
    let (pre_last, post_last) = path.split_at(last_path.len());
    if pre_last == last_path && post_last.starts_with('/') {
    continue;
  • edit in src/repo.rs at line 288
    [2.1704][2.1704:1729]()
    _ => (),
  • replacement in src/repo.rs at line 303
    [2.2080][4.129:152](),[4.2355][4.129:152]()
    return Ok(fs);
    [2.2080]
    [4.1462]
    Ok(fs)
  • replacement in src/repo.rs at line 402
    [4.817][4.5612:5634](),[4.5612][4.5612:5634]()
    return Ok(f);
    [4.817]
    [4.5634]
    Ok(f)
  • replacement in src/main.rs at line 39
    [4.121][3.733:823](),[3.823][4.219:239](),[4.219][4.219:239]()
    match cli.marks {
    Some(ref filename) => stream.load_marks(filename).unwrap(),
    None => (),
    [4.121]
    [4.239]
    if let Some(ref filename) = cli.marks {
    stream.load_marks(filename).unwrap();
  • replacement in src/main.rs at line 69
    [4.573][3.1190:1280](),[3.1280][4.671:691](),[4.671][4.671:691]()
    match cli.marks {
    Some(ref filename) => stream.save_marks(filename).unwrap(),
    None => (),
    [4.573]
    [4.939]
    if let Some(ref filename) = cli.marks {
    stream.save_marks(filename).unwrap();
  • replacement in src/fast_export.rs at line 25
    [4.317][4.317:336]()
    return result;
    [4.317]
    [4.336]
    result
  • replacement in src/fast_export.rs at line 40
    [4.426][4.407:499]()
    pub fn new(branch_name: String) -> FastExportStream {
    return FastExportStream {
    [4.426]
    [4.499]
    pub fn new(branch_name: String) -> Self {
    FastExportStream {
  • replacement in src/fast_export.rs at line 50
    [4.79][4.599:610](),[4.6007][4.599:610](),[4.599][4.599:610]()
    };
    [4.79]
    [4.610]
    }
  • replacement in src/fast_export.rs at line 56
    [4.1070][4.1070:1970]()
    match &op {
    FileOp::Modify { fw } => {
    let ct = fw.content.lock().unwrap();
    let content: &[u8] = &*ct;
    let h = sha256::digest(content);
    let mut new_blob = false;
    let blob_mark = *self.blob_marks.entry(h).or_insert_with(|| {
    new_blob = true;
    self.max_blob_mark += 1;
    self.max_blob_mark
    });
    file_marks.insert(fw.name.clone(), blob_mark);
    if new_blob {
    println!("blob");
    println!("mark :{}", blob_mark);
    println!("data {}", content.len());
    std::io::stdout().write_all(content).unwrap();
    println!("");
    }
    [4.1070]
    [4.1970]
    if let FileOp::Modify { fw } = &op {
    let ct = fw.content.lock().unwrap();
    let content: &[u8] = &ct;
    let h = sha256::digest(content);
    let mut new_blob = false;
    let blob_mark = *self.blob_marks.entry(h).or_insert_with(|| {
    new_blob = true;
    self.max_blob_mark += 1;
    self.max_blob_mark
    });
    file_marks.insert(fw.name.clone(), blob_mark);
    if new_blob {
    println!("blob");
    println!("mark :{}", blob_mark);
    println!("data {}", content.len());
    std::io::stdout().write_all(content).unwrap();
    println!();
  • edit in src/fast_export.rs at line 74
    [4.1988][4.1988:2013]()
    _ => (),
  • replacement in src/fast_export.rs at line 90
    [4.893][4.557:606](),[4.557][4.557:606]()
    let committer = if c.authors.len() > 0 {
    [4.893]
    [4.606]
    let committer = if c.authors.is_empty() {
    "<>"
    } else {
  • edit in src/fast_export.rs at line 94
    [4.632][4.632:666]()
    } else {
    "<>"
  • replacement in src/fast_export.rs at line 102
    [4.1010][4.894:917](),[4.917][4.6530:6676](),[4.6676][4.1108:1123](),[4.1108][4.1108:1123](),[4.1123][4.6677:6700]()
    match parent {
    Some(p) => match self.commit_marks.get(&p) {
    Some(p_mark) => println!("from :{}", p_mark),
    None => {}
    },
    None => {}
    [4.1010]
    [4.6700]
    if let Some(p) = parent {
    if let Some(p_mark) = self.commit_marks.get(&p) {
    println!("from :{}", p_mark);
    }
  • replacement in src/fast_export.rs at line 114
    [4.2302][4.2302:2389]()
    FileOp::Delete { path } => println!("D \"{}\"", escape_string(&path)),
    [4.2302]
    [4.2389]
    FileOp::Delete { path } => println!("D \"{}\"", escape_string(path)),
  • replacement in src/fast_export.rs at line 116
    [4.2438][4.2438:2528]()
    println!("R \"{}\" \"{}\"", escape_string(&old), escape_string(&new))
    [4.2438]
    [4.2528]
    println!("R \"{}\" \"{}\"", escape_string(old), escape_string(new))
  • replacement in src/fast_export.rs at line 120
    [4.1082][4.1082:1104]()
    println!("");
    [4.1157]
    [4.1093]
    println!();
  • replacement in src/fast_export.rs at line 126
    [4.1265][4.1265:1338]()
    let state = libpijul::Merkle::from_base32(&caps[2].as_bytes())?;
    [4.1265]
    [4.1338]
    let state = libpijul::Merkle::from_base32(caps[2].as_bytes())?;
  • replacement in src/fast_export.rs at line 150
    [4.2225][4.2225:2248]()
    return Ok(());
    [4.2225]
    [4.2248]
    Ok(())
  • replacement in src/fast_export.rs at line 154
    [4.2332][4.2332:2385]()
    std::fs::write(&filename, &self.mark_file)?;
    [4.2332]
    [4.2385]
    std::fs::write(filename, &self.mark_file)?;
  • replacement in src/changestore.rs at line 49
    [4.1738][4.1738:1778]()
    if let Some(_) = r.get(h) {
    [4.1738]
    [4.1778]
    if r.get(h).is_some() {
  • replacement in src/changestore.rs at line 56
    [4.1919][4.1919:1978]()
    let p = Change::deserialize(&file_name, Some(h))?;
    [4.1919]
    [4.1978]
    let p = Change::deserialize(file_name, Some(h))?;
  • replacement in src/changestore.rs at line 83
    [4.2693][4.2693:2730]()
    if let Some(t) = r.get(&h) {
    [4.2693]
    [4.2730]
    if let Some(t) = r.get(h) {