diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-07-27 09:58:40 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-07-27 09:58:40 -0300 |
commit | 653eaac0fcf120902f0f98628f9e962225fe1d1d (patch) | |
tree | 8fe2a3bf3440f1f55cf5c72f8173af94f2c294b8 | |
parent | 2cfa30295ea7fc283f90be4b0b91fc9cfefaf96b (diff) | |
download | mediapointer-dvb-s2-653eaac0fcf120902f0f98628f9e962225fe1d1d.tar.gz mediapointer-dvb-s2-653eaac0fcf120902f0f98628f9e962225fe1d1d.tar.bz2 |
Add a script to allow cherry picking patches from another hg tree
From: Mauro Carvalho Chehab <mchehab@infradead.org>
This script allows cherry picking patches from other mercurial trees. It
identifies the newer patches yet not applied at the current tree and
download they to a temporary dir.
The script works with other local trees, as well as with remote URLs.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rwxr-xr-x | hgimport | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/hgimport b/hgimport new file mode 100755 index 000000000..e286f374b --- /dev/null +++ b/hgimport @@ -0,0 +1,61 @@ +#!/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 <url>" + 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 |