diff options
-rwxr-xr-x | mailimport | 119 | ||||
-rwxr-xr-x | 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 <mbox>" - 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 <<EOF -^Content-Type: -^--Boundary- -^Content-Disposition: inline -^Content-Transfer-Encoding: 8bit -EOF +#################################################################### +# Proccess a new patch -echo git-mailsplit -b $MBOX/tmpbox $DIR -echo -n "Number of patches at file: " -git-mailsplit -b $MBOX $DIR -echo +proccess_patch () +{ + i="$_" -for i in $DIR/*; do if [ "`diffstat -p1 -l $i`" == "" ]; then echo "*** ERROR nothing to commit" cd $cur exit fi - cat $i| git-mailinfo $DIR/msg $DIR/patch>$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 <mbox>" + 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 <<EOF +^Content-Type: +^--Boundary- +^Content-Disposition: inline +^Content-Transfer-Encoding: 8bit +EOF + + echo git-mailsplit -b $DIR/tmpbox $DIR + echo -n "Number of patches at file: " + git-mailsplit -b $DIR/tmpbox $DIR + echo + + for i in $DIR/0*; do + echo $i + proccess_patch $i + done +fi + diff --git a/v4l/scripts/hghead.pl b/v4l/scripts/hghead.pl index 7b3f3106d..af8b7914f 100755 --- a/v4l/scripts/hghead.pl +++ b/v4l/scripts/hghead.pl @@ -45,15 +45,23 @@ while ($line = <IN>) { 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 = <IN>) { 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"; |