#!/usr/bin/perl

$f=shift; 
open IN,"hg diff|diffstat -p1 |"; 
my $n=2;
my $from="";
my $first="";
my $changed="";
$out="";
while (<IN>) {
	$changed="$changed#$_";
}

my $user = $ENV{HGUSER};

if ( $user eq "" ) {
	my $name = $ENV{CHANGE_LOG_NAME};
	my $email = $ENV{CHANGE_LOG_EMAIL_ADDRESS};

	$user="$name <$email>";
}

$first= "# Please change below if you are not patch author\n#\nFrom: $user";
$out= "# At the end Signed-off-by: fields by patch author and committer, at least\n#\nSigned-off-by: $user";
$from= "From: $user";

printf  "#Added/removed/changed files:\n%s#\n" .
	"# For better log display, please keep a blank line after subject, after from\n" .
	"# and before signed-off-by\n" .
	"# First line should be the subject, without Subject:\n#\n\n\n" .
	"# Now, patch author (just the main one), on a From: field\n" .
	"# Please change below if the committer is not the patch author\n#\n%s\n\n" .
	"# Then a detailed description:\n\n\n%s",
	$changed,$from,$out;