mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +00:00
conflicts: switch to multi-line regex, fix minor bug
The multi-line regex will be used for other purposes soon.
This commit is contained in:
parent
d095570718
commit
e2f12d91cc
2 changed files with 7 additions and 26 deletions
|
@ -19,7 +19,7 @@ use std::iter::zip;
|
||||||
|
|
||||||
use futures::{try_join, Stream, StreamExt, TryStreamExt};
|
use futures::{try_join, Stream, StreamExt, TryStreamExt};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::{Regex, RegexBuilder};
|
||||||
|
|
||||||
use crate::backend::{BackendError, BackendResult, CommitId, FileId, SymlinkId, TreeId, TreeValue};
|
use crate::backend::{BackendError, BackendResult, CommitId, FileId, SymlinkId, TreeId, TreeValue};
|
||||||
use crate::diff::{Diff, DiffHunk};
|
use crate::diff::{Diff, DiffHunk};
|
||||||
|
@ -47,10 +47,9 @@ const CONFLICT_PLUS_LINE_CHAR: u8 = CONFLICT_PLUS_LINE[0];
|
||||||
// separators. This could be useful to make it possible to allow conflict
|
// separators. This could be useful to make it possible to allow conflict
|
||||||
// markers inside the text of the conflicts.
|
// markers inside the text of the conflicts.
|
||||||
static CONFLICT_MARKER_REGEX: once_cell::sync::Lazy<Regex> = once_cell::sync::Lazy::new(|| {
|
static CONFLICT_MARKER_REGEX: once_cell::sync::Lazy<Regex> = once_cell::sync::Lazy::new(|| {
|
||||||
Regex::new(
|
RegexBuilder::new(r"^(<{7}|>{7}|%{7}|\-{7}|\+{7})( .*)?$")
|
||||||
r"(<{7}|>{7}|%{7}|\-{7}|\+{7})( .*)?
|
.multi_line(true)
|
||||||
",
|
.build()
|
||||||
)
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -611,7 +611,7 @@ fn test_parse_conflict_simple() {
|
||||||
)
|
)
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
// BUG: The conflict markers are too long and shouldn't parse (though we may
|
// The conflict markers are too long and shouldn't parse (though we may
|
||||||
// decide to change this in the future)
|
// decide to change this in the future)
|
||||||
insta::assert_debug_snapshot!(
|
insta::assert_debug_snapshot!(
|
||||||
parse_conflict(indoc! {b"
|
parse_conflict(indoc! {b"
|
||||||
|
@ -629,25 +629,7 @@ fn test_parse_conflict_simple() {
|
||||||
"},
|
"},
|
||||||
2
|
2
|
||||||
),
|
),
|
||||||
@r###"
|
@"None"
|
||||||
Some(
|
|
||||||
[
|
|
||||||
Resolved(
|
|
||||||
"line 1\n",
|
|
||||||
),
|
|
||||||
Conflicted(
|
|
||||||
[
|
|
||||||
"line 2\nleft\nline 4\n",
|
|
||||||
"line 2\nline 3\nline 4\n",
|
|
||||||
"right\n",
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Resolved(
|
|
||||||
"line 5\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
"###
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue