summaryrefslogtreecommitdiffstats
path: root/pullrev.sh
blob: 7ee601e3199c4edaf40a61c3ca029de09a78e2ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh -e

if [ $# -lt 1 ]; then
    echo "What?"
    exit 1
fi

repo="https://svn.apache.org/repos/asf/httpd/httpd/trunk"
ver=2.4.2
prefix="httpd-${ver}"
suffix="r$1${2:++}"
fn="${prefix}-${suffix}.patch"
vcurl="http://svn.apache.org/viewvc?view=revision&revision="

if test -f ${fn}; then
    mv -v -f ${fn} ${fn}\~
    echo "# $0 $*" > ${fn}
    sed '1{/#.*pullrev/d;};/^--- /,$d' < ${fn}\~ >> ${fn}
else
    echo "# $0 $*" > ${fn}
fi

new=0
for r in $*; do
   if ! grep -q "${vcurl}${r}" ${fn}; then
       echo "${vcurl}${r}"
       new=1
   fi
done >> ${fn}

[ $new -eq 0 ] || echo >> ${fn}

prev=/dev/null
for r in $*; do
    echo "+ fetching ${r}"
    this=`mktemp /tmp/pullrevXXXXXX`
    svn diff -c ${r} ${repo} | filterdiff --remove-timestamps -x 'CHANGES' -x 'next-number' \
        --addprefix="${prefix}/" > ${this}
    next=`mktemp /tmp/pullrevXXXXXX`
    combinediff --quiet ${prev} ${this} > ${next}
    rm -f "${this}"
    [ "${prev}" = "/dev/null" ] || rm -f "${prev}"
    prev=${next}
done

cat ${prev} >> ${fn}

vi "${fn}"
echo "+ git add ${fn}" 
git add "${fn}"
echo "+ spec template:"
echo "PatchN: ${fn}"
echo "%patchN -p1 -b .${suffix}"