releng r940 - trunk/tools



Author: herzi
Date: Wed Feb 13 09:18:57 2008
New Revision: 940
URL: http://svn.gnome.org/viewvc/releng?rev=940&view=rev

Log:
2008-02-13  Sven Herzberg  <sven imendio com>

	* tools/prepare-ChangeLog.pl: re-merged the multiple-changelog support


Modified:
   trunk/tools/ChangeLog
   trunk/tools/prepare-ChangeLog.pl

Modified: trunk/tools/prepare-ChangeLog.pl
==============================================================================
--- trunk/tools/prepare-ChangeLog.pl	(original)
+++ trunk/tools/prepare-ChangeLog.pl	Wed Feb 13 09:18:57 2008
@@ -7,9 +7,10 @@
 #
 # Darin Adler <darin eazel com>, started 20 April 2000
 # Java support added by Maciej Stachowiak <mjs eazel com>
-# last updated 28 December 2000
+# Multiple ChangeLog support added by Laszlo (Laca) Peter <laca sun com>
 # Fernando Herrera added Subversion support
 # Sven Herzberg added Git support
+# last updated 13 February 2007
 #
 # (Someone put a license in here, like maybe GPL.)
 #
@@ -26,8 +27,6 @@
 #   Handle C++ and yacc source files too (other languages?).
 #   Help merge when there are ChangeLog conflicts or if there's
 #     already a partly written ChangeLog entry.
-#   Find appropriate ChangeLog to edit for each changed file
-#     instead of always using ChangeLog in current directory.
 #   Add command line option to put the ChangeLog into a separate
 #     file or just spew it out stdout.
 #   Figure out how to allow -z options from .cvsrc to work without
@@ -48,6 +47,7 @@
 
 use English;
 use Text::Wrap;
+use File::Basename;
 use File::Temp qw/ tempfile /;
 
 # Check for cvs, svn or git system
@@ -56,7 +56,7 @@
   {
     $command = "cvs";
   }
-elsif (-d ".svn")
+elsif (-e ".svn/entries")
   {
     $command = "svn";
   }
@@ -69,30 +69,23 @@
     die "There is not known revision system.\n"
   }
 
-# Read the old change log file.
-# It's less efficient to read the whole thing into memory than it would be
-# to read it while we prepend to it later, but I like doing this part first.
-if ($command eq "cvs")
-  {
-     print STDERR "  Updating ChangeLog from cvs repository.\n";
-     open ERRORS, "cvs update ChangeLog |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
-  }
-elsif ($command eq "svn")
-  {
-     print STDERR "  Updating ChangeLog from svn repository.\n";
-     open ERRORS, "svn update ChangeLog |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
-  }
-else
-  {
-    print STDERR "  Not updating ChangeLog from git repository.\n";
-    #open ERRORS, "svn update ChangeLog |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
-    open ERRORS, "true |";
-  }
-print STDERR "    $ARG" while <ERRORS>;
-close ERRORS;
-open OLD_CHANGE_LOG, "ChangeLog" or die "Could not open ChangeLog file: $OS_ERROR.\n";
-my @old_change_log = <OLD_CHANGE_LOG>;
-close OLD_CHANGE_LOG;
+# Update the change log file.
+sub update_change_log ($) {
+    my $logname = shift;
+    if ($command eq "cvs") {
+        print STDERR "  Updating $logname from cvs repository.\n";
+        open ERRORS, "cvs update $logname |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
+    } elsif ($command eq "svn") {
+        print STDERR "  Updating $logname from svn repository.\n";
+        open ERRORS, "svn update $logname |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
+    } else {
+        print STDERR "  Not updating ChangeLog from git repository.\n";
+	#open ERRORS, "svn update ChangeLog |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
+	open ERRORS, "true |";
+    }
+    print STDERR "    $ARG" while <ERRORS>;
+    close ERRORS;
+}
 
 # For each file, build a list of modified lines.
 # Use line numbers from the "after" side of each diff.
@@ -135,8 +128,9 @@
   {
     $file = $1 if /^Index: (\S+)$/;
 
+    my $basename = basename ($file);
     if (defined $file
-        and $file ne "ChangeLog"
+        and $basename ne "ChangeLog"
         and (/^\d+(,\d+)?[acd](\d+)(,(\d+))?/ or /^Binary files/) )
       {
         push @{$changed_line_ranges{$file}}, [ $2, $4 || $2 ];
@@ -201,7 +195,25 @@
   }
 
 # Write out a new ChangeLog file.
-print STDERR "  Editing the ChangeLog file.\n";
+print STDERR "  Finding ChangeLog files:\n";
+my %changelogs;
+foreach my $file (sort keys %function_lists) {
+    $file = dirname ($file);
+    while ($file ne '.' and $file ne '/') {
+        if (-f "$file/ChangeLog") {
+            $changelogs{"./$file"} = 1;
+            last;
+        }
+        $file = dirname ($file);
+    }
+}
+$changelogs{'.'} = 1;
+
+foreach my $chl (reverse sort keys %changelogs) {
+    print STDERR "\t${chl}/ChangeLog\n";
+}
+
+print STDERR "  Editing the ChangeLog file(s).\n";
 my $date = sprintf "%d-%02d-%02d",
   1900 + (localtime $BASETIME)[5], # year
   1 + (localtime $BASETIME)[4], # month
@@ -212,25 +224,40 @@
   || "set REAL_NAME environment variable";
 my $email_address = $ENV{CHANGE_LOG_EMAIL_ADDRESS}
   || $ENV{EMAIL_ADDRESS}
+  || ((getlogin || getpwuid($<)) . "@" . `hostname`)
   || "set EMAIL_ADDRESS environment variable";
-open CHANGE_LOG, "> ChangeLog" or die "Could not write ChangeLog\n.";
-print CHANGE_LOG "$date  $name  <$email_address>\n\n";
-print CHANGE_LOG "\treviewed by: <delete if not using a buddy>\n\n";
-foreach my $file (sort keys %function_lists)
-  {
-    my $lines = wrap("\t", "\t", "XX$file:$function_lists{$file}");
-    $lines =~ s/^\tXX/\t* /;
-    print CHANGE_LOG "$lines\n";
-  }
-print CHANGE_LOG "\n", @old_change_log;
-close CHANGE_LOG;
+chomp($email_address);
+foreach my $chlog (reverse sort keys %changelogs) {
+    update_change_log ("$chlog/ChangeLog");
+    # It's less efficient to read the whole thing into memory than it would be
+    # to read it while we prepend to it later, but I like doing this part first.
+    open OLD_CHANGE_LOG, "${chlog}/ChangeLog" or die "Could not open ChangeLog file: $OS_ERROR.\n";
+    my @old_change_log = <OLD_CHANGE_LOG>;
+    close OLD_CHANGE_LOG;
+    open CHANGE_LOG, "> ${chlog}/ChangeLog" or die "Could not write ChangeLog\n.";
+    print CHANGE_LOG "$date  $name  <$email_address>\n\n";
+    print CHANGE_LOG "\treviewed by: <delete if not using a buddy>\n\n";
+    foreach my $file (sort keys %function_lists) {
+        my $fname = "./$file";
+        if ($fname =~ /^${chlog}\//) {
+            $fname =~ s/^${chlog}\///;
+            my $lines = wrap("\t", "\t", "XX$fname:$function_lists{$file}");
+            $lines =~ s/^\tXX/\t* /;
+            print CHANGE_LOG "$lines\n";
+            delete ($function_lists{$file});
+        }
+    }
+    print CHANGE_LOG "\n", @old_change_log;
+    close CHANGE_LOG;
+    
+    # Done.
+    print STDERR "  Done editing ${chlog}/ChangeLog.\n";
+    last if not (keys %function_lists);
+}
 
-# Done.
-print STDERR "  Done editing ChangeLog.\n";
 exit;
 
 
-
 sub get_function_line_ranges
   {
     my ($file_handle, $file_name) = @_;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]