Author: adam-guest
Date: 2008-08-30 14:53:27 +0000 (Sat, 30 Aug 2008)
New Revision: 1600

Modified:
   trunk/debian/changelog
   trunk/scripts/debcommit.pl
Log:
debcommit: When committing to a bzr repository with a message including
bug closures, pass corresponding --fixes to bzr. Thanks James Westby for
the patch. (Closes: #496643)

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-08-30 11:57:19 UTC (rev 1599)
+++ trunk/debian/changelog      2008-08-30 14:53:27 UTC (rev 1600)
@@ -17,6 +17,9 @@
   * checkbashisms: Flag "read without variable" and "read with options other
     than -r" separately to ensure that all uses are correctly matched. Thanks
     to Frank Lichtenheld for pointing this out via a related bug in lintian.
+  * debcommit: When committing to a bzr repository with a message including
+    bug closures, pass corresponding --fixes to bzr. Thanks James Westby for
+    the patch. (Closes: #496643)
   * debsign: When copying .changes files from a remote host, attempt to process
     each copied file if a wildcard was used in the filename (Closes: #491627)
   * tagpending:

Modified: trunk/scripts/debcommit.pl
===================================================================
--- trunk/scripts/debcommit.pl  2008-08-30 11:57:19 UTC (rev 1599)
+++ trunk/scripts/debcommit.pl  2008-08-30 14:53:27 UTC (rev 1600)
@@ -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);
@@ -420,6 +426,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;
     
@@ -427,7 +445,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);
@@ -471,6 +489,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";
     }



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to