Diff of /mkchlog [b11254] .. [ff2cd9] Maximize Restore

  Switch to side-by-side view

--- a/mkchlog
+++ b/mkchlog
@@ -1,73 +1,37 @@
-#!/usr/bin/perl
+#! /usr/bin/perl
 
-# Generate a ChangeLog file from a CVS log.
-# Written by Robert Krawitz <rlk@alum.mit.edu>
-# This code is in the public domain and may be used
-# for any purpose.
+# Generate a ChangeLog file from a Mercurial log.
+# Written by Darren Salt <linux@youmustbejoking.demon.co.uk>
+# This code is covered by the GPL, version 2 or later.
 
-%logmsgs = ();			# Index by date, time, and author
-$skipme = 0;
+# Usage: hg log [-v] | mkchlog [> ChangeLog]
 
-$names{"klan"} = 'Claudio Ciccani';
-$names{"miguelfreitas"} = 'Miguel Freitas';
-$names{"guenter"} = 'G端nter Bartsch';
-$names{"f1rmb"} = 'Daniel Caujolle-Bert';
-$names{"dsalt"} = 'Darren Salt';
+$skip = 0;
 
 while (<>) {
-    if (/^Working file: /) {
-	chomp;
-	($ignore, $ignore, $currentfile) = split;
-	while (<>) {
-	    if (/^----------------------------$/) {
-		last;
-	    }
-	}
-	next;
-    } elsif (/^----------------------------$/) {
-	next;
-    } elsif (/^revision /) {
-	($ignore, $revision) = split;
-	@junk = split(/\./, $revision);
-    } elsif (/^date: /) {
-	($ignore, $date, $time, $ignore, $author, $ignore, $ignore,
-	 $ignore, $plus, $minus, $ignore, $ignore, $ignore, $commitid) = split;
-	$time =~ s/:[0-9][0-9];$//;
-	$author =~ s/;$//;
-	$datetimeauthor = "$date $time $author $commitid";
-	$body = "";
-	$firstline = 1;
-	while (<>) {
-	    if (/^----------------------------$/) {
-		last;
-	    } elsif (/^=============================================================================$/) {
-		last;
-	    } elsif ($firstline && /^branches:[ \t]+[0-9]+(\.[0-9]+)+;$/) {
-		next;
-	    } else {
-		$body .= $_;
-		$firstline = 0;
-	    }
-	}
-	if ($skipme == 0) {
-	    if ($logmsgs{$datetimeauthor}) {
-		$stuff = $logmsgs{$datetimeauthor};
-		$stuff =~ s/\n/\n\t$currentfile ($revision) ($plus $minus)\n/;
-		$logmsgs{$datetimeauthor} = $stuff;
-	    } else {
-		$logmsgs{$datetimeauthor} = "Files:\t$currentfile ($revision) ($plus $minus)\n\n$body"
-		}
-	}
-    }				# Other junk we ignore
+  if (/^changeset:\s+(.*)/) {
+    $skipme = 0;
+    $cset = $1;
+    $tag = '';
+  } elsif (/^tag:\s+(.*)/ ) {
+    $tag = $1;
+  } elsif (/^user:\s+(.*)/) {
+    $author = $1;
+  } elsif (/^date:\s+(.*)/) {
+    $date = $1;
+  } elsif (/^summary:\s(.*)/) {
+    $preamble = "Cset	$cset\nby	$author\non	$date\n";
+    $preamble .= "Tag	$tag\n" if $tag ne '';
+    print $preamble . "\n	" . $1 . "\n\n";
+  } elsif (/^description:/) {
+    $preamble = "Cset	$cset\nby	$author\non	$date\n";
+    $preamble .= "Tag	$tag\n" if $tag ne '';
+    $desc = '';
+    while (<>) {
+      $desc .= '	' . $_;
+      $skip = /^\n/ ? $skip + 1 : 0;
+      last if $skip == 2;
+    }
+    print $preamble . "\n" . substr ($desc, 0, -4) . "\n";
+  }
 }
-
-@chlog = reverse sort keys %logmsgs;
-foreach $_ (@chlog) {
-    ($date, $time, $author) = split;
-    $date =~ s,/,-,g;
-    $msg = $logmsgs{$_};
-    print "$date   $author\t$time\t$names{$author}\n\n";
-    $msg =~ s/^/\t/g;
-    $msg =~ s/\n/\n\t/g;
-    print "$msg\n";
-}