1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: diff.coretag,v 1.4 2007-03-30 23:40:54 pajamian Exp $
10 UserTag diff Order current previous
11 UserTag diff attrAlias curr current prev previous
13 UserTag diff Version $Revision: 1.4 $
14 UserTag diff Routine <<EOR
16 my ($curr, $prev, $opt) = @_;
18 $opt->{flags} .= ' -c' if $opt->{context};
19 $opt->{flags} .= ' -u' if $opt->{unified};
22 $data_opt->{safe_data} = 1 if $opt->{safe_data};
24 unless($opt->{flags} =~ /^[-\s\w.]*$/) {
25 Log("diff tag: Security violation with flags: $opt->{flags}");
26 return "Security violation with flags: $opt->{flags}. Logged.";
29 my ($currfn, $prevfn);
31 if($curr =~ /^(\w+)::(.*?)::(.*)/) {
32 my ($table, $col, $key) = ($1, $2, $3);
33 $currfn = "tmp/$Vend::SessionName.current";
34 my $data = tag_data($table, $col, $key, $data_opt);
36 $data =~ s/\r\n?/\n/g;
37 $data .= "\n" unless substr($data, -1, 1) eq "\n";
39 Vend::Util::writefile(">$currfn", $data);
45 if($prev =~ /^(\w+)::(.*?)::(.*)/) {
46 my ($table, $col, $key) = ($1, $2, $3);
47 $prevfn = "tmp/$Vend::SessionName.previous";
48 my $data = tag_data($table, $col, $key, $data_opt);
50 $data =~ s/\r\n?/\n/g;
51 $data .= "\n" unless substr($data, -1, 1) eq "\n";
53 Vend::Util::writefile(">$prevfn", $data);
59 #Debug("diff command: 'diff $opt->{flags} $prevfn $currfn'");
60 return `diff $opt->{flags} $prevfn $currfn`;