summaryrefslogtreecommitdiff
path: root/mailimport
diff options
context:
space:
mode:
Diffstat (limited to 'mailimport')
-rwxr-xr-xmailimport127
1 files changed, 87 insertions, 40 deletions
diff --git a/mailimport b/mailimport
index edbde0e06..e6e4df411 100755
--- a/mailimport
+++ b/mailimport
@@ -10,6 +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
@@ -22,6 +28,10 @@ if [ "$TMPDIR" == "" ]; then
TMPDIR=/tmp
fi
+if [ "$EDITOR" == "" ]; then
+ EDITOR=nano
+fi
+
DIR=$TMPDIR/mailimport$$
mkdir $DIR
if [ "$?" != "0" ]; then
@@ -34,58 +44,95 @@ TMP2=$DIR/patchheader
apply_patch () {
next=$1
- echo patch -s -t -p1 --dry-run -l -N -d linux -i $next
- patch -s -t -p1 --dry-run -l -N -d linux -i $next
- if [ "$?" != "0" ]; then
- $head $next
- echo "*** ERROR"
- exit
- fi
+ unset cont
+ until [ "$cont" == "0" ]; do
+ cont=1
+ pdir=linux
+ echo patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ if [ "$?" != "0" ]; then
+ pdir=.
+ echo patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ fi
+
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR: Patch didn't applied well"
+ if [ "$exitonerror" != "" ]; then
+ $head $next
+ exit
+ fi
+ echo "** Edit file $next"
+ sleep 1
+ $EDITOR $next
+ else
+ echo "Patch applied OK against $pdir"
+ cont=0
+ fi
+ done
- nano $next
+ $EDITOR $next
unset cont
until [ "$cont" == "0" ]; do
cont=0
$head $next >$TMP2
- if [ "`grep 'Bad formed author' $TMP2`" != "" ]; then
- echo Patch bad formed. Please fix.
+ if [ "`grep '^Bad:' $TMP2`" != "" ]; then
+ echo "*** ERROR: Patch bad formed. Please fix."
sleep 1
- nano $next
+ $EDITOR $next
cont=1
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 linux -i $next
- hg qrefresh
+ make whitespace
+
+ 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