Skip to content

Commit 0c90829

Browse files
author
fossdd
committed
Update pijul
1 parent c4bb79c commit 0c90829

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4146
-1470
lines changed

Cargo.lock

Lines changed: 101 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@
109109
pijul-git = pijul.override { features = [ "git" ]; };
110110
});
111111

112-
defaultPackage = forAllSystems ({ system, ... }: self.packages.${system}.pijul);
112+
defaultPackage = forAllSystems (system: self.packages.${system}.pijul);
113113
};
114114
}

libpijul/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "libpijul"
33
description = "Core library of Pijul, a distributed version control system based on a sound theory of collaborative work."
4-
version = "1.0.0-alpha.51"
4+
version = "1.0.0-alpha.52"
55

66
repository = "https://nest.pijul.com/pijul/libpijul"
77
documentation = "https://docs.rs/libpijul"
@@ -59,6 +59,7 @@ include = [
5959
"src/pristine/inode_vertex.rs",
6060
"src/find_alive.rs",
6161
"src/tag.rs",
62+
"src/tag/txn.rs",
6263
"src/text_encoding.rs",
6364
"src/tests/performance.rs",
6465
"src/tests/file_conflicts.rs",
@@ -107,7 +108,7 @@ bitflags = "1.2"
107108
thiserror = "1.0"
108109
blake3 = "1.0"
109110
chrono = { version = "0.4", features = ["serde"] }
110-
pijul-macros = { path = "../pijul-macros", version = "0.4.0" }
111+
pijul-macros = { path = "../pijul-macros", version = "0.5.0" }
111112
bincode = "1.3"
112113
data-encoding = "2.3"
113114
diffs = "0.4"

libpijul/src/alive/dfs.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl Graph {
366366
channel: &T::Graph,
367367
scc: &Vector2<VertexId>,
368368
forward_scc: &HashSet<(usize, usize)>,
369-
forward: &mut Vec<(Vertex<ChangeId>, SerializedEdge)>,
369+
forward: &mut Vec<super::Redundant>,
370370
) -> Result<(), TxnErr<T::GraphError>> {
371371
for &(a, b) in forward_scc.iter() {
372372
for cousin in scc[a].iter() {
@@ -388,7 +388,10 @@ impl Graph {
388388
EdgeFlags::DELETED,
389389
)?
390390
{
391-
forward.push((self[*cousin].vertex, edge))
391+
forward.push(super::Redundant {
392+
v: self[*cousin].vertex,
393+
e: edge,
394+
})
392395
}
393396
}
394397
}

libpijul/src/alive/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ pub struct AliveVertex {
2121
pub extra: Vec<(Option<SerializedEdge>, VertexId)>,
2222
}
2323

24+
pub struct Redundant {
25+
pub(crate) v: Vertex<ChangeId>,
26+
pub(crate) e: SerializedEdge,
27+
}
28+
2429
bitflags! {
2530
struct Flags: u8 {
2631
const ZOMBIE = 4;

libpijul/src/alive/output.rs

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ fn output_conflict<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
2121
graph: &Graph,
2222
sccs: &Vector2<VertexId>,
2323
conflict: Path,
24-
) -> Result<(), FileError<P::Error, T::GraphError>> {
24+
) -> Result<(), FileError<P::Error, T>> {
2525
let mut stack = vec![ConflictStackElt {
2626
conflict: vec![conflict],
2727
side: 0,
2828
idx: 0,
2929
}];
30-
let mut is_zombie = false;
30+
let mut is_zombie = None;
31+
let mut id = 0;
3132
while let Some(mut elt) = stack.pop() {
3233
let n_sides = elt.conflict.len();
34+
let id0 = id;
3335
if n_sides > 1 && elt.side == 0 && elt.idx == 0 {
34-
line_buf.begin_conflict()?;
3536
elt.conflict.sort_by(|a, b| {
3637
let a_ = a
3738
.path
@@ -47,21 +48,48 @@ fn output_conflict<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
4748
.unwrap();
4849
a_.cmp(&b_)
4950
});
51+
match elt.conflict[elt.side].path[elt.idx] {
52+
PathElement::Scc { scc } => {
53+
let vid = sccs[scc][0];
54+
let ext = txn.get_external(&graph[vid].vertex.change)?.unwrap();
55+
line_buf.begin_conflict(id, &[&ext.into()])?;
56+
}
57+
_ => {
58+
line_buf.begin_conflict(id, &[])?;
59+
}
60+
}
61+
id += 1;
5062
}
5163

5264
let mut next = None;
5365
'outer: while elt.side < n_sides {
5466
if elt.side > 0 && elt.idx == 0 {
55-
if is_zombie {
56-
is_zombie = false;
57-
line_buf.end_zombie_conflict()?;
67+
if let Some(id) = is_zombie.take() {
68+
line_buf.end_zombie_conflict(id)?;
69+
}
70+
match elt.conflict[elt.side].path[elt.idx] {
71+
PathElement::Scc { scc } => {
72+
let vid = sccs[scc][0];
73+
let ext = txn.get_external(&graph[vid].vertex.change)?.unwrap();
74+
line_buf.conflict_next(id0, &[&ext.into()])?;
75+
}
76+
_ => {
77+
line_buf.conflict_next(id0, &[])?;
78+
}
5879
}
59-
line_buf.conflict_next()?;
6080
}
6181
while elt.idx < elt.conflict[elt.side].path.len() {
6282
match elt.conflict[elt.side].path[elt.idx] {
6383
PathElement::Scc { scc } => {
64-
output_scc(changes, txn, graph, &sccs[scc], &mut is_zombie, line_buf)?;
84+
output_scc(
85+
changes,
86+
txn,
87+
graph,
88+
&sccs[scc],
89+
&mut is_zombie,
90+
&mut id,
91+
line_buf,
92+
)?;
6593
elt.idx += 1;
6694
}
6795
PathElement::Conflict { ref mut sides } => {
@@ -82,23 +110,21 @@ fn output_conflict<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
82110

83111
if elt.side >= n_sides {
84112
if n_sides > 1 {
85-
if is_zombie {
86-
is_zombie = false;
87-
line_buf.end_zombie_conflict()?;
113+
if let Some(id) = is_zombie.take() {
114+
line_buf.end_zombie_conflict(id)?;
88115
}
89-
line_buf.end_conflict()?;
116+
line_buf.end_conflict(id0)?;
90117
}
91118
} else {
92-
if is_zombie {
93-
is_zombie = false;
94-
line_buf.end_zombie_conflict()?;
119+
if let Some(id) = is_zombie.take() {
120+
line_buf.end_zombie_conflict(id)?;
95121
}
96122
stack.push(elt);
97123
stack.push(next.unwrap())
98124
}
99125
}
100-
if is_zombie {
101-
line_buf.end_zombie_conflict()?;
126+
if let Some(id) = is_zombie.take() {
127+
line_buf.end_zombie_conflict(id)?;
102128
}
103129
Ok(())
104130
}
@@ -159,22 +185,26 @@ fn output_scc<T: GraphTxnT, B: VertexBuffer, P: ChangeStore>(
159185
txn: &T,
160186
graph: &Graph,
161187
scc: &[VertexId],
162-
is_zombie: &mut bool,
188+
is_zombie: &mut Option<usize>,
189+
id: &mut usize,
163190
vbuf: &mut B,
164-
) -> Result<(), FileError<P::Error, T::GraphError>> {
191+
) -> Result<(), FileError<P::Error, T>> {
192+
let id_cyclic = *id;
165193
if scc.len() > 1 {
166-
vbuf.begin_cyclic_conflict()?;
194+
vbuf.begin_cyclic_conflict(*id)?;
195+
*id += 1;
167196
}
168197
for &v in scc.iter() {
169198
let now = std::time::Instant::now();
170199
if graph[v].flags.contains(Flags::ZOMBIE) {
171-
if !*is_zombie {
172-
*is_zombie = true;
173-
vbuf.begin_zombie_conflict()?;
200+
if is_zombie.is_none() {
201+
*is_zombie = Some(*id);
202+
let hash = txn.get_external(&graph[v].vertex.change)?.unwrap();
203+
vbuf.begin_zombie_conflict(*id, &[&hash.into()])?;
204+
*id += 1
174205
}
175-
} else if *is_zombie {
176-
*is_zombie = false;
177-
vbuf.end_zombie_conflict()?;
206+
} else if let Some(id) = is_zombie.take() {
207+
vbuf.end_zombie_conflict(id)?;
178208
}
179209
crate::TIMERS.lock().unwrap().alive_write += now.elapsed();
180210

@@ -201,7 +231,7 @@ fn output_scc<T: GraphTxnT, B: VertexBuffer, P: ChangeStore>(
201231
}
202232
let now = std::time::Instant::now();
203233
if scc.len() > 1 {
204-
vbuf.end_cyclic_conflict()?;
234+
vbuf.end_cyclic_conflict(id_cyclic)?;
205235
}
206236
crate::TIMERS.lock().unwrap().alive_write += now.elapsed();
207237
Ok(())
@@ -213,8 +243,8 @@ pub fn output_graph<T: ChannelTxnT, B: VertexBuffer, P: ChangeStore>(
213243
channel: &T::Channel,
214244
line_buf: &mut B,
215245
graph: &mut Graph,
216-
forward: &mut Vec<(Vertex<ChangeId>, SerializedEdge)>,
217-
) -> Result<(), crate::output::FileError<P::Error, T::GraphError>> {
246+
forward: &mut Vec<super::Redundant>,
247+
) -> Result<(), crate::output::FileError<P::Error, T>> {
218248
if graph.lines.len() <= 1 {
219249
return Ok(());
220250
}

libpijul/src/alive/retrieve.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,10 @@ pub(crate) fn remove_forward_edges<T: GraphMutTxnT>(
117117
let (_, forward_scc) = graph.dfs(&scc);
118118
let mut forward = Vec::new();
119119
graph.collect_forward_edges(txn, channel, &scc, &forward_scc, &mut forward)?;
120-
for &(vertex, edge) in forward.iter() {
121-
let dest = *txn.find_block(channel, edge.dest()).unwrap();
122-
debug!(target:"libpijul::forward", "deleting forward edge {:?} {:?} {:?}", vertex, dest, edge);
123-
del_graph_with_rev(
124-
txn,
125-
channel,
126-
edge.flag(),
127-
vertex,
128-
dest,
129-
edge.introduced_by(),
130-
)?;
120+
for ve in forward.iter() {
121+
let dest = *txn.find_block(channel, ve.e.dest()).unwrap();
122+
debug!(target:"libpijul::forward", "deleting forward edge {:?} {:?} {:?}", ve.v, dest, ve.e);
123+
del_graph_with_rev(txn, channel, ve.e.flag(), ve.v, dest, ve.e.introduced_by())?;
131124
}
132125
Ok(())
133126
}

0 commit comments

Comments
 (0)