Skip to content

Commit 19f6a0e

Browse files
author
fossdd
committed
Update pijul
1 parent 29d744b commit 19f6a0e

File tree

7 files changed

+49
-15
lines changed

7 files changed

+49
-15
lines changed

libpijul/src/diff/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ fn make_old_lines<'a>(d: &'a vertex_buffer::Diff, r: &'a regex::bytes::Regex) ->
9696
} else {
9797
false
9898
};
99-
debug!("old = {:?}", l);
99+
if log_enabled!(log::Level::Debug) {
100+
if let Ok(l) = std::str::from_utf8(l) {
101+
debug!("old = {:?}", l);
102+
} else {
103+
debug!("old = {:?}", l);
104+
}
105+
}
100106
Line {
101107
l,
102108
cyclic,
@@ -112,7 +118,13 @@ fn make_old_lines<'a>(d: &'a vertex_buffer::Diff, r: &'a regex::bytes::Regex) ->
112118
fn make_new_lines<'a>(b: &'a [u8], sep: &'a regex::bytes::Regex) -> Vec<Line<'a>> {
113119
split::LineSplit::from_bytes_with_sep(b, sep)
114120
.map(|l| {
115-
debug!("new: {:?}", l);
121+
if log_enabled!(log::Level::Debug) {
122+
if let Ok(l) = std::str::from_utf8(l) {
123+
debug!("new = {:?}", l);
124+
} else {
125+
debug!("new = {:?}", l);
126+
}
127+
}
116128
let next_index = l.as_ptr() as usize + l.len() - b.as_ptr() as usize;
117129
Line {
118130
l,

libpijul/src/diff/replace.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,33 @@ pub(super) fn get_up_context(
136136
} else {
137137
diff.contents_a.len()
138138
};
139-
debug!("old_bytes {:?}", old_bytes);
140139
let mut up_context_idx = diff.last_vertex_containing(old_bytes - 1);
141140
let mut seen_conflict_markers = false;
142141
loop {
143-
debug!("up_context_idx = {:?}", up_context_idx);
144-
debug!("{:?}", diff.marker.get(&diff.pos_a[up_context_idx].pos));
145142
match diff.marker.get(&diff.pos_a[up_context_idx].pos) {
146143
None if seen_conflict_markers => {
147144
return vec![diff.pos_a[up_context_idx].vertex.end_pos().to_option()]
148145
}
149146
None => {
150147
let change = diff.pos_a[up_context_idx].vertex.change;
151148
let pos = diff.pos_a[up_context_idx].vertex.start;
152-
let offset = old_bytes - diff.pos_a[up_context_idx].pos;
153-
debug!("offset {:?} {:?}", pos.0, offset);
149+
let mut offset = old_bytes - diff.pos_a[up_context_idx].pos;
150+
// Here, in the case where one side of the conflict
151+
// ended with a "last line without a `\n`", the offset
152+
// might be off by one.
153+
//
154+
// We detect that case by testing whether the vertex
155+
// length is the same as the length of the "line".
156+
157+
let v_end = diff.pos_a[up_context_idx].vertex.end.0.into();
158+
if pos.0 + offset <= v_end {
159+
//
160+
} else if pos.0 + offset == v_end + 1 {
161+
assert_eq!(diff.contents_a[old_bytes - 1], b'\n');
162+
offset -= 1
163+
} else {
164+
panic!("{:?} {:?} {:?}", pos.0, offset, v_end);
165+
}
154166
return vec![Position {
155167
change: Some(change),
156168
pos: ChangePosition(pos.0 + offset),

libpijul/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<C: std::error::Error + 'static, T: GraphTxnT> std::fmt::Debug for FsErrorC<
7070
#[error("Path not found: {0}")]
7171
pub struct FsNotFound(String);
7272

73-
pub(crate) fn create_new_inode<T: TreeMutTxnT>(
73+
pub fn create_new_inode<T: TreeMutTxnT>(
7474
txn: &mut T,
7575
parent_id: &PathId,
7676
salt: u64,

libpijul/src/pristine/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ pub trait MutTxnT:
18901890
fn set_current_channel(&mut self, cur: &str) -> Result<(), Self::GraphError>;
18911891
}
18921892

1893-
pub(crate) fn put_inodes_with_rev<T: TreeMutTxnT>(
1893+
pub fn put_inodes_with_rev<T: TreeMutTxnT>(
18941894
txn: &mut T,
18951895
inode: &Inode,
18961896
position: &Position<ChangeId>,
@@ -1900,7 +1900,7 @@ pub(crate) fn put_inodes_with_rev<T: TreeMutTxnT>(
19001900
Ok(())
19011901
}
19021902

1903-
pub(crate) fn del_inodes_with_rev<T: TreeMutTxnT>(
1903+
pub fn del_inodes_with_rev<T: TreeMutTxnT>(
19041904
txn: &mut T,
19051905
inode: &Inode,
19061906
position: &Position<ChangeId>,
@@ -1913,7 +1913,7 @@ pub(crate) fn del_inodes_with_rev<T: TreeMutTxnT>(
19131913
}
19141914
}
19151915

1916-
pub(crate) fn put_tree_with_rev<T: TreeMutTxnT>(
1916+
pub fn put_tree_with_rev<T: TreeMutTxnT>(
19171917
txn: &mut T,
19181918
file_id: &PathId,
19191919
inode: &Inode,
@@ -1924,7 +1924,7 @@ pub(crate) fn put_tree_with_rev<T: TreeMutTxnT>(
19241924
Ok(())
19251925
}
19261926

1927-
pub(crate) fn del_tree_with_rev<T: TreeMutTxnT>(
1927+
pub fn del_tree_with_rev<T: TreeMutTxnT>(
19281928
txn: &mut T,
19291929
file_id: &PathId,
19301930
inode: &Inode,

libpijul/src/record.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,8 @@ impl Recorded {
808808
self.largest_file = self.largest_file.max(end.0.as_u64() - start.0.as_u64());
809809
contents.push(0);
810810
if end > start {
811+
>>>>>>> 0 [PDTUHOMV]
812+
<<<<<<< 0
811813
(
812814
Some(Atom::NewVertex(NewVertex {
813815
up_context: vec![Position {
@@ -1583,8 +1585,10 @@ impl Recorded {
15831585
self.recorded_inodes
15841586
.lock()
15851587
.insert(*inode, vertex.start_pos().to_option());
1586-
self.updatables
1587-
.insert(self.actions.len(), InodeUpdate::Deleted { inode: *inode });
1588+
self.updatables.insert(
1589+
self.actions.len() + 1,
1590+
InodeUpdate::Deleted { inode: *inode },
1591+
);
15881592
}
15891593
self.delete_inode_vertex::<_, _, W>(
15901594
changes,

libpijul/src/tests/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ fn record_all<T: MutTxnT, R: WorkingCopy, P: ChangeStore>(
9696
prefix: &str,
9797
) -> Result<Hash, anyhow::Error>
9898
where
99+
>>>>>>> 0 [SHSJ3Y53]
99100
T: MutTxnT + Send + Sync + 'static,
100101
R: WorkingCopy + Clone + Send + Sync + 'static,
101102
P: ChangeStore + Clone + Send + 'static,
103+
<<<<<<< 0
102104
R::Error: Send + Sync + 'static,
103105
{
104106
let (hash, _) = record_all_change(repo, store, txn, channel, prefix)?;

pijul/src/commands/change.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ impl Change {
2323
let changes = repo.changes;
2424

2525
let hash = if let Some(hash) = self.hash {
26-
txn.hash_from_prefix(&hash)?.0
26+
if let Some(h) = Hash::from_base32(hash.as_bytes()) {
27+
h
28+
} else {
29+
txn.hash_from_prefix(&hash)?.0
30+
}
2731
} else {
2832
let channel_name = txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL);
2933
let channel = if let Some(channel) = txn.load_channel(&channel_name)? {

0 commit comments

Comments
 (0)