From 569fda25980e17a63c2a66b9271840a90502b5a5 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 8 Jan 2008 13:26:51 -0200 Subject: Improve script to handle also hg mq series of patches From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- mailimport | 119 +++++++++++++++++++++++++++++++++----------------- v4l/scripts/hghead.pl | 14 +++++- 2 files changed, 91 insertions(+), 42 deletions(-) diff --git a/mailimport b/mailimport index 6895fc32d..bd834123a 100755 --- a/mailimport +++ b/mailimport @@ -18,32 +18,8 @@ head=v4l/scripts/hghead.pl -if [ "$1" == "" ]; then - echo "Usage: $0 " - exit -fi -MBOX=$1 - -if [ "$TMPDIR" == "" ]; then - TMPDIR=/tmp -fi - -if [ "$EDITOR" == "" ]; then - EDITOR="nano -w" -fi - -if [ "$CHECKPATCH" == "" ]; then - CHECKPATCH="/lib/modules/`uname -r`/build/scripts/checkpatch.pl" -fi - -DIR=$TMPDIR/mailimport$$ -mkdir $DIR -if [ "$?" != "0" ]; then - echo "*** Error at mkdir $DIR" - exit; -fi -trap "rm -rf $DIR" EXIT -TMP2=$DIR/patchheader +#################################################################### +# Tries to apply a patch at the tree apply_patch () { next=$1 @@ -159,26 +135,20 @@ apply_patch () { hg log -r -1 -v } -grep -v $MBOX >$DIR/tmpbox <$DIR/author + cat $i| git-mailinfo $DIR/msg $DIR/patch >$DIR/author cat $DIR/msg|grep -vi ^CC: >$DIR/msg2 cat $DIR/author|perl -ne "if (m/Author[:]\\s*(.*)\\n/) { \$auth=\$1; } else \ @@ -195,12 +165,79 @@ for i in $DIR/*; do cat $DIR/author2 - echo "Signed-off-by: $CHANGE_LOG_NAME <$CHANGE_LOG_EMAIL_ADDRESS>" >>$DIR/msg2 + sob="Signed-off-by: $CHANGE_LOG_NAME <$CHANGE_LOG_EMAIL_ADDRESS>" + + if [ "$(perl -ne 'if (m/$sob/) { print $_; }' $DIR/msg2)" == "" ]; then + echo $sob >>$DIR/msg2 + fi echo "cat $DIR/author2 $DIR/msg2 $DIR/patch >$out" $CHECKPATCH -q --notree $i|perl -ne '{ print "# $_"; }' >$out cat $DIR/author2 $DIR/msg2 $DIR/patch >>$out - apply_patch $out -done +} + +#################################################################### +# Main + +if [ "$1" == "" ]; then + echo "Usage: $0 " + exit +fi + +if [ "$TMPDIR" == "" ]; then + TMPDIR=/tmp +fi + +if [ "$EDITOR" == "" ]; then + EDITOR="nano -w" +fi + +if [ "$CHECKPATCH" == "" ]; then + CHECKPATCH="/lib/modules/`uname -r`/build/scripts/checkpatch.pl" +fi + +DIR=$TMPDIR/mailimport$$ +mkdir $DIR +if [ "$?" != "0" ]; then + echo "*** Error at mkdir $DIR" + exit; +fi +trap "rm -rf $DIR" EXIT + +if [ -d "$1" ]; then + TMP2=$DIR/patchheader + + if [ -e "$1/series" ]; then + for i in `cat "$1/series"|grep -v "^#"`; do + echo $1/$i + proccess_patch "$1/$i" + done + else + for i in $1/*; do + proccess_patch $i + done + fi +else + MBOX="$1" + TMP2=$DIR/patchheader + + grep -v -f - $MBOX >$DIR/tmpbox <) { last; } + if ($line =~ m/^# Date\s*(.*)/) { + print "#Date: $1\n"; + } + if ($line =~ m/^Date:\s*(.*)/) { my $time = str2time($1); if ($time) { + print "#Date: $time\n"; + } else { print "#Date: $1\n"; } next; } + $line =~ s/^#\sUser/From:/; + my $tag=$line; my $arg=$line; $tag =~ s/\s*([^\s]+:)(.*)\n/\1/; @@ -139,6 +147,9 @@ while ($line = ) { next; } if ($sub_ok == 0) { + if ($line =~ m/^\s*\n/) { + next; + } $sub_ok=1; substr( $subject, 0, 1 ) = uc (substr ($subject, 0, 1)); if ($subject =~ m|V4L\/DVB\s*(.+)|) { @@ -180,10 +191,11 @@ if (!$signed =~ m/$from/) { die; } +$body="$from\n$body"; $body=~s/[\n\s]+$//; $body=~s/^[\n\s]+//; # First from is used by hg to recognize commiter name print "#Committer: $maintainer_name <$maintainer_email>\n"; -print "$subject\n$from\n$body\n\n$signed"; +print "$subject\n$body\n\n$signed"; -- cgit v1.2.3