File: vldiff

package info (click to toggle)
libvcs-lite-perl 0.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: perl: 988; makefile: 2
file content (46 lines) | stat: -rwxr-xr-x 733 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl

use strict;
use warnings;

use VCS::Lite;
use Getopt::Long;

my $uflag = 0;
my $wintxt = '';

GetOptions(
	'unified+' => \$uflag,
	'window=s' => \$wintxt,
	);

if (@ARGV != 2) {
	print <<END;

Usage: $0 [options] file1 file2

Options can be:

	-u | --unified	output in diff -u format
	-w n | --window n	set window size to n lines either side
	-w m,n | --window m,n	set window to m lines before, n lines after
END
	exit;
}

my $el1 = VCS::Lite->new(shift @ARGV);
my $el2 = VCS::Lite->new(shift @ARGV);

my $win = 0;

if ($wintxt =~ /(\d+),(\d+)/) {
	$win = [$1,$2];
}
elsif ($wintxt =~ /(\d+)/) {
	$win = $1;
}

my $dt1 = $el1->delta($el2, window => $win);
my $diff = $uflag ? $dt1->udiff : $dt1->diff;

print $diff;