/
diff.coretag
52 lines (45 loc) · 1.44 KB
/
diff.coretag
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
47
48
49
50
51
52
UserTag diff Order current previous
UserTag diff attrAlias curr current prev previous
UserTag diff addAttr
UserTag diff Routine <<EOR
sub {
my ($curr, $prev, $opt) = @_;
$opt->{flags} .= ' -c' if $opt->{context};
$opt->{flags} .= ' -u' if $opt->{unified};
my $data_opt = {};
$data_opt->{safe_data} = 1 if $opt->{safe_data};
unless($opt->{flags} =~ /^[-\s\w.]*$/) {
Log("diff tag: Security violation with flags: $opt->{flags}");
return "Security violation with flags: $opt->{flags}. Logged.";
}
my ($currfn, $prevfn);
if($curr =~ /^(\w+)::(.*?)::(.*)/) {
my ($table, $col, $key) = ($1, $2, $3);
$currfn = "tmp/$Vend::SessionName.current";
my $data = tag_data($table, $col, $key, $data_opt);
if ($opt->{ascii}) {
$data =~ s/\r\n?/\n/g;
$data .= "\n" unless substr($data, -1, 1) eq "\n";
}
Vend::Util::writefile(">$currfn", $data);
}
else {
$currfn = $curr;
}
if($prev =~ /^(\w+)::(.*?)::(.*)/) {
my ($table, $col, $key) = ($1, $2, $3);
$prevfn = "tmp/$Vend::SessionName.previous";
my $data = tag_data($table, $col, $key, $data_opt);
if ($opt->{ascii}) {
$data =~ s/\r\n?/\n/g;
$data .= "\n" unless substr($data, -1, 1) eq "\n";
}
Vend::Util::writefile(">$prevfn", $data);
}
else {
$prevfn = $prev;
}
#Debug("diff command: 'diff $opt->{flags} $prevfn $currfn'");
return `diff $opt->{flags} $prevfn $currfn`;
}
EOR