Source: devscripts
Severity: wishlist
Tags: patch

Dear Devscripts Maintainers,

The attached patch adds a new '--no-append' option to debchange (a.k.a. dch)
that allows the user to override the release heuristics guessing
(DEBCHANGE_RELEASE_HEURISTIC and friends) that 'debchange' performs when
deciding whether to append a new changelog message to the current changelog
entry, or to create a new changelog entry section. It is mainly useful in
combination with the existing '--local' option, as explained below.

Usually the release heuristics do what the user wants, insofar as changes are
collected in a changelog entry leading up to a release of the package, and
once released, further changes will be added to a new changelog entry leading
up to the next release of the package.

There are circumstances, however, under which I wish to produce a modified
version of a given package for use on the local machine only, so the package
will never be "released" or be uploaded for inclusion in the Debian
distribution (or even to a local package repository). In such a case, I
sometimes want to accumulate multiple versions of the package over time (where
each changelog entry section uses a locally augmented version number (updated
using the --local option), each of which specifies UNRELEASED in the
distribution field. By default, the release heuristics guessing will always[0]
add new change detail messages to the current or topmost changelog entry whose
distribution field is UNRELEASED; the '--no-append' option allows the user to
override this behavior where desired to force 'debchange' to create a new
changelog entry section.

For example, let's say I have a locally modified 'deoobleckify-1.2.5-4'
package that was produced using the dch '--local' option to append my initials
(ads) as the version suffix. The top-most changelog entry for that version
looks like this:

----------------------------------------8<----------------------------------------
    deoobleckify (1.2.5-4ads2) UNRELEASED; urgency=low

      * Woke royal bell ringer
      * Woke royal trumpeter

     -- Bartholomew Cubbins <[email protected]>  Fri, 02 Jan 2015 19:13:55 
-0500
----------------------------------------8<----------------------------------------


So I come along a couple of months later and make another change to the
package, and want to install it as 'deoobleckify-1.2.5-4ads3'. I want the
changelog to now look something like this:

----------------------------------------8<----------------------------------------
    deoobleckify (1.2.5-4ads3) UNRELEASED; urgency=low

      * Warned captain of the guards

     -- Bartholomew Cubbins <[email protected]>  Sun, 22 Mar 2015 15:36:27 
-0400

    deoobleckify (1.2.5-4ads2) UNRELEASED; urgency=low

      * Woke royal bell ringer
      * Woke royal trumpeter

     -- Bartholomew Cubbins <[email protected]>  Fri, 02 Jan 2015 19:13:55 
-0500
----------------------------------------8<----------------------------------------


Without artificially indicating a release distribution (something other than
'UNRELEASED') in the changelog, dch cannot be used to produce that; when I
need to do this, I currently just edit the changelog file directly. When using
dch, the changelog would look like this:

----------------------------------------8<----------------------------------------
    deoobleckify (1.2.5-4ads3) UNRELEASED; urgency=low

      * Woke royal bell ringer
      * Woke royal trumpeter
      * Warned captain of the guards

     -- Bartholomew Cubbins <[email protected]>  Fri, 02 Jan 2015 19:13:55 
-0500
----------------------------------------8<----------------------------------------

The local version number was updated, but I've now lost the self-contained set
of change messages grouped under the 1.2.5-4ads2 changelog entry, and the last
edit/change date from that version has been clobbered.

Please consider applying the attached patch to the devscripts source tree.

Man page doc update included in patch.

The change supports the same behavior when updating NEWS files, too, of course.

Thanks much,
-Al


[0] Note that it is sometimes possible to get the behavior described here by
    specifying the command line option: '--release-heuristic log', but only as
    a side effect, and not reliably.


-- Package-specific info:

--- /etc/devscripts.conf ---

--- ~/.devscripts ---
Not present

-- System Information:
Debian Release: 7.8
  APT prefers stable
  APT policy: (990, 'stable'), (800, 'testing'), (500, 'stable-updates'), (500, 
'oldstable-updates'), (500, 'oldstable'), (80, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

-- no debconf information
diff --git a/scripts/debchange.1 b/scripts/debchange.1
index dc4639b..b3a2a05 100644
--- a/scripts/debchange.1
+++ b/scripts/debchange.1
@@ -62,6 +62,22 @@ A warning will be issued if the log file is found but a successful upload is not
 recorded. This may be because the previous upload was performed with a version
 of \fBdupload\fR prior to 2.1 or because the upload failed.
 .PP
+Usually the release heuristics do what the user wants, insofar as changes are
+collected in a changelog entry leading up to a release of the package, and
+once released, further changes will be added to a new changelog entry leading
+up to the next release of the package. There are circumstances, however, under
+which the user may wish to produce a modified version of the package for use
+on the local machine only, so the package will never be "released" or be
+uploaded for inclusion in the Debian distribution (or even a local package
+repository). In such a case, the user may wish to accumulate multiple versions
+of the package over time (where each changelog entry section uses a locally
+augmented version number (see the \fB\-\-local\fR option)), each of which
+specifies \fBUNRELEASED\fR in the distribution field. By default, the release
+heuristics guessing will always add new change detail messages to the current
+or topmost changelog entry whose distribution field is \fBUNRELEASED\fR; the
+\fB\-\-no\-append\fR option allows the user to override this behavior where
+desired to force \fBdebchange\fR to create a new changelog entry section.
+.PP
 If either \fB\-\-increment\fR or \fB\-\-newversion\fR is used, the
 name and email for the new version will be determined as follows.  If
 the environment variable \fBDEBFULLNAME\fR is set, this will be used
@@ -147,6 +163,13 @@ options or the \fBCHANGELOG\fR environment variable, as described below.
 .BR \-\-append ", " \-a
 Add a new changelog entry at the end of the current version's entries.
 .TP
+.BR \-\-no\-append
+Force creation of new changelog entry when release heuristics (see
+\fBDEBCHANGE_RELEASE_HEURISTIC\fR) would otherwise append to the current
+changelog entry. This option is mainly useful in combination with
+\fB\-\-local\fR to allow multiple changelog entries with the value
+\fBUNRELEASED\fR in the distribution field.
+.TP
 .BR \-\-increment ", " \-i
 Increment either the final component of the Debian release number or,
 if this is a native Debian package, the version number.  On Ubuntu or Tanglu,
@@ -255,7 +278,9 @@ Increment the Debian release number for an upload to wheezy-backports,
 and add a backport upload changelog comment.
 .TP
 .BR \-\-local ", " \-l \fIsuffix\fR
- Add a suffix to the Debian version number for a local build.
+Add a suffix to the Debian version number for a local build. Can be combined
+with \fB\-\-no\-append\fR to version local-only changes across multiple
+\fBUNRELEASED\fR changelog entries.
 .TP
 .BR \-\-force\-bad\-version ", " \-b
 Force a version number to be less than the current one (e.g., when
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 7e695ba..ada56e3 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -184,6 +184,11 @@ Options:
          Preserve the directory name
   --no-preserve
          Do not preserve the directory name (default)
+  --no-append
+         Force creation of new changelog entry when release heuristics would
+         otherwise append to the current changelog entry; mainly useful in
+         combination with '--local' to allow multiple changelog entries with
+         the value UNRELEASED in the distribution field.
   --vendor <vendor>
          Override the distributor ID from dpkg-vendor.
   -D, --distribution <dist>
@@ -352,6 +357,7 @@ my ($opt_i, $opt_a, $opt_e, $opt_r, $opt_v, $opt_b, $opt_d, $opt_D, $opt_u, $opt
 my ($opt_n, $opt_bn, $opt_qa, $opt_R, $opt_s, $opt_team, $opt_U, $opt_bpo, $opt_l, $opt_c, $opt_m, $opt_M, $opt_create, $opt_package, @closes);
 my ($opt_news);
 my ($opt_level, $opt_regex, $opt_noconf, $opt_empty);
+my ($opt_noappend);
 
 Getopt::Long::Configure('bundling');
 GetOptions("help|h" => \$opt_help,
@@ -393,6 +399,8 @@ GetOptions("help|h" => \$opt_help,
 	   "t|mainttrailer!" => \$opt_t,
 	   "check-dirname-level=s" => \$opt_level,
 	   "check-dirname-regex=s" => \$opt_regex,
+	   "noappend"  => \$opt_noappend,
+	   "no-append" => \$opt_noappend,
 	   "noconf" => \$opt_noconf,
 	   "no-conf" => \$opt_noconf,
 	   "release-heuristic=s" => \$opt_release_heuristic,
@@ -433,6 +441,9 @@ if (defined $opt_regex) { $check_dirname_regex = $opt_regex; }
 fatal "Only one of -a, -i, -e, -r, -v, -d, -n/--nmu, --bin-nmu, -q/--qa, -R/--rebuild, -s/--security, --team, --bpo, -l/--local is allowed;\ntry $progname --help for more help"
     if ($opt_i?1:0) + ($opt_a?1:0) + ($opt_e?1:0) + ($opt_r?1:0) + ($opt_v?1:0) + ($opt_d?1:0) + ($opt_n?1:0) + ($opt_bn?1:0) + ($opt_qa?1:0) + ($opt_R?1:0) + ($opt_s?1:0) + ($opt_team?1:0) + ($opt_bpo?1:0) + ($opt_l?1:0) > 1;
 
+fatal "The -a/--append and --no-append options are mutually exclusive;\ntry $progname --help for more help"
+    if ($opt_a?1:0) + ($opt_noappend?1:0) > 1;
+
 if ($opt_s) {
     $opt_u = "high";
 }
@@ -940,7 +951,7 @@ my $DATE;
 }
 
 if ($opt_news && !$opt_i && !$opt_a) {
-    if ($VERSION eq $changelog->{Version} && !$opt_v && !$opt_l) {
+    if ($VERSION eq $changelog->{Version} && !$opt_v && !$opt_l && !$opt_noappend) {
 	$opt_a = 1;
     } else {
 	$opt_i = 1;
@@ -952,7 +963,10 @@ if (! $opt_i && ! $opt_v && ! $opt_d && ! $opt_a && ! $opt_e && ! $opt_r &&
     ! $opt_n && ! $opt_bn && ! $opt_qa && ! $opt_R && ! $opt_s && ! $opt_team &&
     ! $opt_bpo && ! $opt_l && ! $opt_create) {
     # Yes, we are
-    if ($opt_release_heuristic eq 'log') {
+    if ($opt_noappend) {  # user wants a new changelog entry section (is overriding our release heuristics guessing behavior)
+        $opt_i = 1;
+    }
+    elsif ($opt_release_heuristic eq 'log') {
 	my @UPFILES = glob("../$PACKAGE\_$SVERSION\_*.upload");
 	if (@UPFILES > 1) {
 	    fatal "Found more than one appropriate .upload file!\n" .
@@ -1218,6 +1232,7 @@ if (($opt_i || $opt_n || $opt_bn || $opt_qa || $opt_R || $opt_s || $opt_team ||
     $urgency ||= 'medium';
 
     if (($opt_v or $opt_i or $opt_l or $opt_d) and
+        !$opt_noappend and
 	$opt_release_heuristic eq 'changelog' and
 	$changelog->{Distribution} eq 'UNRELEASED' and
 	$distribution eq 'UNRELEASED') {
_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel

Reply via email to