Skip to content

Commit a10b12f

Browse files
author
fossdd
committed
Update pijul
1 parent 6fcb20b commit a10b12f

File tree

16 files changed

+281
-201
lines changed

16 files changed

+281
-201
lines changed

libpijul/src/alive/output.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct ConflictStackElt {
1616

1717
fn output_conflict<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
1818
changes: &P,
19-
txn: &T,
20-
channel: &T::Channel,
19+
txn: &ArcTxn<T>,
20+
channel: &ChannelRef<T>,
2121
line_buf: &mut B,
2222
graph: &Graph,
2323
sccs: &Vector2<VertexId>,
@@ -34,17 +34,25 @@ fn output_conflict<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
3434
while let Some(mut elt) = stack.pop() {
3535
let n_sides = elt.conflict.len();
3636
if n_sides > 1 && elt.side == 0 && elt.idx == 0 {
37+
let txn = txn.read();
38+
let channel = channel.read();
3739
elt.conflict.sort_by(|a, b| {
3840
let a_ = a
3941
.path
4042
.iter()
41-
.map(|a| a.oldest_vertex(changes, txn, channel, graph, sccs).unwrap())
43+
.map(|a| {
44+
a.oldest_vertex(changes, &*txn, &*channel, graph, sccs)
45+
.unwrap()
46+
})
4247
.min()
4348
.unwrap();
4449
let b_ = b
4550
.path
4651
.iter()
47-
.map(|b| b.oldest_vertex(changes, txn, channel, graph, sccs).unwrap())
52+
.map(|b| {
53+
b.oldest_vertex(changes, &*txn, &*channel, graph, sccs)
54+
.unwrap()
55+
})
4856
.min()
4957
.unwrap();
5058
a_.cmp(&b_)
@@ -70,6 +78,7 @@ fn output_conflict<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
7078
match elt.conflict[elt.side].path[elt.idx] {
7179
PathElement::Scc { scc } => {
7280
let vid = sccs[scc][0];
81+
let txn = txn.read();
7382
let ext = txn.get_external(&graph[vid].vertex.change)?.unwrap();
7483
line_buf.conflict_next(elt.id, &[&ext.into()])?;
7584
}
@@ -184,7 +193,7 @@ impl PathElement {
184193

185194
fn output_scc<T: GraphTxnT, B: VertexBuffer, P: ChangeStore>(
186195
changes: &P,
187-
txn: &T,
196+
txn: &ArcTxn<T>,
188197
graph: &Graph,
189198
scc: &[VertexId],
190199
is_zombie: &mut Option<usize>,
@@ -201,6 +210,7 @@ fn output_scc<T: GraphTxnT, B: VertexBuffer, P: ChangeStore>(
201210
if graph[v].flags.contains(Flags::ZOMBIE) {
202211
if is_zombie.is_none() {
203212
*is_zombie = Some(*id);
213+
let txn = txn.read();
204214
let hash = txn.get_external(&graph[v].vertex.change)?.unwrap();
205215
vbuf.begin_zombie_conflict(*id, &[&hash.into()])?;
206216
*id += 1
@@ -216,7 +226,7 @@ fn output_scc<T: GraphTxnT, B: VertexBuffer, P: ChangeStore>(
216226
let now = std::time::Instant::now();
217227
let result = changes
218228
.get_contents(
219-
|p| txn.get_external(&p).unwrap().map(|x| x.into()),
229+
|p| txn.read().get_external(&p).unwrap().map(|x| x.into()),
220230
vertex,
221231
buf,
222232
)
@@ -241,8 +251,8 @@ fn output_scc<T: GraphTxnT, B: VertexBuffer, P: ChangeStore>(
241251

242252
pub fn output_graph<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
243253
changes: &P,
244-
txn: &T,
245-
channel: &T::Channel,
254+
txn: &ArcTxn<T>,
255+
channel: &ChannelRef<T>,
246256
line_buf: &mut B,
247257
graph: &mut Graph,
248258
forward: &mut Vec<super::Redundant>,
@@ -253,8 +263,11 @@ pub fn output_graph<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
253263
let now0 = std::time::Instant::now();
254264
let scc = graph.tarjan(); // SCCs are given here in reverse order.
255265
let (conflict_tree, forward_scc) = graph.dfs(&scc);
256-
graph.collect_forward_edges(txn, txn.graph(channel), &scc, &forward_scc, forward)?;
257-
266+
{
267+
let txn = txn.read();
268+
let channel = channel.read();
269+
graph.collect_forward_edges(&*txn, txn.graph(&*channel), &scc, &forward_scc, forward)?;
270+
}
258271
crate::TIMERS.lock().unwrap().alive_graph += now0.elapsed();
259272
let now1 = std::time::Instant::now();
260273
debug!("conflict_tree = {:?}", conflict_tree);

libpijul/src/change/parse.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ fn parse_file_del_hunk(i: &str) -> IResult<&str, PrintableHunk> {
7070
} else {
7171
(i, Vec::new())
7272
};
73-
let (i, contents) = parse_contents('-', encoding.clone(), i)?;
73+
let (i, contents) = if encoding.is_none() {
74+
(i, Vec::new())
75+
} else {
76+
parse_contents('-', encoding.clone(), i)?
77+
};
7478
Ok((
7579
i,
7680
FileDel {

libpijul/src/diff/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ impl Recorded {
129129
pub(crate) fn diff<T: ChannelTxnT, P: ChangeStore>(
130130
&mut self,
131131
changes: &P,
132-
txn: &T,
133-
channel: &T::Channel,
132+
txn: &ArcTxn<T>,
133+
channel: &ChannelRef<T>,
134134
algorithm: Algorithm,
135135
stop_early: bool,
136136
path: String,
@@ -144,6 +144,8 @@ impl Recorded {
144144
self.largest_file = self.largest_file.max(b.len() as u64);
145145
let mut d = vertex_buffer::Diff::new(inode, path.clone(), a);
146146
output_graph(changes, txn, channel, &mut d, a, &mut self.redundant)?;
147+
let txn = txn.read();
148+
let channel = channel.read();
147149
// TODO pass through both encodings and use that to decide
148150
debug!("encoding = {:?}", encoding);
149151
let (lines_a, lines_b) = if encoding.is_none() {
@@ -171,8 +173,8 @@ impl Recorded {
171173
for r in 0..dd.len() {
172174
if dd[r].old_len > 0 {
173175
self.delete(
174-
txn,
175-
txn.graph(channel),
176+
&*txn,
177+
txn.graph(&*channel),
176178
&d,
177179
&dd,
178180
&mut conflict_contexts,

libpijul/src/fs.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ pub fn inode_filename<T: TreeTxnT>(
168168
txn: &T,
169169
inode: Inode,
170170
) -> Result<Option<String>, TreeErr<T::TreeError>> {
171+
debug!("inode_filename {:?}", inode);
171172
let mut components = Vec::new();
172173
let mut current = inode;
173174
loop {
@@ -193,12 +194,13 @@ pub fn inode_filename<T: TreeTxnT>(
193194
}
194195
path.push_str(c.as_str());
195196
}
197+
debug!("inode_filename = {:?}", path);
196198
Ok(Some(path))
197199
}
198200

199201
/// Record the information that `parent_inode` is now a parent of
200202
/// file `filename`, and `filename` has inode `child_inode`.
201-
fn make_new_child<T: TreeMutTxnT>(
203+
pub fn make_new_child<T: TreeMutTxnT>(
202204
txn: &mut T,
203205
parent_inode: Inode,
204206
filename: &str,
@@ -439,7 +441,7 @@ pub struct WorkingCopyIterator<'txn, T: TreeTxnT> {
439441
}
440442

441443
impl<'txn, T: TreeTxnT> Iterator for WorkingCopyIterator<'txn, T> {
442-
type Item = Result<(Inode, String), T::TreeError>;
444+
type Item = Result<(Inode, String, bool), T::TreeError>;
443445
fn next(&mut self) -> Option<Self::Item> {
444446
loop {
445447
if let Some((inode, name)) = self.stack.pop() {
@@ -452,6 +454,7 @@ impl<'txn, T: TreeTxnT> Iterator for WorkingCopyIterator<'txn, T> {
452454
Ok(iter) => iter,
453455
Err(e) => return Some(Err(e.0)),
454456
};
457+
let mut is_folder = false;
455458
for x in iter {
456459
let (k, v) = match x {
457460
Ok(x) => x,
@@ -462,6 +465,7 @@ impl<'txn, T: TreeTxnT> Iterator for WorkingCopyIterator<'txn, T> {
462465
} else if k.parent_inode > inode {
463466
break;
464467
}
468+
is_folder = true;
465469
if !k.basename.is_empty() {
466470
let mut name = name.clone();
467471
crate::path::push(&mut name, k.basename.as_str());
@@ -470,7 +474,7 @@ impl<'txn, T: TreeTxnT> Iterator for WorkingCopyIterator<'txn, T> {
470474
}
471475
(&mut self.stack[len..]).reverse();
472476
if !name.is_empty() {
473-
return Some(Ok((inode, name)));
477+
return Some(Ok((inode, name, is_folder)));
474478
}
475479
} else {
476480
return None;

0 commit comments

Comments
 (0)