#!/bin/bash # Copyright (c) 2006-2007 Mauro Carvalho Chehab (mchehab@infradead.org) # This code is placed under the terms of the GNU General Public License v2 # #This script is capable to mass import patches from a mercurial tree # if [ "$1" == "" ]; then echo "Usage: $0 " exit fi TREE="`echo $1|perl -ne 's|[/]$||; s|^.*[/]||; print $_;'`" if [[ "`echo $1|grep ^http://`" != "" ]]; then SITE="`echo $1|perl -ne 's|[/]$||; print $_;'`" echo Pushing from remote site $SITE, tree: $TREE else DIR=$1 echo "Pushing from local directory $DIR, tree=$TREE" fi if [ "$TMP" == "" ]; then TMP=/tmp fi TMP=$TMP/newpatches if [ ! -d $TMP ]; then mkdir $TMP else rm $TMP/* fi if [ "$DIR" != "" ]; then CS="`hg outgoing -R $DIR .|grep 'changeset:'|cut -f2 -d:`" else CS="`hg incoming $SITE |grep 'changeset:'|cut -f3 -d:`" fi NUM="`echo $CS|wc -w`" echo Number of patches: $NUM j=1 for i in $CS; do name=$TMP/hg_${TREE}_$(printf %0${#NUM}d ${j}).patch echo $name with cs=$i if [ "$DIR" != "" ]; then hg export -R $DIR $i >$name else wget -q -O $name "$SITE?cmd=changeset;node=$i;style=raw" fi j=$((j+1)) done echo "Diffstat of the imported series:" diffstat -w 72 -p1 $TMP/hg_${TREE}_*.patch # To cherry pick all files, you can do something like: #for i in $TMP/newpatches/*; do # hg import $i; #done