Author: adam-guest
Date: 2008-04-01 17:30:36 +0000 (Tue, 01 Apr 2008)
New Revision: 1231
Modified:
trunk/conf.default.in
trunk/debian/changelog
trunk/debian/postinst
trunk/scripts/debdiff.1
trunk/scripts/debdiff.pl
Log:
debdiff: Add a --diffstat option (Closes: #370286)
Modified: trunk/conf.default.in
===================================================================
--- trunk/conf.default.in 2008-03-31 19:57:34 UTC (rev 1230)
+++ trunk/conf.default.in 2008-04-01 17:30:36 UTC (rev 1231)
@@ -217,6 +217,9 @@
#
# Option to pass to wdiff
# DEBDIFF_WDIFF_OPT=
+#
+# Include the output of diffstat?
+# DEBDIFF_SHOW_DIFFSTAT=no
##### debi
#
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-03-31 19:57:34 UTC (rev 1230)
+++ trunk/debian/changelog 2008-04-01 17:30:36 UTC (rev 1231)
@@ -28,6 +28,7 @@
respository will be writable by the user passed on the command line
(Closes: #447791)
* debcommit: Strip epochs from hg tags (Closes: #473593)
+ * debdiff: Add a --diffstat option (Closes: #370286)
* dget: Pass --all-versions to apt-cache show in case the user has
configured it to only show the candidate version. Thanks HÃ¥kon Stordahl
(Closes: #472747)
Modified: trunk/debian/postinst
===================================================================
--- trunk/debian/postinst 2008-03-31 19:57:34 UTC (rev 1230)
+++ trunk/debian/postinst 2008-04-01 17:30:36 UTC (rev 1231)
@@ -474,6 +474,10 @@
# BTS_SMTP_AUTH_USERNAME=user
# BTS_SMTP_AUTH_PASSWORD=pass
+##### debdiff option added in version 2.10.21
+# Include the output of diffstat?
+# DEBDIFF_SHOW_DIFFSTAT=no
+
EOF
fi
fi
Modified: trunk/scripts/debdiff.1
===================================================================
--- trunk/scripts/debdiff.1 2008-03-31 19:57:34 UTC (rev 1230)
+++ trunk/scripts/debdiff.1 2008-04-01 17:30:36 UTC (rev 1231)
@@ -117,6 +117,13 @@
Exclude files that match \fIPATTERN\fR. Multiple uses of this option
are permitted.
.TP
+.B \-\-diffstat
+Include the result of \fBdiffstat\fR before the generated diff.
+.TP
+.B \-\-no-diffstat
+The default behaviour; can be used to override a configuration file
+setting.
+.TP
\fB\-\-no-conf\fR, \fB\-\-noconf\fR
Do not read any configuration files. This can only be used as the
first option given on the command-line.
@@ -160,6 +167,10 @@
.B DEBDIFF_WDIFF_OPT
This option will be passed to \fBwdiff\fR; it should be one of
\fB\-p\fR, \fB\-l\fR or \fB\-t\fR.
+.TP
+.B DEBDIFF_SHOW_DIFFSTAT
+If this is set to \fIyes\fR, then it is the same as the
+\fB\-\-diffstat\fR command line parameter being used.
.SH "EXIT VALUES"
Normally the exit value will be 0 if no differences are reported and 1
if any are reported. If there is some fatal error, the exit code will
@@ -170,6 +181,7 @@
.BR dpkg-deb (1),
.BR wdiff (1),
.BR interdiff (1)
+.BR diffstat (1)
and
.BR devscripts.conf (5).
.SH AUTHOR
Modified: trunk/scripts/debdiff.pl
===================================================================
--- trunk/scripts/debdiff.pl 2008-03-31 19:57:34 UTC (rev 1230)
+++ trunk/scripts/debdiff.pl 2008-04-01 17:30:36 UTC (rev 1231)
@@ -18,7 +18,7 @@
use strict;
use Cwd;
use File::Basename;
-use File::Temp qw/ tempdir /;
+use File::Temp qw/ tempdir tempfile /;
# Predeclare functions
sub process_debc($$);
@@ -93,6 +93,7 @@
my $show_moved = 0;
my $wdiff_opt = '';
my @diff_opts = ();
+my $show_diffstat = 0;
my $quiet = 0;
@@ -110,6 +111,7 @@
'DEBDIFF_CONTROLFILES' => 'control',
'DEBDIFF_SHOW_MOVED' => 'no',
'DEBDIFF_WDIFF_OPT' => '',
+ 'DEBDIFF_SHOW_DIFFSTAT' => '',
);
my %config_default = %config_vars;
@@ -132,6 +134,8 @@
or $config_vars{'DEBDIFF_CONTROL'}='yes';
$config_vars{'DEBDIFF_SHOW_MOVED'} =~ /^(yes|no)$/
or $config_vars{'DEBDIFF_SHOW_MOVED'}='no';
+ $config_vars{'DEBDIFF_SHOW_DIFFSTAT'} =~ /^(yes|no)$/
+ or $config_vars{'DEBDIFF_SHOW_DIFFSTAT'}='no';
foreach my $var (sort keys %config_vars) {
if ($config_vars{$var} ne $config_default{$var}) {
@@ -146,6 +150,7 @@
$controlfiles = $config_vars{'DEBDIFF_CONTROLFILES'};
$show_moved = $config_vars{'DEBDIFF_SHOW_MOVED'} eq 'yes' ? 1 : 0;
$wdiff_opt = $config_vars{'DEBDIFF_WDIFF_OPT'} =~ /^-([plt])$/ ? $1 : '';
+ $show_diffstat = $config_vars{'DEBDIFF_SHOW_DIFFSTAT'} eq 'yes' ? 1 : 0;
}
# Are they a pair of debs, changes or dsc files, or a list of debs?
@@ -226,6 +231,8 @@
push @diff_opts, "-w";
shift;
}
+ elsif ($ARGV[0] eq '--diffstat') { $show_diffstat = 1; shift; }
+ elsif ($ARGV[0] =~ /^--no-?diffstat$/) { $show_diffstat = 0; shift; }
elsif ($ARGV[0] =~ /^--no-?conf$/) {
fatal "--no-conf is only acceptable as the first command-line option!";
}
@@ -423,13 +430,34 @@
# Do we have interdiff?
system("command -v interdiff >/dev/null 2>&1");
my $use_interdiff = ($?==0) ? 1 : 0;
+ system("command -v diffstat >/dev/null 2>&1");
+ my $have_diffstat = ($?==0) ? 1 : 0;
+ my ($fh, $filename) = tempfile("debdiffXXXXXX",
+ SUFFIX => ".diff",
+ DIR => File::Spec->tmpdir,
+ UNLINK => 1);
+
if ($origs[1] eq $origs[2] and defined $diffs[1] and defined $diffs[2]
and scalar(@excludes) == 0 and $use_interdiff) {
# same orig tar ball and interdiff exists
- my $rv = system('interdiff', '-z', @diff_opts, $diffs[1], $diffs[2]);
+
+ my $command = join( " ", ("interdiff", "-z", @diff_opts, $diffs[1],
+ $diffs[2], ">", $filename) );
+ my $rv = system($command);
if ($rv) {
fatal "interdiff -z $diffs[1] $diffs[2] failed!";
+ } else {
+ if ($have_diffstat and $show_diffstat) {
+ print "diffstat for $diffs[1] $diffs[2]\n\n";
+ system("diffstat $filename");
+ print "\n";
+ }
+ open( INTERDIFF, '<', $filename );
+ while( <INTERDIFF> ) {
+ print $_;
+ }
+ close INTERDIFF;
}
} else {
# Any other situation
@@ -482,16 +510,26 @@
}
closedir(DIR);
}
+
my @command = ("diff", "-Nru", @diff_opts);
for my $exclude (@excludes) {
push @command, ("--exclude", $exclude);
}
push @command, ("$dir1/$sdir1", "$dir2/$sdir2");
+ push @command, (">", $filename);
# Execute diff and remove the common prefixes $dir1/$dir2, so the patch
can be used with -p1,
# as if when interdiff would have been used:
- open( DIFF, '-|', @command ) || fatal "Failed to execute @command!";
+ system(join(" ", @command)) || fatal "Failed to execute @command!";
+ if ($have_diffstat and $show_diffstat) {
+ print "diffstat for $sdir1 $sdir2\n\n";
+ system("diffstat $filename");
+ print "\n";
+ }
+
+ open( DIFF, '<', $filename );
+
# replace in first line:
my $first = <DIFF>;
$first =~ s/ $dir1\/\Q$sdir1\E/ $sdir1/;
--
To unsubscribe, send mail to [EMAIL PROTECTED]