Debian Codegraph @

scripts/vlmerge

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use VCS::Lite;
7 use Getopt::Long;
8
9 my $output;
10
11 GetOptions(
12 'output=s' => \$output
13 );
14
15 if (@ARGV != 3) {
16 print <<END;
17
18 Usage: $0 [--output outfile] original changed1 changed2
19
20 If --output is not specified, the results are put in place
21 of the original, and the original is renamed to *.orig
22
23 END
24 exit;
25 }
26
27 my ($orig,$chg1,$chg2) = @ARGV;
28
29 my $el1 = VCS::Lite->new($orig);
30 my $el2 = VCS::Lite->new($chg1);
31 my $el3 = VCS::Lite->new($chg2);
32
33 my $el4 = $el1->merge($el2,$el3) or die "Merge failed";
34
35 if (!$output) {
36 rename $orig, "$orig.orig";
37 $output = $orig;
38 }
39
40 open MERGE,">$output";
41 print MERGE $el4->text;
42 close MERGE;
43