> > also are you sure that we need to have this kind of diffs?
> >
> > # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> > # ! WARNING: generated by Apache::ParseSource/0.02
> > -# ! Sun Aug 19 10:32:09 2001
> > +# ! Sun Aug 26 01:23:32 2001
> > # ! do NOT edit, any changes will be lost !
> > # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>
> it would be nice if the date was not changed if contents are not changed.
Something like that?
Index: lib/Apache/ParseSource.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/ParseSource.pm,v
retrieving revision 1.23
diff -u -r1.23 ParseSource.pm
--- lib/Apache/ParseSource.pm 2001/08/19 18:51:26 1.23
+++ lib/Apache/ParseSource.pm 2001/08/28 16:23:17
@@ -2,6 +2,7 @@
use strict;
use Apache::Build ();
+use Apache::TestTrace;
use Config ();
our $VERSION = '0.02';
@@ -410,19 +411,41 @@
$file = "$tdir/$subdir/$file";
}
- open my $pm, '>', $file or die "open $file: $!";
+ my $old_dump = '';
+ if (-e $file) {
+ my @old_file = ();
+ open my $old, '<', $file or die "open $file: $!";
+ my $skip = 1;
+ while (<$old>) {
+ if ($skip){
+ $skip = 0 if /^\$Apache/;
+ }
+ else {
+ $skip = 1 if /^\s*\n/;
+ }
+ push @old_file, $_ unless $skip;
+ }
+ close $old;
+ $old_dump = join '', @old_file;
+ }
+
# sort the hashes (including nested ones) for a consistent dump
canonsort(\$data);
my $dump = Data::Dumper->new([$data],
[$name])->Dump;
- my $package = ref($self) || $self;
- my $version = $self->VERSION;
- my $date = scalar localtime;
+ # write the file only if it has been changed
+ if ($dump ne $old_dump) {
- print $pm <<EOF;
+ my $package = ref($self) || $self;
+ my $version = $self->VERSION;
+ my $date = scalar localtime;
+
+ open my $pm, '>', $file or die "open $file: $!";
+
+ print $pm <<EOF;
package $name;
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -435,7 +458,11 @@
1;
EOF
- close $pm;
+ close $pm;
+ }
+ else {
+ warning "$file didn't change, skipping creating of the file";
+ }
}
# canonsort(\$data);
it's still not working perfectly, since it has to fish $dump out of the
file, and I see that it doesn't work for all current files.
I think a much better solution will be to write the
"$file.dump.md5" and compare Digest::MD5::md5($dump) with the contents
of this file.
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]