Skip to content

Commit 4592157

Browse files
author
fossdd
committed
Update pijul
1 parent a42b848 commit 4592157

File tree

5 files changed

+67
-49
lines changed

5 files changed

+67
-49
lines changed

libpijul/src/fs.rs

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,10 @@ impl<'txn, 'changes, T: GraphTxnT, P: ChangeStore + 'changes> Iterator
715715
.txn
716716
.find_block_end(&self.channel, parent.dest())
717717
.unwrap();
718+
if dest.start == dest.end {
719+
// non-null root.
720+
return None
721+
}
718722
let mut buf = std::mem::replace(&mut self.buf, Vec::new());
719723
let FileMetadata {
720724
basename,
@@ -771,7 +775,7 @@ where
771775
channel,
772776
pos.inode_vertex(),
773777
EdgeFlags::FOLDER | EdgeFlags::PARENT,
774-
EdgeFlags::FOLDER | EdgeFlags::PARENT | EdgeFlags::PSEUDO,
778+
EdgeFlags::FOLDER | EdgeFlags::PARENT | EdgeFlags::BLOCK | EdgeFlags::PSEUDO,
775779
)
776780
.map_err(|e| e.0)?,
777781
txn,
@@ -845,47 +849,57 @@ pub(crate) fn follow_oldest_path<T: ChannelTxnT, C: ChangeStore>(
845849
let mut ambiguous = false;
846850
for c in crate::path::components(path) {
847851
let mut next = None;
848-
for name in iter_adjacent(
849-
txn,
850-
txn.graph(channel),
851-
current.inode_vertex(),
852-
flag0,
853-
flag1,
854-
)? {
855-
let name = name?;
856-
let name_dest = txn.find_block(txn.graph(channel), name.dest()).unwrap();
857-
name_buf.clear();
858-
debug!("getting contents {:?}", name);
859-
changes
860-
.get_contents(
861-
|h| txn.get_external(&h).unwrap().map(|x| x.into()),
862-
*name_dest,
863-
&mut name_buf,
864-
)
865-
.map_err(FsErrorC::Changestore)?;
866-
let FileMetadata { basename, .. } = FileMetadata::read(&name_buf);
867-
if basename == c {
868-
let age = txn
869-
.get_changeset(txn.changes(&channel), &name.dest().change)
870-
.unwrap();
871-
if let Some((ref mut next, ref mut next_age)) = next {
872-
ambiguous = true;
873-
if age < *next_age {
874-
*next = name_dest;
875-
*next_age = age;
852+
'outer: loop {
853+
for name in iter_adjacent(
854+
txn,
855+
txn.graph(channel),
856+
current.inode_vertex(),
857+
flag0,
858+
flag1,
859+
)? {
860+
let name = name?;
861+
let name_dest = txn.find_block(txn.graph(channel), name.dest()).unwrap();
862+
if name_dest.start == name_dest.end {
863+
// non-null root, just continue.
864+
current = iter_adjacent(txn, txn.graph(channel), *name_dest, flag0, flag1)?
865+
.next()
866+
.unwrap()?
867+
.dest();
868+
break 'outer
869+
}
870+
name_buf.clear();
871+
debug!("getting contents {:?}", name);
872+
changes
873+
.get_contents(
874+
|h| txn.get_external(&h).unwrap().map(|x| x.into()),
875+
*name_dest,
876+
&mut name_buf,
877+
)
878+
.map_err(FsErrorC::Changestore)?;
879+
let FileMetadata { basename, .. } = FileMetadata::read(&name_buf);
880+
if basename == c {
881+
let age = txn
882+
.get_changeset(txn.changes(&channel), &name.dest().change)
883+
.unwrap();
884+
if let Some((ref mut next, ref mut next_age)) = next {
885+
ambiguous = true;
886+
if age < *next_age {
887+
*next = name_dest;
888+
*next_age = age;
889+
}
890+
} else {
891+
next = Some((name_dest, age));
876892
}
877-
} else {
878-
next = Some((name_dest, age));
879893
}
880894
}
881-
}
882-
if let Some((next, _)) = next {
883-
current = iter_adjacent(txn, txn.graph(channel), *next, flag0, flag1)?
884-
.next()
885-
.unwrap()?
886-
.dest()
887-
} else {
888-
return Err(FsErrorC::NotFound(FsNotFound(path.to_string())));
895+
if let Some((next, _)) = next {
896+
current = iter_adjacent(txn, txn.graph(channel), *next, flag0, flag1)?
897+
.next()
898+
.unwrap()?
899+
.dest()
900+
} else {
901+
return Err(FsErrorC::NotFound(FsNotFound(path.to_string())));
902+
}
889903
}
890904
}
891905
Ok((current, ambiguous))

libpijul/src/output/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ fn collect_children<T: GraphTxnT, P: ChangeStore>(
9999
files: &mut HashMap<String, Vec<(Vertex<ChangeId>, OutputItem)>>,
100100
) -> Result<(), PristineOutputError<P::Error, T::GraphError>> {
101101
debug!("path = {:?}, inode_pos = {:?}", path, inode_pos);
102+
debug!("prefix_basename = {:?}", prefix_basename);
102103
for e in iter_adjacent(
103104
txn,
104105
channel,
@@ -141,7 +142,7 @@ fn collect_children<T: GraphTxnT, P: ChangeStore>(
141142
EdgeFlags::FOLDER | EdgeFlags::PSEUDO | EdgeFlags::BLOCK,
142143
)? {
143144
let e = e?;
144-
debug!("e = {:?}", e);
145+
debug!("e' = {:?}", e);
145146
let name_vertex = txn.find_block(channel, e.dest()).unwrap();
146147
collect(
147148
txn,
@@ -171,6 +172,7 @@ fn collect<T: GraphTxnT, P: ChangeStore>(
171172
files: &mut HashMap<String, Vec<(Vertex<ChangeId>, OutputItem)>>,
172173
name_vertex: &Vertex<ChangeId>,
173174
) -> Result<(), PristineOutputError<P::Error, T::GraphError>> {
175+
// First, get the basename of the path we're outputting.
174176
let mut name_buf = Vec::new();
175177
let FileMetadata {
176178
basename,
@@ -187,6 +189,7 @@ fn collect<T: GraphTxnT, P: ChangeStore>(
187189
let mut name = path.to_string();
188190
if let Some(next) = prefix_basename {
189191
if next != basename {
192+
debug!("next = {:?} basename = {:?}", next, basename);
190193
return Ok(());
191194
}
192195
}

libpijul/src/output/output.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub fn output_repository_no_pending<
6363
where
6464
T::Channel: Send + Sync + 'static,
6565
{
66+
debug!("output_repository_no_pending: {:?}", prefix);
6667
output_repository(
6768
repo,
6869
changes,

libpijul/src/pristine/sanakirja.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,15 +2139,6 @@ impl<T> MutTxn<T> {
21392139
fn put_channel(&mut self, channel: ChannelRef<Self>) -> Result<(), SanakirjaError> {
21402140
debug!("Commit_channel.");
21412141
let channel = channel.r.read();
2142-
// Since we are replacing the value, we don't want to
2143-
// decrement its reference counter (which del would do), hence
2144-
// the transmute.
2145-
//
2146-
// This would normally be wrong. The only reason it works is
2147-
// because we know that dbs_channels has never been forked
2148-
// from another database, hence all the reference counts to
2149-
// its elements are 1 (and therefore represented as "not
2150-
// referenced" in Sanakirja).
21512142
debug!("Commit_channel, dbs_channels = {:?}", self.channels);
21522143
btree::del(&mut self.txn, &mut self.channels, &channel.name, None)?;
21532144
debug!(

libpijul/src/record.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ impl Builder {
374374
let e = e?;
375375
let child = txn.find_block(txn.graph(&*channel), e.dest()).unwrap();
376376
if child.start == child.end {
377+
// This is the "new" format, with multiple
378+
// roots, and `grandchild` is one of the
379+
// roots.
377380
let grandchild =
378381
iter_adjacent(&*txn, txn.graph(&*channel), *child, f0, f1)?
379382
.next()
@@ -389,9 +392,13 @@ impl Builder {
389392
grandchild,
390393
)?;
391394
} else {
395+
// Single-root repository, we need to follow
396+
// the root's children.
392397
has_nonempty_root = true
393398
}
394399
}
400+
debug!("has_nonempty_root: {:?}", has_nonempty_root);
401+
debug!("root_vertices: {:?}", root_vertices);
395402
if has_nonempty_root && !root_vertices.is_empty() {
396403
// This repository is mixed between "zero" roots,
397404
// and new-style-roots.
@@ -474,6 +481,7 @@ impl Builder {
474481
*r = Some((vertex.to_option(), (*age).into()))
475482
}
476483
}
484+
item.v_papa = vertex.to_option();
477485
self.push_children::<_, _, C>(
478486
&*txn,
479487
&*channel,
@@ -634,6 +642,7 @@ impl Builder {
634642
parent_inode: item.inode,
635643
basename: SmallString::new(),
636644
};
645+
debug!("fileid = {:?}", fileid);
637646
let mut has_matching_children = false;
638647
for x in txn.iter_tree(&fileid, None)? {
639648
let (fileid_, child_inode) = x?;

0 commit comments

Comments
 (0)