Function diffy::merge

source · []
pub fn merge<'a>(
    ancestor: &'a str,
    ours: &'a str,
    theirs: &'a str
) -> Result<String, String>
Expand description

Merge two files given a common ancestor.

Returns Ok(String) upon a successful merge. Returns Err(String) if there were conflicts, with the conflicting regions marked with conflict markers.

Merging two files without conflicts

let original = "\
Devotion
Dominion
Odium
Preservation
Ruin
Cultivation
Honor
Endowment
Autonomy
Ambition
";
let a = "\
Odium
Preservation
Ruin
Cultivation
Endowment
Autonomy
";
let b = "\
Devotion
Dominion
Odium
Harmony
Cultivation
Honor
Endowment
Autonomy
Ambition
";

let expected = "\
Odium
Harmony
Cultivation
Endowment
Autonomy
";

assert_eq!(merge(original, a, b).unwrap(), expected);