3 unstable releases

0.2.0 Aug 14, 2024
0.1.1 Aug 12, 2024
0.1.0 Apr 14, 2024

#1116 in Command line utilities

Download history 1006/week @ 2024-09-07 367/week @ 2024-09-14 547/week @ 2024-09-21 780/week @ 2024-09-28 340/week @ 2024-10-05 290/week @ 2024-10-12 432/week @ 2024-10-19 390/week @ 2024-10-26 274/week @ 2024-11-02 1208/week @ 2024-11-09 1101/week @ 2024-11-16 394/week @ 2024-11-23 354/week @ 2024-11-30 376/week @ 2024-12-07 393/week @ 2024-12-14 347/week @ 2024-12-21

1,527 downloads per month
Used in 5 crates (via debian-analyzer)

Apache-2.0 and maybe GPL-2.0+

56KB
1.5K SLoC

Merge3

A rust implementation of 3-way merge of texts.

Given BASE, OTHER, THIS, tries to produce a combined text incorporating the changes from both BASE->OTHER and BASE->THIS. All three will typically be sequences of lines.

Usage

From the command-line::


$ echo foo > mine
$ echo bar > base
$ echo blah > other
$ merge3 mine base other > merged
$ cat merged

Or from rust:


use merge3::Merge3;

fn main() {
    let base = vec!["common\n", "base\n"];
    let this = vec!["common\n", "a\n"];
    let other = vec!["common\n", "b\n"];

    let m3 = Merge3::new(&base, &this, &other);

    for line in m3.merge_lines() {
        println!("{}", line);
    }
}

lib.rs:

Merge3

A rust implementation of 3-way merge of texts.

Given BASE, OTHER, THIS, tries to produce a combined text incorporating the changes from both BASE->OTHER and BASE->THIS. All three will typically be sequences of lines.

Example

use merge3::Merge3;

let base = vec!["common\n", "base\n"];
let this = vec!["common\n", "a\n"];
let other = vec!["common\n", "b\n"];

let m3 = Merge3::new(&base, &this, &other);

for line in m3.merge_lines(false, &merge3::StandardMarkers::default()) {
    println!("{}", line);
}

Dependencies

~31–305KB