Recursive add
[?]
Dec 5, 2020, 1:10 PM
4OCC6D42GZYRDLH3NSKXMJTRKXP7UZ6Z3YNGCNUT7NT6WBDBCBIACDependencies
- [2]
R3H7D42UDebugging `pijul git`: proper error reporting - [3]
BZSC7VMYaddress clippy lints - [4]
BAUL3WR2Format, versions, README - [5]
TZVUNELWDocumentation comments - [6]
JP3BYVXXFixing file paths on Windows - [7]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [8]
YDKNUL6BAdd `diff --short` that lists changes without showing them
Change contents
- edit in pijul/src/commands/file_operations.rs at line 91
#[clap(short = 'r', long = "recursive")]recursive: bool, - edit in pijul/src/commands/file_operations.rs at line 101
let mut stderr = std::io::stderr(); - replacement in pijul/src/commands/file_operations.rs at line 102[4.171591]→[4.171591:171720](∅→∅),[4.171720]→[3.454:540](∅→∅),[3.540]→[4.171806:171880](∅→∅),[4.171806]→[4.171806:171880](∅→∅)
debug!("{:?}", path);if let Some(p) = path.file_name() {if let Some(p) = p.to_str() {if p.ends_with('~') || (p.starts_with('#') && p.ends_with('#')) {continue;}}info!("Adding {:?}", path);if self.paths.len() > 1 && !libpijul::working_copy::filesystem::ignore_filter_path(path){continue; - replacement in pijul/src/commands/file_operations.rs at line 107
let path = path.canonicalize()?;let meta = std::fs::metadata(&path)?;let path = if let Ok(path) = path.strip_prefix(&repo.path) {pathif self.recursive {use libpijul::working_copy::filesystem::*;if let Ok((full, prefix)) = get_prefix(Some(&repo.path), path) {repo.working_copy.add_prefix_rec(&mut txn, &repo.path, &full, &prefix)?} - replacement in pijul/src/commands/file_operations.rs at line 114
continue;};let path_str = path.to_str().unwrap();if !txn.is_tracked(&path_str) {writeln!(stderr, "Adding {:?}", path)?;info!("Adding {:?}", path);txn.add(&path_str, meta.is_dir())?let path = path.canonicalize()?;let meta = std::fs::metadata(&path)?;let path = if let Ok(path) = path.strip_prefix(&repo.path) {path} else {continue;};let path_str = path.to_str().unwrap();if !txn.is_tracked(&path_str) {txn.add(&path_str, meta.is_dir())?} - edit in libpijul/src/working_copy/filesystem.rs at line 8
}pub fn ignore_filter(entry: &ignore::DirEntry) -> bool {ignore_filter_path(entry.path()) - edit in libpijul/src/working_copy/filesystem.rs at line 14
pub fn ignore_filter_path(path: &std::path::Path) -> bool {debug!("ignore_filter_path {:?}", path);if let Some(file) = path.file_name() {if let Some(file) = file.to_str() {!file.ends_with("~") && !file.starts_with("#")} else {false}} else {true}}/// From a path on the filesystem, return the canonical path (a `PathBuf`), and a/// prefix relative to the root of the repository (a `String`). - edit in libpijul/src/working_copy/filesystem.rs at line 83
}Ok(())}pub fn add_prefix_rec<T: crate::MutTxnTExt + crate::TxnTExt>(&self,txn: &mut T,repo_path: &Path,full: &Path,prefix: &str,) -> Result<(), anyhow::Error> {debug!("record_prefix {:?}", prefix);let repo_path_ = std::fs::canonicalize(repo_path)?;debug!("full = {:?}", full);let meta = std::fs::metadata(&full);debug!("meta = {:?}", meta);debug!("{:?}", full.strip_prefix(&repo_path_));if let Ok(meta) = meta {if meta.is_dir() {let mut walk = WalkBuilder::new(&full);walk.standard_filters(true);let walk = walk.build();for entry in walk {let entry = entry?;let p = entry.path();if let Some(p) = p.file_name() {if let Some(p) = p.to_str() {if p.ends_with("~") || (p.starts_with("#") && p.ends_with("#")) {continue;}}}debug!("entry path = {:?} {:?}", entry.path(), repo_path);if let Ok(path) = entry.path().strip_prefix(&repo_path_) {let path_str = path.to_str().unwrap();if !txn.is_tracked(&path_str) {info!("Adding {:?}", path);txn.add(path_str, entry.file_type().unwrap().is_dir())?} else {debug!("already tracked {:?}", path_str)}} else {debug!("entry = {:?}", entry.path());}}} else if let Ok(path) = full.strip_prefix(&repo_path_) {let path_str = path.to_str().unwrap();if !txn.is_tracked(&path_str) {info!("Adding file {:?}", path);txn.add(path_str, false)?}} - edit in libpijul/src/working_copy/filesystem.rs at line 151
debug!("record_prefix {:?}", prefix);let repo_path_ = std::fs::canonicalize(repo_path)?; - replacement in libpijul/src/working_copy/filesystem.rs at line 152[4.211500]→[4.211500:212689](∅→∅),[4.212753]→[4.212753:213373](∅→∅),[4.213429]→[4.213429:213590](∅→∅)
debug!("full = {:?}", full);let meta = std::fs::metadata(&full);debug!("meta = {:?}", meta);debug!("{:?}", full.strip_prefix(&repo_path_));if let Ok(meta) = meta {if meta.is_dir() {let mut walk = WalkBuilder::new(&full);walk.standard_filters(true);let walk = walk.build();for entry in walk {let entry = entry?;let p = entry.path();if let Some(p) = p.file_name() {if let Some(p) = p.to_str() {if p.ends_with("~") || (p.starts_with("#") && p.ends_with("#")) {continue;}}}debug!("entry path = {:?} {:?}", entry.path(), repo_path);if let Ok(path) = entry.path().strip_prefix(&repo_path_) {let path_str = path.to_str().unwrap();if !txn.is_tracked(&path_str) {info!("Adding {:?}", path);txn.add(path_str, entry.file_type().unwrap().is_dir())?} else {debug!("already tracked {:?}", path_str)}} else {debug!("entry = {:?}", entry.path());}}} else if let Ok(path) = full.strip_prefix(&repo_path_) {let path_str = path.to_str().unwrap();if !txn.is_tracked(&path_str) {info!("Adding file {:?}", path);txn.add(path_str, false)?}}}self.add_prefix_rec(txn, repo_path, &full, &prefix)?;