Package: devscripts
Version: 2.10.26
Severity: wishlist
Tags: patch
User: [EMAIL PROTECTED]
Usertags: origin-ubuntu intrepid ubuntu-patch

Hi,

bzr has an option to commit called "--fixes" which allows a revision
property to be set which associates the revision with a particular bug.
For a while now bzr has had built in support for the Debian BTS and
Launchpad.

When the message that is going to be used for the commit contains
"Closes:" statements it would be great to automatically pass the
--fixes argument, so that the user gets the association with no
effort.

The attached patch does this, please consider applying it.

It uses Dpkg::Changelog from dpkg-dev to find the bug numbers,
and then turns it in to the appropriate command line arguments
for "bzr commit".

Thanks,

James

diff -Nru devscripts-2.10.26ubuntu10/scripts/debcommit.pl devscripts-2.10.26ubuntu11/scripts/debcommit.pl
--- devscripts-2.10.26ubuntu10/scripts/debcommit.pl	2008-04-30 09:20:28.000000000 +0100
+++ devscripts-2.10.26ubuntu11/scripts/debcommit.pl	2008-08-26 13:01:22.000000000 +0100
@@ -159,12 +159,18 @@
 summary. If multiple changes were detected then an editor will be spawned to
 allow the message to be fine-tuned.
 
+=item B<bzr>
+
+If the changelog entry used for the commit message closes any bugs then --fixes
+options to "bzr commit" will be generated to associate the revision and the bugs.
+
 =cut
 
 use warnings;
 use strict;
 use Getopt::Long;
 use Cwd;
+use Dpkg::Changelog;
 use File::Basename;
 use File::Temp;
 my $progname = basename($0);
@@ -413,6 +419,18 @@
     return (system($prog, @_) != 0) ? 0 : 1;
 }
 
+sub bzr_find_fixes {
+    my $message=shift;
+
+    my $debian_closes = Dpkg::Changelog::find_closes($message);
+    my $launchpad_closes = Dpkg::Changelog::find_launchpad_closes($message);
+
+    my @fixes_arg = ();
+    map { push(@fixes_arg, ("--fixes", "deb:".$_)) } @$debian_closes;
+    map { push(@fixes_arg, ("--fixes", "lp:".$_)) } @$launchpad_closes;
+    return @fixes_arg;
+}
+
 sub commit {
     my $message=shift;
     
@@ -420,7 +438,7 @@
 	if (@files_to_commit and $all);
 
     my $action_rc;  # return code of external command
-    if ($prog =~ /^(cvs|svn|svk|bzr|hg)$/) {
+    if ($prog =~ /^(cvs|svn|svk|hg)$/) {
         $action_rc = $diffmode
 	    ? action($prog, "diff", @files_to_commit)
 	    : action($prog, "commit", "-m", $message, @files_to_commit);
@@ -464,6 +482,15 @@
         ) if @files_to_commit;
 	$action_rc = action($prog, $diffmode ? "diff" : "commit", @args);
     }
+    elsif ($prog eq 'bzr') {
+        if ($diffmode) {
+            $action_rc = action($prog, "diff", @files_to_commit);
+        } else {
+            my @fixes_arg = bzr_find_fixes($message);
+            $action_rc = action($prog, "commit", "-m", $message,
+                    @fixes_arg, @files_to_commit);
+        }
+    }
     else {
 	die "debcommit: unknown program $prog";
     }

Reply via email to