Bug#337829: devscripts: debdiff should be quiet if no differences were found

2005-11-07 Thread Roland Stigge
Julian Gilbey wrote:
> I prefer the --quiet option, so will go with that (principle of least
> surprise).  In the case of debdiff, I'm not sure what the exit code
> would mean: would it mean that the file lists are different, that the
> control files are different, that there was some difference or what?
> Given the nature of debdiff, one would usually expect some sort of
> difference.

Right. Any difference that was found. This in turn depends on which test
it was told to do (e.g. check control files or not).

bye,
  Roland


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#337829: devscripts: debdiff should be quiet if no differences were found

2005-11-07 Thread Roland Stigge
Hi,

Peter Samuelson wrote:
>>It would also be possible to return the differences-found state via a
>>return/exit value of the script. But that would diverge from common
>>practice (see e.g., diff(1)).
> 
> Heh - did you read diff(1)?

Well, not lately. :) But the manpage actually doesn't mention this
anyway (the info pages do, though).

> diff *does* in fact return 1 iff any
> differences are found.  So does cmp.  grep is another good example
> (returns 0 iff any matches were found), which makes 'grep -q' very
> useful indeed.
> 
> I favor the exit value approach (consistency with cmp and diff), but
> that *does* mean breaking an existing API that scripts may be depending
> on.  I also favor eliminating the extra chatter, as you propose -
> either by default or with a -q|--quiet.

OK.

bye,
  Roland


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#337829: devscripts: debdiff should be quiet if no differences were found

2005-11-07 Thread Julian Gilbey
On Sun, Nov 06, 2005 at 05:14:05PM -0600, Peter Samuelson wrote:
> 
> [Roland Stigge]
> > It would also be possible to return the differences-found state via a
> > return/exit value of the script. But that would diverge from common
> > practice (see e.g., diff(1)).
> 
> Heh - did you read diff(1)?  diff *does* in fact return 1 iff any
> differences are found.  So does cmp.  grep is another good example
> (returns 0 iff any matches were found), which makes 'grep -q' very
> useful indeed.
> 
> I favor the exit value approach (consistency with cmp and diff), but
> that *does* mean breaking an existing API that scripts may be depending
> on.  I also favor eliminating the extra chatter, as you propose -
> either by default or with a -q|--quiet.

I prefer the --quiet option, so will go with that (principle of least
surprise).  In the case of debdiff, I'm not sure what the exit code
would mean: would it mean that the file lists are different, that the
control files are different, that there was some difference or what?
Given the nature of debdiff, one would usually expect some sort of
difference.

   Julian


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#337829: devscripts: debdiff should be quiet if no differences were found

2005-11-06 Thread Peter Samuelson

[Roland Stigge]
> It would also be possible to return the differences-found state via a
> return/exit value of the script. But that would diverge from common
> practice (see e.g., diff(1)).

Heh - did you read diff(1)?  diff *does* in fact return 1 iff any
differences are found.  So does cmp.  grep is another good example
(returns 0 iff any matches were found), which makes 'grep -q' very
useful indeed.

I favor the exit value approach (consistency with cmp and diff), but
that *does* mean breaking an existing API that scripts may be depending
on.  I also favor eliminating the extra chatter, as you propose -
either by default or with a -q|--quiet.


signature.asc
Description: Digital signature


Bug#337829: devscripts: debdiff should be quiet if no differences were found

2005-11-06 Thread Roland Stigge
Package: devscripts
Version: 2.9.8
Severity: wishlist
Tags: patch

Hi,

in order to use debdiff in scripts, I would need it to let me evaluate
the result of the outcome (differences found or not). This is currently
not easily possible except employing some heuristics by parsing the
output.

I propose the attached patch that adds a "--verbose" option. Without it,
debdiff doesn't output anything on stdout if no problems or differences
were found. With "--verbose", you can reactivate the current behaviour.
This would follow common Unix practice.

See also http://www.catb.org/~esr/writings/taoup/html/ , "Rule of
Silence".

It would also be possible to return the differences-found state via a
return/exit value of the script. But that would diverge from common
practice (see e.g., diff(1)).

Feel free to remove the output-in-case-of-no-differences entirely in
which case you don't need the --verbose switch.

Thanks.

bye,
  Roland

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: sparc (sparc64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-sparc64
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_GB.UTF-8)

Versions of packages devscripts depends on:
ii  debianutils   2.15.1 Miscellaneous utilities specific t
ii  dpkg-dev  1.13.11package building tools for Debian
ii  libc6 2.3.5-6GNU C Library: Shared libraries an
ii  perl  5.8.7-7Larry Wall's Practical Extraction 
ii  sed   4.1.4-4The GNU sed stream editor

Versions of packages devscripts recommends:
ii  fakeroot  1.5.5  Gives a fake root environment

-- no debconf information
--- debdiff.1.orig  2005-11-06 19:33:12.0 +0100
+++ debdiff.1   2005-11-06 19:35:27.0 +0100
@@ -111,6 +111,9 @@
 .TP
 .BR \-\-version ", " \-v
 Show version and copyright information.
+.TP
+.BR \-\-verbose
+Print additional info, even if no differences were found.
 .SH "CONFIGURATION VARIABLES"
 The two configuration files \fI/etc/devscripts.conf\fR and
 \fI~/.devscripts\fR are sourced by a shell in that order to set
--- debdiff.pl.orig 2005-11-06 19:33:22.0 +0100
+++ debdiff.pl  2005-11-06 19:42:42.0 +0100
@@ -61,6 +61,8 @@
--renamed FROM TO  The package formerly called FROM has been
 renamed TO; only of interest with --show-moved
 (multiple permitted)
+   --verbose  Print additional info, even if no differences were
+found
 
 Default settings modified by devscripts configuration files:
 $modified_conf_msg
@@ -84,6 +86,8 @@
 my $show_moved = 0;
 my $wdiff_opt = '';
 
+my $verbose = 0;
+
 # Next, read read configuration files and then command line
 # The next stuff is boilerplate
 
@@ -180,6 +184,7 @@
 }
 elsif ($ARGV[0] =~ /^(--dirs|-d)$/) { $ignore_dirs = 0; shift; }
 elsif ($ARGV[0] eq '--nodirs') { $ignore_dirs = 1; shift; }
+elsif ($ARGV[0] eq '--verbose') { $verbose = 1; shift; }
 elsif ($ARGV[0] =~ /^(--show-moved|-s)$/) { $show_moved = 1; shift; }
 elsif ($ARGV[0] eq '--noshow-moved') { $show_moved = 0; shift; }
 elsif ($ARGV[0] eq '--nocontrol') { $compare_control = 0; shift; }
@@ -489,7 +494,7 @@
}
 }
 
-if (! $changes) {
+if ($verbose && ! $changes) {
print "File lists identical on package level (after any 
substitutions)\n";
 }
 } else {
@@ -500,7 +505,7 @@
 my @losses = sort grep $files{$_} < 0, keys %files;
 my @gains = sort grep $files{$_} > 0, keys %files;
 
-if (@losses == 0 && @gains == 0) {
+if ($verbose && @losses == 0 && @gains == 0) {
print "File lists identical (after any substitutions)\n";
 }
 
@@ -554,10 +559,14 @@
 
 use strict 'refs';
 
-print "\n";
+if ($verbose) {
+print "\n";
+}
 my $wdiff = `wdiff -n $wdiff_opt $dir1/control $dir2/control`;
 if ($? >> 8 == 0) {
-print "No differences were encountered in the control files\n";
+if ($verbose) {
+print "No differences were encountered in the control files\n";
+}
 } elsif ($? >> 8 == 1) {
 if ($wdiff_opt) {
# Don't try messing with control codes