Skip to content

Commit c703861

Browse files
author
fossdd
committed
Update pijul
1 parent ba9ce95 commit c703861

File tree

7 files changed

+48
-33
lines changed

7 files changed

+48
-33
lines changed

libpijul/src/chardetng/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,7 @@ impl EncodingDetector {
30043004
}
30053005
for (i, candidate) in self.candidates.iter().enumerate().skip(Self::FIRST_NORMAL) {
30063006
if let Some(score) = candidate.score(i, tld_type, expectation_is_valid) {
3007+
debug!("score = {:?} {:?}", i, score);
30073008
if score > max {
30083009
max = score;
30093010
encoding = candidate.encoding();

libpijul/src/record.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,8 @@ where
14741474
}
14751475
}
14761476

1477+
debug!("alive = {:#?}", alive);
1478+
14771479
for ((from, to), intro) in alive {
14781480
if intro.len() > 1 || !moved.resurrect.is_empty() {
14791481
for introduced_by in intro {

pijul/src/commands/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ fn make_changelist<S: libpijul::changestore::ChangeStore>(
173173
.unwrap();
174174
let mut first_p = true;
175175
for p in pullable {
176+
use ::log::*;
177+
debug!("make_changelist {:?}", p);
176178
if !first_p {
177179
writeln!(v, "").unwrap();
178180
}
@@ -191,7 +193,7 @@ fn make_changelist<S: libpijul::changestore::ChangeStore>(
191193
changes.get_header(&p)?
192194
}
193195
CS::State(p) => {
194-
writeln!(v, "t{}\n", p.to_base32()).unwrap();
196+
writeln!(v, "{}\n", p.to_base32()).unwrap();
195197
changes.get_tag_header(&p)?
196198
}
197199
};
@@ -226,8 +228,9 @@ fn make_changelist<S: libpijul::changestore::ChangeStore>(
226228
/// Parses a list of hashes from a slice of bytes.
227229
/// Everything that is not a line consisting of a
228230
/// valid hash and nothing else will be ignored.
229-
fn parse_changelist(o: &[u8]) -> Vec<crate::remote::CS> {
231+
fn parse_changelist(o: &[u8], states: &[CS]) -> Vec<crate::remote::CS> {
230232
use libpijul::Base32;
233+
let states: std::collections::HashSet<&CS> = states.iter().collect();
231234
if let Ok(o) = std::str::from_utf8(o) {
232235
o.lines()
233236
.filter_map(|l| {
@@ -236,11 +239,13 @@ fn parse_changelist(o: &[u8]) -> Vec<crate::remote::CS> {
236239
l,
237240
libpijul::Merkle::from_base32(l.as_bytes())
238241
);
239-
if l.starts_with("t") {
240-
libpijul::Merkle::from_base32(&l.as_bytes()[1..]).map(crate::remote::CS::State)
241-
} else {
242-
libpijul::Hash::from_base32(l.as_bytes()).map(crate::remote::CS::Change)
242+
let h_ = libpijul::Hash::from_base32(l.as_bytes()).map(crate::remote::CS::Change);
243+
if let Some(h) = h_ {
244+
if states.contains(&h) {
245+
return h_;
246+
}
243247
}
248+
libpijul::Merkle::from_base32(&l.as_bytes()[..]).map(crate::remote::CS::State)
244249
})
245250
.collect()
246251
} else {

pijul/src/commands/pushpull.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl Push {
301301
} else {
302302
let mut o = make_changelist(&repo.changes, &to_upload, "push")?;
303303
loop {
304-
let d = parse_changelist(&edit::edit_bytes(&o[..])?);
304+
let d = parse_changelist(&edit::edit_bytes(&o[..])?, &to_upload);
305305
let comp = complete_deps(&repo.changes, &to_upload, &d)?;
306306
if comp.len() == d.len() {
307307
break comp;
@@ -453,7 +453,7 @@ impl Pull {
453453
if !self.all {
454454
let mut o = make_changelist(&repo.changes, &to_download, "pull")?;
455455
to_download = loop {
456-
let d = parse_changelist(&edit::edit_bytes(&o[..])?);
456+
let d = parse_changelist(&edit::edit_bytes(&o[..])?, &to_download);
457457
let comp = complete_deps(&repo.changes, &to_download, &d)?;
458458
if comp.len() == d.len() {
459459
break comp;

pijul/src/commands/unrecord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Unrecord {
7575
.take(number_of_changes)
7676
.collect::<Vec<_>>();
7777
let o = make_changelist(&repo.changes, &hashes_, "unrecord")?;
78-
for h in parse_changelist(&edit::edit_bytes(&o[..])?).iter() {
78+
for h in parse_changelist(&edit::edit_bytes(&o[..])?, &hashes_).iter() {
7979
if let CS::Change(h) = h {
8080
hashes.push((*h, *txn.get_internal(&h.into())?.unwrap()))
8181
}

pijul/src/remote/local.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,29 @@ impl Local {
198198
mut path: &mut PathBuf,
199199
) -> Result<(), anyhow::Error> {
200200
while let Some(c) = hashes.recv().await {
201-
if let CS::Change(c) = c {
202-
libpijul::changestore::filesystem::push_filename(&mut self.changes_dir, &c);
203-
libpijul::changestore::filesystem::push_filename(&mut path, &c);
204-
super::PROGRESS.borrow_mut().unwrap()[pro_n].incr();
205-
if std::fs::metadata(&path).is_ok() {
206-
debug!("metadata {:?} ok", path);
207-
libpijul::changestore::filesystem::pop_filename(&mut path);
208-
continue;
201+
match c {
202+
CS::Change(c) => {
203+
libpijul::changestore::filesystem::push_filename(&mut self.changes_dir, &c);
204+
libpijul::changestore::filesystem::push_filename(&mut path, &c);
209205
}
210-
std::fs::create_dir_all(&path.parent().unwrap())?;
211-
if std::fs::hard_link(&self.changes_dir, &path).is_err() {
212-
std::fs::copy(&self.changes_dir, &path)?;
206+
CS::State(c) => {
207+
libpijul::changestore::filesystem::push_tag_filename(&mut self.changes_dir, &c);
208+
libpijul::changestore::filesystem::push_tag_filename(&mut path, &c);
213209
}
214-
debug!("hard link done");
215-
libpijul::changestore::filesystem::pop_filename(&mut self.changes_dir);
210+
}
211+
super::PROGRESS.borrow_mut().unwrap()[pro_n].incr();
212+
if std::fs::metadata(&path).is_ok() {
213+
debug!("metadata {:?} ok", path);
216214
libpijul::changestore::filesystem::pop_filename(&mut path);
215+
continue;
216+
}
217+
std::fs::create_dir_all(&path.parent().unwrap())?;
218+
if std::fs::hard_link(&self.changes_dir, &path).is_err() {
219+
std::fs::copy(&self.changes_dir, &path)?;
217220
}
221+
debug!("hard link done");
222+
libpijul::changestore::filesystem::pop_filename(&mut self.changes_dir);
223+
libpijul::changestore::filesystem::pop_filename(&mut path);
218224
debug!("sent");
219225
send.send(c).await?;
220226
}

pijul/src/remote/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,14 +1082,19 @@ impl RemoteRepo {
10821082
let mut change_path_ = repo.changes_dir.clone();
10831083
let mut to_download = HashSet::with_capacity(to_apply.len());
10841084
for h in to_apply {
1085-
if let CS::Change(h) = h {
1086-
libpijul::changestore::filesystem::push_filename(&mut change_path_, h);
1087-
if std::fs::metadata(&change_path_).is_err() {
1088-
hash_send.send(CS::Change(*h))?;
1089-
to_download.insert(CS::Change(*h));
1085+
match h {
1086+
CS::Change(h) => {
1087+
libpijul::changestore::filesystem::push_filename(&mut change_path_, h);
10901088
}
1091-
libpijul::changestore::filesystem::pop_filename(&mut change_path_);
1089+
CS::State(h) => {
1090+
libpijul::changestore::filesystem::push_tag_filename(&mut change_path_, h);
1091+
}
1092+
}
1093+
if std::fs::metadata(&change_path_).is_err() {
1094+
hash_send.send(*h)?;
1095+
to_download.insert(*h);
10921096
}
1097+
libpijul::changestore::filesystem::pop_filename(&mut change_path_);
10931098
}
10941099
std::mem::drop(hash_send);
10951100

@@ -1300,11 +1305,7 @@ impl RemoteRepo {
13001305
});
13011306

13021307
for c in changes {
1303-
let c = if let CS::Change(c) = c {
1304-
c
1305-
} else {
1306-
unreachable!()
1307-
};
1308+
let c = if let CS::Change(c) = c { c } else { continue };
13081309
let sc = c.into();
13091310
if repo
13101311
.changes

0 commit comments

Comments
 (0)