4OCC6D42GZYRDLH3NSKXMJTRKXP7UZ6Z3YNGCNUT7NT6WBDBCBIAC
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;
let path = path.canonicalize()?;
let meta = std::fs::metadata(&path)?;
let path = if let Ok(path) = path.strip_prefix(&repo.path) {
path
if 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)?
}
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())?
}
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`).
}
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)?
}
}
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)?;