~bzr-pqm/bzr/bzr.dev

699 by Martin Pool
- simpleminded patchwork client in shell
1
#! /bin/sh -pe
2
3
# take patches from patchwork into bzr
4
5
# authentication must be in ~/.netrc
6
730 by Martin Pool
- add help, try, apply options to pwk script
7
# TODO: Scan all pending patches and say which ones apply cleanly.
699 by Martin Pool
- simpleminded patchwork client in shell
8
730 by Martin Pool
- add help, try, apply options to pwk script
9
# these should be moved into some kind of per-project configuration
699 by Martin Pool
- simpleminded patchwork client in shell
10
PWK_ROOT='http://patchwork.ozlabs.org/bazaar-ng'
11
PWK_AUTH_ROOT='https://patchwork.ozlabs.org/bazaar-ng'
12
730 by Martin Pool
- add help, try, apply options to pwk script
13
# bzr uses -p0 style; others use -p1
14
PATCH_OPTS='-p0'
15
699 by Martin Pool
- simpleminded patchwork client in shell
16
usage() {
730 by Martin Pool
- add help, try, apply options to pwk script
17
    cat <<EOF
18
usage: 
856 by Martin Pool
- fix pwk help
19
   pwk cat PATCH-ID       show the patch text
730 by Martin Pool
- add help, try, apply options to pwk script
20
   pwk try PATCH-ID        see if the patch applies cleanly
21
   pwk apply PATCH-ID      apply patch into current directory
22
EOF
699 by Martin Pool
- simpleminded patchwork client in shell
23
}
24
25
catpatch() {
730 by Martin Pool
- add help, try, apply options to pwk script
26
    curl --silent --show-error --get -d id=$1 $PWK_ROOT/patchcontent
699 by Martin Pool
- simpleminded patchwork client in shell
27
}
28
730 by Martin Pool
- add help, try, apply options to pwk script
29
if [ $# -lt 1 ]
699 by Martin Pool
- simpleminded patchwork client in shell
30
then
31
    usage
32
    exit 1
33
fi
34
35
36
case "$1" in
730 by Martin Pool
- add help, try, apply options to pwk script
37
help|-h|--help)
38
    usage
39
    exit 0
40
    ;;
699 by Martin Pool
- simpleminded patchwork client in shell
41
cat)
730 by Martin Pool
- add help, try, apply options to pwk script
42
    catpatch $2 | ${PAGER:-less}
699 by Martin Pool
- simpleminded patchwork client in shell
43
    ;;
44
try)
45
    catpatch $2 | patch -p0 --dry-run
46
    ;;
730 by Martin Pool
- add help, try, apply options to pwk script
47
apply)
48
    catpatch $2 | patch -p0
49
    ;;
699 by Martin Pool
- simpleminded patchwork client in shell
50
*)
51
    usage
52
    exit 1
53
esac