Debian Codegraph @

scripts/vldiff

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use VCS::Lite;
7 use Getopt::Long;
8
9 my $uflag = 0;
10 my $wintxt = '';
11
12 GetOptions(
13 'unified+' => \$uflag,
14 'window=s' => \$wintxt,
15 );
16
17 if (@ARGV != 2) {
18 print <<END;
19
20 Usage: $0 [options] file1 file2
21
22 Options can be:
23
24 -u | --unified output in diff -u format
25 -w n | --window n set window size to n lines either side
26 -w m,n | --window m,n set window to m lines before, n lines after
27 END
28 exit;
29 }
30
31 my $el1 = VCS::Lite->new(shift @ARGV);
32 my $el2 = VCS::Lite->new(shift @ARGV);
33
34 my $win = 0;
35
36 if ($wintxt =~ /(\d+),(\d+)/) {
37 $win = [$1,$2];
38 }
39 elsif ($wintxt =~ /(\d+)/) {
40 $win = $1;
41 }
42
43 my $dt1 = $el1->delta($el2, window => $win);
44 my $diff = $uflag ? $dt1->udiff : $dt1->diff;
45
46 print $diff;