summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmailimport80
-rwxr-xr-xv4l/scripts/hghead.pl6
2 files changed, 54 insertions, 32 deletions
diff --git a/mailimport b/mailimport
index f1a64af35..b563eecd9 100755
--- a/mailimport
+++ b/mailimport
@@ -10,7 +10,12 @@
#2) hg mailqueue. It is easier to manage patches using mq, allowing to work with
# the patches before applying to the tree.
+#uncomment to use mq
+#usemq=1
+
+#uncomment to stop at the first error while testing a patch with --dry-run
#exitonerror=1
+
head=v4l/scripts/hghead.pl
if [ "$1" == "" ]; then
@@ -68,36 +73,53 @@ apply_patch () {
fi
done
-# hg qnew doesn't support specifying a date
-# date="`perl -ne '{ if ( s/^# Date: //) { print; } }' $TMP2`"
-# echo "Patch date is $date"
-# patch -s -t -p1 -l -N -d linux -i ../$next
-# cd linux
-# hg addremove `diffstat -p1 -l $next`
-# cd ..
-
- name=`cat $next | perl -ne '
- if (s/Subject:\s+(.*)/$1/) {
- m/\s*(.*)\s*\n/;
- $_="$1";
-
- tr/[A-Z]/[a-z]/;
- s/[^a-z0-9]/_/g;
- s/_+$//;
- s/_+/_/g;
- s/^v4l_dvb_\d+[a-z]*_//g;
-
- printf "%s.patch",$_;
- exit;
- }'`
-
- cat $next| grep -v "^#" >$TMPDIR/$name
-
- echo hg -m "`cat $TMP2|grep -v "^#"`" qnew $name
- hg qnew -m "`cat $TMP2|grep -v "^#"`" $name
- patch -s -t -p1 -l -N -d $pdir -i $next
make whitespace
- hg qrefresh
+
+ committer=`grep "Committer:" $TMP2|sed s/"#Committer: "//`
+
+ if [ "$usemq" != "" ]; then
+ name=`cat $next | perl -ne '
+ if (s/Subject:\s+(.*)/$1/) {
+ m/\s*(.*)\s*\n/;
+ $_="$1";
+
+ tr/[A-Z]/[a-z]/;
+ s/[^a-z0-9]/_/g;
+ s/_+$//;
+ s/_+/_/g;
+ s/^v4l_dvb_\d+[a-z]*_//g;
+
+ printf "%s.patch",$_;
+ exit;
+ }'`
+
+ cat $next| grep -v "^#" >$TMPDIR/$name
+
+ echo hg -m "`cat $TMP2|grep -v "^#"`" qnew $name
+ hg qnew -m "`cat $TMP2|grep -v "^#"`" $name
+ hg qrefresh
+ else
+ patch -s -t -p1 -l -N -d $pdir -i $next
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR at: patch -s -t -p1 -l -N -d $pdir -i $next"
+ exit
+ fi
+ cur=`pwd`
+ cd $pdir
+ hg addremove `diffstat -p1 -l $next`
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR at hg addremove"
+ exit
+ fi
+ # Commit the changed files
+ hg commit -u "$committer" -m "`cat $TMP2|grep -v "^#"`" `diffstat -p1 -l $next`
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR at hg commit"
+ cd $cur
+ exit
+ fi
+ cd $cur
+ fi
}
echo git-mailsplit $MBOX $DIR
diff --git a/v4l/scripts/hghead.pl b/v4l/scripts/hghead.pl
index 5c5e63f1f..ddaef0767 100755
--- a/v4l/scripts/hghead.pl
+++ b/v4l/scripts/hghead.pl
@@ -66,7 +66,7 @@ while ($line = <IN>) {
die;
}
- if ($line =~ m/^Subject:\s*(.*)\n/) {
+ if ($line =~ m/^Subject:\s*(.*\n)/) {
$subject=$1;
next;
}
@@ -100,7 +100,7 @@ while ($line = <IN>) {
next;
}
- if ($line =~ m|^(V4L\/DVB\s*\(.+\)\s*:.*)\n|) {
+ if ($line =~ m|^(V4L\/DVB\s*\(.+\)\s*:.*\n)|) {
$subject=$1;
$line="\n";
}
@@ -147,6 +147,6 @@ $body=~s/\n+$//;
$body=~s/^\n+$//;
# First from is used by hg to recognize commiter name
-print "From: $maintainer_name <$maintainer_email>\n";
+print "#Committer: $maintainer_name <$maintainer_email>\n";
print "$subject\n$from\n$body\n\n$signed";