c5a1e6a
#!/bin/sh -e
c5a1e6a
c5a1e6a
if [ $# -lt 1 ]; then
c5a1e6a
    echo "What?"
c5a1e6a
    exit 1
c5a1e6a
fi
c5a1e6a
c5a1e6a
repo="https://svn.apache.org/repos/asf/subversion/trunk"
c5a1e6a
#repo="https://svn.apache.org/repos/asf/subversion/branches/1.11.x"
c5a1e6a
prefix=`rpmspec -q --queryformat='%{name}-%{version}\n' ./subversion.spec | sed 1q`
c5a1e6a
suffix="r$1${2:++}"
c5a1e6a
fn="${prefix}-${suffix}.patch"
c5a1e6a
vcurl="http://svn.apache.org/viewvc?view=revision&revision="
c5a1e6a
c5a1e6a
if test -f ${fn}; then
c5a1e6a
    mv -v -f ${fn} ${fn}\~
c5a1e6a
    echo "# $0 $*" > ${fn}
c5a1e6a
    sed '1{/#.*pullrev/d;};/^--- /,$d' < ${fn}\~ >> ${fn}
c5a1e6a
else
c5a1e6a
    echo "# $0 $*" > ${fn}
c5a1e6a
fi
c5a1e6a
c5a1e6a
new=0
c5a1e6a
for r in $*; do
c5a1e6a
   if ! grep -q "${vcurl}${r}" ${fn}; then
c5a1e6a
       echo "${vcurl}${r}"
c5a1e6a
       new=1
c5a1e6a
   fi
c5a1e6a
done >> ${fn}
c5a1e6a
c5a1e6a
[ $new -eq 0 ] || echo >> ${fn}
c5a1e6a
c5a1e6a
prev=/dev/null
c5a1e6a
for r in $*; do
c5a1e6a
    echo "+ fetching ${r}"
c5a1e6a
    this=`mktemp /tmp/pullrevXXXXXX`
c5a1e6a
    svn diff -c ${r} ${repo} | filterdiff --remove-timestamps --clean -x 'CHANGES' -x 'next-number' -x 'STATUS' \
c5a1e6a
        --addprefix="${prefix}/" > ${this}
c5a1e6a
    next=`mktemp /tmp/pullrevXXXXXX`
c5a1e6a
    combinediff --quiet ${prev} ${this} > ${next}
c5a1e6a
    rm -f "${this}"
c5a1e6a
    [ "${prev}" = "/dev/null" ] || rm -f "${prev}"
c5a1e6a
    prev=${next}
c5a1e6a
done
c5a1e6a
c5a1e6a
cat ${prev} >> ${fn}
c5a1e6a
c5a1e6a
vi "${fn}"
c5a1e6a
echo "+ git add ${fn}" 
c5a1e6a
git add "${fn}"
c5a1e6a
echo "+ spec template:"
c5a1e6a
echo "PatchN: ${fn}"
c5a1e6a
echo "%patchN -p1 -b .${suffix}"