[ef0636]: mkchlog Maximize Restore History

Download this file

mkchlog    38 lines (33 with data), 968 Bytes

#! /usr/bin/perl

# 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.

# Usage: hg log [-v] | mkchlog [> ChangeLog]

$skip = 0;

while (<>) {
  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";
  }
}