Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > db7a42361fc52f1236a61b01ceee68a3 > files > 1510

bzr-2.0.1-1mdv2010.0.x86_64.rpm

#! /bin/sh -pe

# take patches from patchwork into bzr

# authentication must be in ~/.netrc

# TODO: Scan all pending patches and say which ones apply cleanly.

# these should be moved into some kind of per-project configuration
PWK_ROOT='http://patchwork.ozlabs.org/bazaar-ng'
PWK_AUTH_ROOT='https://patchwork.ozlabs.org/bazaar-ng'

usage() {
    cat <<EOF
usage: 
   pwk cat PATCH-ID       show the patch text
   pwk try PATCH-ID        see if the patch applies cleanly
   pwk apply PATCH-ID      apply patch into current directory
EOF
}

catpatch() {
    curl --silent --show-error --get -d id=$1 $PWK_ROOT/patchcontent
}

if [ $# -lt 1 ]
then
    usage
    exit 1
fi


case "$1" in
help|-h|--help)
    usage
    exit 0
    ;;
cat)
    catpatch $2 | ${PAGER:-less}
    ;;
try)
    catpatch $2 | patch -p1 --dry-run
    ;;
apply)
    catpatch $2 | patch -p1
    ;;
*)
    usage
    exit 1
esac