replacement in pijul-remote/src/ssh.rs at line 4
[8.25667]→[8.1863:1887](∅→∅) − use std::path::PathBuf;
+ use std::path::{Path, PathBuf};
edit in pijul-remote/src/ssh.rs at line 12
+ use libpijul::changestore::filesystem::fmt_filename;
replacement in pijul-remote/src/ssh.rs at line 343
replacement in pijul-remote/src/ssh.rs at line 524
edit in pijul-remote/src/ssh.rs at line 528
+ let mut buf = PathBuf::new();
replacement in pijul-remote/src/ssh.rs at line 549
[8.692]→[8.692:1149](∅→∅) − libpijul::changestore::filesystem::push_filename(final_path, h);
− debug!("moving {:?} to {:?}", path, final_path);
− std::fs::create_dir_all(&final_path.parent().unwrap())?;
− let r = std::fs::rename(&path, &final_path);
− libpijul::changestore::filesystem::pop_filename(final_path);
+ let p = fmt_filename(&mut buf, &destdir, &h);
+ debug!("moving {:?} to {:?}", path, p);
+ std::fs::create_dir_all(&p.parent().unwrap())?;
+ let r = std::fs::rename(&path, &p);
replacement in pijul-remote/src/ssh.rs at line 556
[8.1273]→[8.1273:1814](∅→∅) − libpijul::changestore::filesystem::push_tag_filename(
− final_path, &h,
− );
− debug!("moving {:?} to {:?}", path, final_path);
− std::fs::create_dir_all(&final_path.parent().unwrap())?;
− let r = std::fs::rename(&path, &final_path);
− libpijul::changestore::filesystem::pop_filename(final_path);
+ let p = fmt_filename(&mut buf, &destdir, &h);
+ debug!("moving {:?} to {:?}", path, p);
+ std::fs::create_dir_all(&p.parent().unwrap())?;
+ let r = std::fs::rename(&path, &p);
replacement in pijul-remote/src/ssh.rs at line 583
[8.5342]→[3.0:135](∅→∅),
[3.135]→[3.135:179](∅→∅),
[3.179]→[3.179:259](∅→∅) − trace!(
− "writing to {:?} {:?} {:?}",
− path,
− final_path,
− hashes[*current]
− );
+ trace!("writing to {:?} {:?} {:?}", path, destdir, hashes[*current]);
replacement in pijul-remote/src/ssh.rs at line 934
[8.22]→[8.44372:44400](∅→∅),
[8.82]→[8.44372:44400](∅→∅),
[8.44372]→[8.44372:44400](∅→∅) edit in pijul-remote/src/ssh.rs at line 938
+ let mut buf = PathBuf::new();
replacement in pijul-remote/src/ssh.rs at line 950
[8.2148]→[8.2148:2306](∅→∅) − libpijul::changestore::filesystem::push_filename(&mut local, &c);
− let mut change_file = std::fs::File::open(&local)?;
+ let p = fmt_filename(&mut buf, &changes_dir, &c);
+ let mut change_file = std::fs::File::open(&p)?;
edit in pijul-remote/src/ssh.rs at line 963
[8.2875]→[8.2875:2956](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut local);
replacement in pijul-remote/src/ssh.rs at line 965
[8.3008]→[8.3008:3184](∅→∅) − libpijul::changestore::filesystem::push_tag_filename(&mut local, &c);
− let mut tag_file = libpijul::tag::OpenTagFile::open(&local, &c)?;
+ let p = fmt_filename(&mut buf, &changes_dir, &c);
+ let mut tag_file = libpijul::tag::OpenTagFile::open(&p, &c)?;
edit in pijul-remote/src/ssh.rs at line 976
[8.3575]→[8.3575:3656](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut local);
replacement in pijul-remote/src/ssh.rs at line 988
[8.60]→[8.8820:8855](∅→∅),
[8.3799]→[8.8820:8855](∅→∅),
[8.8820]→[8.8820:8855](∅→∅) − changes_dir: &mut PathBuf,
replacement in pijul-remote/src/ssh.rs at line 1000
[8.129]→[8.334:369](∅→∅),
[8.536]→[8.334:369](∅→∅),
[8.3918]→[8.334:369](∅→∅),
[8.334]→[8.334:369](∅→∅) − changes_dir: &mut PathBuf,
replacement in pijul-remote/src/ssh.rs at line 1004
[8.8923]→[8.671:715](∅→∅) − let path = changes_dir.join("tmp");
+ let tmp_file = changes_dir.join("tmp");
replacement in pijul-remote/src/ssh.rs at line 1006
[8.95]→[8.9044:9094](∅→∅),
[8.763]→[8.9044:9094](∅→∅),
[8.46580]→[8.9044:9094](∅→∅) − let file = std::fs::File::create(&path)?;
+ let file = std::fs::File::create(&tmp_file)?;
replacement in pijul-remote/src/ssh.rs at line 1010
[8.9211]→[8.9211:9229](∅→∅),
[8.9229]→[8.764:809](∅→∅) − path,
− final_path: changes_dir.clone(),
+ path: tmp_file,
+ destdir: changes_dir.to_path_buf(),
replacement in pijul-remote/src/local.rs at line 2
[8.63]→[8.11563:11587](∅→∅),
[8.291]→[8.11563:11587](∅→∅),
[8.4234]→[8.11563:11587](∅→∅),
[8.79745]→[8.11563:11587](∅→∅) − use std::path::PathBuf;
+ use std::path::{Path, PathBuf};
edit in pijul-remote/src/local.rs at line 6
+ use libpijul::changestore::filesystem::fmt_filename;
replacement in pijul-remote/src/local.rs at line 212
[8.82124]→[8.82124:82143](∅→∅) replacement in pijul-remote/src/local.rs at line 214
[8.831]→[8.82143:82171](∅→∅),
[8.3459]→[8.82143:82171](∅→∅),
[8.82143]→[8.82143:82171](∅→∅) edit in pijul-remote/src/local.rs at line 218
+ let mut buf = PathBuf::new();
+ let mut buf2 = PathBuf::new();
+
replacement in pijul-remote/src/local.rs at line 230
[8.82584]→[8.21554:21794](∅→∅) − match c {
− CS::Change(c) => {
− libpijul::changestore::filesystem::push_filename(&mut local, &c);
− libpijul::changestore::filesystem::push_filename(&mut self.changes_dir, &c);
+ let src = fmt_filename(&mut buf, &changes_dir, c);
+ let dest = fmt_filename(&mut buf2, &changes_dir, c);
+
+ std::fs::create_dir_all(&dest.parent().unwrap())?;
+ debug!("hard link {:?} {:?}", src, dest);
+ if std::fs::metadata(&dest).is_err() {
+ if std::fs::hard_link(&src, &dest).is_err() {
+ std::fs::copy(&src, &dest)?;
edit in pijul-remote/src/local.rs at line 239
[8.21812]→[8.21812:22055](∅→∅) − CS::State(c) => {
− libpijul::changestore::filesystem::push_tag_filename(&mut local, &c);
− libpijul::changestore::filesystem::push_tag_filename(&mut self.changes_dir, &c);
− }
edit in pijul-remote/src/local.rs at line 240
[8.22069]→[8.82751:82894](∅→∅),
[8.82751]→[8.82751:82894](∅→∅),
[8.82894]→[2.0:220](∅→∅),
[2.220]→[8.3529:3543](∅→∅),
[8.3529]→[8.3529:3543](∅→∅) − std::fs::create_dir_all(&self.changes_dir.parent().unwrap())?;
− debug!("hard link {:?} {:?}", local, self.changes_dir);
− if std::fs::metadata(&self.changes_dir).is_err() {
− if std::fs::hard_link(&local, &self.changes_dir).is_err() {
− std::fs::copy(&local, &self.changes_dir)?;
− }
− }
edit in pijul-remote/src/local.rs at line 241
[8.22108]→[8.22108:22265](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut local);
− libpijul::changestore::filesystem::pop_filename(&mut self.changes_dir);
replacement in pijul-remote/src/local.rs at line 260
[8.11726]→[8.83493:83512](∅→∅),
[8.83493]→[8.83493:83512](∅→∅) replacement in pijul-remote/src/local.rs at line 264
[8.1462]→[8.11839:11871](∅→∅),
[8.22379]→[8.11839:11871](∅→∅),
[8.11839]→[8.11839:11871](∅→∅) − mut path: &mut PathBuf,
edit in pijul-remote/src/local.rs at line 266
+ let mut buf = PathBuf::new();
+ let mut buf2 = PathBuf::new();
+
replacement in pijul-remote/src/local.rs at line 270
[8.2892]→[8.601:840](∅→∅),
[8.840]→[8.22880:22898](∅→∅),
[8.22880]→[8.22880:22898](∅→∅),
[8.22898]→[8.841:1065](∅→∅),
[8.1065]→[8.23102:23120](∅→∅),
[8.23102]→[8.23102:23120](∅→∅),
[8.23120]→[8.1066:1080](∅→∅) − match c {
− CS::Change(c) => {
− libpijul::changestore::filesystem::push_filename(&mut self.changes_dir, &c);
− libpijul::changestore::filesystem::push_filename(&mut path, &c);
− }
− CS::State(c) => {
− libpijul::changestore::filesystem::push_tag_filename(&mut self.changes_dir, &c);
− libpijul::changestore::filesystem::push_tag_filename(&mut path, &c);
− }
− }
+ let src = fmt_filename(&mut buf, &self.changes_dir, &c);
+ let dest = fmt_filename(&mut buf2, &dest_dir, &c);
+
replacement in pijul-remote/src/local.rs at line 275
[8.3616]→[8.1145:1245](∅→∅),
[8.1145]→[8.1145:1245](∅→∅),
[8.1245]→[7.3316:3404](∅→∅),
[8.1245]→[8.12157:12233](∅→∅),
[7.3404]→[8.12157:12233](∅→∅),
[8.23250]→[8.12157:12233](∅→∅),
[8.12157]→[8.12157:12233](∅→∅) − if std::fs::metadata(&path).is_ok() {
− debug!("metadata {:?} ok", path);
− libpijul::changestore::filesystem::pop_filename(&mut self.changes_dir);
− libpijul::changestore::filesystem::pop_filename(&mut path);
+ if std::fs::metadata(&dest).is_ok() {
+ debug!("metadata {:?} ok", dest);
replacement in pijul-remote/src/local.rs at line 280
[8.1286]→[8.1286:1478](∅→∅) − std::fs::create_dir_all(&path.parent().unwrap())?;
− if std::fs::hard_link(&self.changes_dir, &path).is_err() {
− std::fs::copy(&self.changes_dir, &path)?;
+ std::fs::create_dir_all(&dest.parent().unwrap())?;
+ if std::fs::hard_link(&src, &dest).is_err() {
+ std::fs::copy(&src, &dest)?;
replacement in pijul-remote/src/local.rs at line 284
[8.1517]→[8.1517:1673](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut self.changes_dir);
− libpijul::changestore::filesystem::pop_filename(&mut path);
edit in pijul-remote/src/lib.rs at line 9
+ use libpijul::changestore::filesystem;
+ use libpijul::changestore::filesystem::fmt_filename;
edit in pijul-remote/src/lib.rs at line 51
+
+ impl filesystem::CacheEntry for CS {
+ fn hash(&self) -> String {
+ match self {
+ CS::Change(v) => v.hash(),
+ CS::State(v) => v.hash(),
+ }
+ }
edit in pijul-remote/src/lib.rs at line 60
+ fn ext(&self) -> &str {
+ match self {
+ CS::Change(v) => v.ext(),
+ CS::State(v) => v.ext(),
+ }
+ }
+ }
+
replacement in pijul-remote/src/lib.rs at line 1131
[8.2441]→[8.662:686](∅→∅) replacement in pijul-remote/src/lib.rs at line 1139
− l.upload_changes(upload_bar, local, to_channel, changes)?
+ l.upload_changes(upload_bar, &changes_dir, to_channel, changes)?
replacement in pijul-remote/src/lib.rs at line 1142
− s.upload_changes(upload_bar, local, to_channel, changes)
+ s.upload_changes(upload_bar, &changes_dir, to_channel, changes)
replacement in pijul-remote/src/lib.rs at line 1146
− h.upload_changes(upload_bar, local, to_channel, changes)
+ h.upload_changes(upload_bar, &changes_dir, to_channel, changes)
replacement in pijul-remote/src/lib.rs at line 1152
+ changes_dir.to_path_buf(),
replacement in pijul-remote/src/lib.rs at line 1168
[8.256]→[8.66747:66775](∅→∅),
[8.10772]→[8.66747:66775](∅→∅),
[8.16081]→[8.66747:66775](∅→∅),
[8.66747]→[8.66747:66775](∅→∅) edit in pijul-remote/src/lib.rs at line 1245
[8.2757]→[8.1348:1472](∅→∅),
[8.1348]→[8.1348:1472](∅→∅) − let mut change_path_ = repo.path.clone();
− change_path_.push(DOT_DIR);
− change_path_.push("changes");
edit in pijul-remote/src/lib.rs at line 1246
+ let mut changes_dir = repo.changes_dir.clone();
replacement in pijul-remote/src/lib.rs at line 1253
[8.1838]→[8.1838:1877](∅→∅) edit in pijul-remote/src/lib.rs at line 1261
[8.69054]→[8.69054:69111](∅→∅) − let mut change_path_ = repo.changes_dir.clone();
replacement in pijul-remote/src/lib.rs at line 1267
[8.118]→[8.0:297](∅→∅),
[8.259]→[8.0:297](∅→∅),
[8.297]→[8.16450:16468](∅→∅),
[8.16450]→[8.16450:16468](∅→∅),
[8.448]→[8.440:454](∅→∅),
[8.1793]→[8.440:454](∅→∅),
[8.3173]→[8.440:454](∅→∅),
[8.16552]→[8.440:454](∅→∅),
[8.440]→[8.440:454](∅→∅) − match h {
− CS::Change(h) => {
− libpijul::changestore::filesystem::push_filename(&mut change_path_, h);
− }
− CS::State(h) => {
− libpijul::changestore::filesystem::push_tag_filename(&mut change_path_, h);
− }
− }
edit in pijul-remote/src/lib.rs at line 1271
[8.178]→[8.449:529](∅→∅),
[8.454]→[8.449:529](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut change_path_);
replacement in pijul-remote/src/lib.rs at line 1355
[8.1156]→[8.1156:1209](∅→∅) − let mut dep_path = repo.changes_dir.clone();
+ let changes_dir = repo.changes_dir.clone();
edit in pijul-remote/src/lib.rs at line 1358
+ let mut buf = PathBuf::new();
+
replacement in pijul-remote/src/lib.rs at line 1374
[8.1957]→[8.1957:2056](∅→∅) − libpijul::changestore::filesystem::push_filename(&mut dep_path, &dep);
+ let dep_path = fmt_filename(&mut buf, &changes_dir, &dep);
edit in pijul-remote/src/lib.rs at line 1376
[8.2136]→[8.2136:2228](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut dep_path);
edit in pijul-remote/src/http.rs at line 2
+ use libpijul::changestore::filesystem::fmt_filename;
replacement in pijul-remote/src/http.rs at line 8
[8.1932]→[8.1932:1956](∅→∅) − use std::path::PathBuf;
+ use std::path::{Path, PathBuf};
+ use std::sync::Arc;
replacement in pijul-remote/src/http.rs at line 28
[8.1215]→[8.101:124](∅→∅),
[8.2034]→[8.101:124](∅→∅),
[8.101]→[8.101:124](∅→∅) + base_dir: impl AsRef<Path>,
edit in pijul-remote/src/http.rs at line 31
+ let base_dir = base_dir.as_ref();
+ let mut buf = PathBuf::new();
+ let path = fmt_filename(&mut buf, &base_dir, &c);
+
replacement in pijul-remote/src/http.rs at line 36
[8.24028]→[8.24028:24180](∅→∅) − CS::Change(c) => {
− libpijul::changestore::filesystem::push_filename(&mut path, &c);
− ("change", c.to_base32())
− }
+ CS::Change(c) => ("change", c.to_base32()),
edit in pijul-remote/src/http.rs at line 38
[8.24206]→[8.24206:24287](∅→∅) − libpijul::changestore::filesystem::push_tag_filename(&mut path, &c);
replacement in pijul-remote/src/http.rs at line 152
[8.1649]→[8.1436:1460](∅→∅),
[8.24836]→[8.1436:1460](∅→∅),
[8.1252]→[8.1436:1460](∅→∅) edit in pijul-remote/src/http.rs at line 155
+ let path: Arc<Path> = Arc::from(path.to_path_buf().into_boxed_path());
replacement in pijul-remote/src/http.rs at line 229
[8.1014]→[8.876:904](∅→∅),
[8.4026]→[8.876:904](∅→∅),
[8.876]→[8.876:904](∅→∅) edit in pijul-remote/src/http.rs at line 233
+ let mut buf = PathBuf::new();
+
edit in pijul-remote/src/http.rs at line 252
+ let local = fmt_filename(&mut buf, &changes_dir, &c);
+
edit in pijul-remote/src/http.rs at line 256
[8.24954]→[8.24954:25040](∅→∅) − libpijul::changestore::filesystem::push_filename(&mut local, &c);
edit in pijul-remote/src/http.rs at line 262
[8.25277]→[8.25277:25367](∅→∅) − libpijul::changestore::filesystem::push_tag_filename(&mut local, &c);
edit in pijul-remote/src/http.rs at line 270
[8.25698]→[8.25698:25771](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut local);
replacement in pijul/src/commands/tag.rs at line 8
[8.255]→[8.2342:2427](∅→∅) − use libpijul::{ArcTxn, Base32, ChannelMutTxnT, ChannelTxnT, MutTxnT, TxnT, TxnTExt};
+ use libpijul::changestore::filesystem::fmt_filename;
+ use libpijul::{ArcTxn, Base32, ChannelMutTxnT, ChannelTxnT, Merkle, MutTxnT, TxnT, TxnTExt};
edit in pijul/src/commands/tag.rs at line 120
[8.2655]→[8.0:61](∅→∅),
[8.61]→[8.2764:2817](∅→∅),
[8.2764]→[8.2764:2817](∅→∅) − let mut tag_path = repo.changes_dir.clone();
− std::fs::create_dir_all(&tag_path)?;
replacement in pijul/src/commands/tag.rs at line 121
[8.2818]→[8.2818:2872](∅→∅),
[8.2872]→[8.62:101](∅→∅) − let mut temp_path = tag_path.clone();
− temp_path.push("tmp");
+ std::fs::create_dir_all(&repo.changes_dir)?;
+
+ let temp_path = repo.changes_dir.join("tmp");
replacement in pijul/src/commands/tag.rs at line 129
− libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
+ let mut buf = PathBuf::new();
+ let tag_path = fmt_filename(&mut buf, &repo.changes_dir, &h);
replacement in pijul/src/commands/tag.rs at line 145
[8.689]→[8.150:211](∅→∅),
[8.211]→[8.380:562](∅→∅),
[8.263]→[8.3678:3700](∅→∅),
[8.312]→[8.3678:3700](∅→∅),
[8.562]→[8.3678:3700](∅→∅),
[8.3678]→[8.3678:3700](∅→∅),
[8.433]→[8.3700:3725](∅→∅),
[8.3700]→[8.3700:3725](∅→∅),
[8.3725]→[8.0:59](∅→∅) − let mut tag_path = repo.changes_dir.clone();
− let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
− libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
− h
− } else {
− super::find_hash(&mut tag_path, &tag)?
+
+ let h = match Merkle::from_base32(tag.as_bytes()) {
+ None => super::find_hash(&repo.changes_dir, &tag)?,
+ Some(v) => v,
edit in pijul/src/commands/tag.rs at line 150
+
+ let mut buf = PathBuf::new();
+ let tag_path = fmt_filename(&mut buf, &repo.changes_dir, &h);
replacement in pijul/src/commands/tag.rs at line 171
[8.5721]→[8.369:430](∅→∅),
[8.430]→[8.638:820](∅→∅),
[8.482]→[8.6006:6112](∅→∅),
[8.820]→[8.6006:6112](∅→∅),
[8.6006]→[8.6006:6112](∅→∅) − let mut tag_path = repo.changes_dir.clone();
− let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
− libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
− h
− } else {
− super::find_hash(&mut tag_path, &tag)?
+
+ let h = match Merkle::from_base32(tag.as_bytes()) {
+ None => super::find_hash(&repo.changes_dir, &tag)?,
+ Some(v) => v,
edit in pijul/src/commands/tag.rs at line 177
+ let mut buf = PathBuf::new();
+ let tag_path = fmt_filename(&mut buf, &repo.changes_dir, &h);
+
replacement in pijul/src/commands/tag.rs at line 210
[6.882]→[6.882:1231](∅→∅) − let mut tag_path = repo.changes_dir.clone();
− let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
− libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
− h
− } else {
− super::find_hash(&mut tag_path, &tag)?
+
+ let h = match Merkle::from_base32(tag.as_bytes()) {
+ None => super::find_hash(&repo.changes_dir, &tag)?,
+ Some(v) => v,
replacement in pijul/src/commands/tag.rs at line 250
− let mut tag_path = repo.changes_dir.clone();
+ let mut buf = PathBuf::new();
replacement in pijul/src/commands/tag.rs at line 255
[8.26959]→[8.936:1029](∅→∅),
[8.936]→[8.936:1029](∅→∅) − libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &m);
+ let tag_path = fmt_filename(&mut buf, &repo.changes_dir, &m);
edit in pijul/src/commands/tag.rs at line 263
− libpijul::changestore::filesystem::pop_filename(&mut tag_path);
replacement in pijul/src/commands/pushpull.rs at line 317
[8.8905]→[8.8905:8947](∅→∅) − repo.changes_dir.clone(),
edit in pijul/src/commands/protocol.rs at line 11
+ use libpijul::changestore::filesystem::fmt_filename;
replacement in pijul/src/commands/protocol.rs at line 56
[8.1528]→[8.15774:15837](∅→∅),
[8.6860]→[8.15774:15837](∅→∅) − let mut repo = Repository::find_root(self.repo_path)?;
+ let repo = Repository::find_root(self.repo_path)?;
edit in pijul/src/commands/protocol.rs at line 62
+ let mut path_buf = PathBuf::new();
replacement in pijul/src/commands/protocol.rs at line 179
[8.137]→[8.34286:34448](∅→∅) − let mut tag_path = repo.changes_dir.clone();
− libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &state);
+ let tag_path = fmt_filename(&mut path_buf, &repo.changes_dir, &state);
replacement in pijul/src/commands/protocol.rs at line 192
[8.341]→[8.34919:35085](∅→∅) − let mut tag_path = repo.changes_dir.clone();
− libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &m);
+ let tag_path = fmt_filename(&mut path_buf, &repo.changes_dir, &state);
+
replacement in pijul/src/commands/protocol.rs at line 236
[8.128478]→[8.128478:128769](∅→∅) − libpijul::changestore::filesystem::push_filename(&mut repo.changes_dir, &h);
− debug!("repo = {:?}", repo.changes_dir);
− let mut f = std::fs::File::open(&repo.changes_dir)?;
− let size = std::fs::metadata(&repo.changes_dir)?.len();
+
+ let path = fmt_filename(&mut path_buf, &repo.changes_dir, &h);
+
+ debug!("repo = {:?}", path);
+ let mut f = std::fs::File::open(&path)?;
+ let size = std::fs::metadata(&path)?.len();
edit in pijul/src/commands/protocol.rs at line 261
[8.129500]→[8.129500:129588](∅→∅) − libpijul::changestore::filesystem::pop_filename(&mut repo.changes_dir);
replacement in pijul/src/commands/protocol.rs at line 268
[8.129958]→[8.129958:130096](∅→∅) − let mut path = repo.changes_dir.clone();
− libpijul::changestore::filesystem::push_filename(&mut path, &h);
+ let path = fmt_filename(&mut path_buf, &repo.changes_dir, &h);
edit in pijul/src/commands/mod.rs at line 2
replacement in pijul/src/commands/mod.rs at line 286
[8.69]→[8.1179:1297](∅→∅) − fn find_hash<B: libpijul::Base32>(
− path: &mut std::path::PathBuf,
− hash: &str,
− ) -> Result<B, anyhow::Error> {
+ fn find_hash<B: libpijul::Base32>(base_dir: &Path, hash: &str) -> Result<B, anyhow::Error> {
replacement in pijul/src/commands/mod.rs at line 291
+ let mut path = base_dir.join(a);
replacement in pijul/src/commands/apply.rs at line 86
[8.305]→[8.1149:1286](∅→∅) − let mut changes = repo.changes_dir.clone();
− super::find_hash(&mut changes, &ch)?
+ super::find_hash(&repo.changes_dir, &ch)?
edit in libpijul/src/changestore/filesystem.rs at line 35
+ }
+
+ pub trait CacheEntry {
+ fn hash(&self) -> String;
+ fn ext(&self) -> &str;
replacement in libpijul/src/changestore/filesystem.rs at line 42
[8.824522]→[8.824522:824742](∅→∅) − pub fn push_filename(changes_dir: &mut PathBuf, hash: &Hash) {
− let h32 = hash.to_base32();
− let (a, b) = h32.split_at(2);
− changes_dir.push(a);
− changes_dir.push(b);
− changes_dir.set_extension("change");
+ impl<T> CacheEntry for &T
+ where
+ T: CacheEntry,
+ {
+ fn hash(&self) -> String {
+ (*self).hash()
+ }
+
+ fn ext(&self) -> &str {
+ (*self).ext()
+ }
replacement in libpijul/src/changestore/filesystem.rs at line 55
[8.6588]→[8.6588:6811](∅→∅) − pub fn push_tag_filename(changes_dir: &mut PathBuf, hash: &Merkle) {
− let h32 = hash.to_base32();
− let (a, b) = h32.split_at(2);
− changes_dir.push(a);
− changes_dir.push(b);
− changes_dir.set_extension("tag");
+ impl CacheEntry for Hash {
+ fn hash(&self) -> String {
+ self.to_base32()
+ }
+
+ fn ext(&self) -> &str {
+ "change"
+ }
replacement in libpijul/src/changestore/filesystem.rs at line 65
[8.824745]→[8.824745:824840](∅→∅) − pub fn pop_filename(changes_dir: &mut PathBuf) {
− changes_dir.pop();
− changes_dir.pop();
+ impl CacheEntry for Merkle {
+ fn hash(&self) -> String {
+ self.to_base32()
+ }
+
+ fn ext(&self) -> &str {
+ "tag"
+ }
edit in libpijul/src/changestore/filesystem.rs at line 75
+ pub fn fmt_filename<'a, T>(buf: &'a mut PathBuf, changes_dir: &Path, entry: &T) -> &'a Path
+ where
+ T: CacheEntry,
+ {
+ let hash = entry.hash();
+ let (shard, rem) = hash.split_at(2);
+
+ buf.clear();
+ buf.push(changes_dir);
+ buf.push(shard);
+ buf.push(rem);
+ buf.set_extension(entry.ext());
+ buf
+ }
+
replacement in libpijul/src/changestore/filesystem.rs at line 91
[8.824861]→[8.824861:824914](∅→∅),
[8.824914]→[8.87778:87827](∅→∅),
[8.87827]→[8.824965:825005](∅→∅),
[8.824965]→[8.824965:825005](∅→∅) − pub fn filename(&self, hash: &Hash) -> PathBuf {
− let mut path = self.changes_dir.clone();
− push_filename(&mut path, hash);
+ pub fn filename<T>(&self, entry: &T) -> PathBuf
+ where
+ T: CacheEntry,
+ {
+ let mut path = PathBuf::new();
+ self.fmt_filename(&mut path, entry);
replacement in libpijul/src/changestore/filesystem.rs at line 100
[8.46730]→[8.46730:46882](∅→∅),
[8.46882]→[8.825005:825018](∅→∅),
[8.825005]→[8.825005:825018](∅→∅) − pub fn tag_filename(&self, hash: &Merkle) -> PathBuf {
− let mut path = self.changes_dir.clone();
− push_tag_filename(&mut path, hash);
− path
+ pub fn fmt_filename<'a, T>(&self, buf: &'a mut PathBuf, entry: &T) -> &'a Path
+ where
+ T: CacheEntry,
+ {
+ fmt_filename(buf, &self.changes_dir, entry)
replacement in libpijul/src/changestore/filesystem.rs at line 203
[8.46963]→[8.46963:47004](∅→∅) − let path = self.tag_filename(h);
+ let path = self.filename(h);