2010-12-03 05:34:57 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# This script merges changes from the master copy of the Go library
|
|
|
|
# into the libgo library. This does the easy stuff; the hard stuff is
|
|
|
|
# left to the user.
|
|
|
|
|
|
|
|
# The file MERGE should hold the Mercurial revision number of the last
|
|
|
|
# revision which was merged into these sources. Given that, and given
|
|
|
|
# the current sources, we can run the usual diff3 algorithm to merge
|
|
|
|
# all changes into our sources.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TMPDIR=${TMPDIR:-/tmp}
|
|
|
|
|
|
|
|
OLDDIR=${TMPDIR}/libgo-merge-old
|
|
|
|
NEWDIR=${TMPDIR}/libgo-merge-new
|
|
|
|
|
|
|
|
if ! test -f MERGE; then
|
|
|
|
echo 1>&2 "merge.sh: must be run in libgo source directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-12-02 20:27:25 +01:00
|
|
|
rev=weekly
|
|
|
|
case $# in
|
|
|
|
1) ;;
|
|
|
|
2) rev=$2 ;;
|
|
|
|
*)
|
|
|
|
echo 1>&2 "merge.sh: Usage: merge.sh mercurial-repository [revision]"
|
2010-12-03 05:34:57 +01:00
|
|
|
exit 1
|
2011-12-02 20:27:25 +01:00
|
|
|
;;
|
|
|
|
esac
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
repository=$1
|
|
|
|
|
2011-09-16 17:47:21 +02:00
|
|
|
old_rev=`sed 1q MERGE`
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
rm -rf ${OLDDIR}
|
2011-09-16 17:47:21 +02:00
|
|
|
hg clone -r ${old_rev} ${repository} ${OLDDIR}
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
rm -rf ${NEWDIR}
|
2011-12-02 20:27:25 +01:00
|
|
|
hg clone -u ${rev} ${repository} ${NEWDIR}
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2011-12-02 20:27:25 +01:00
|
|
|
new_rev=`cd ${NEWDIR} && hg log -r ${rev} | sed 1q | sed -e 's/.*://'`
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
merge() {
|
|
|
|
name=$1
|
|
|
|
old=$2
|
|
|
|
new=$3
|
|
|
|
libgo=$4
|
|
|
|
if ! test -f ${new}; then
|
|
|
|
# The file does not exist in the new version.
|
|
|
|
if ! test -f ${old}; then
|
|
|
|
echo 1>&2 "merge.sh internal error no files $old $new"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! test -f ${libgo}; then
|
|
|
|
# File removed in new version and libgo.
|
|
|
|
:;
|
|
|
|
else
|
|
|
|
echo "merge.sh: ${name}: REMOVED"
|
|
|
|
rm -f ${libgo}
|
|
|
|
hg rm ${libgo}
|
|
|
|
fi
|
|
|
|
elif test -f ${old}; then
|
|
|
|
# The file exists in the old version.
|
|
|
|
if ! test -f ${libgo}; then
|
|
|
|
echo "merge.sh: $name: skipping: exists in old and new hg, but not in libgo"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if cmp -s ${old} ${libgo}; then
|
|
|
|
# The libgo file is unchanged from the old version.
|
|
|
|
if cmp -s ${new} ${libgo}; then
|
|
|
|
# File is unchanged from old to new version.
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
# Update file in libgo.
|
|
|
|
echo "merge.sh: $name: updating"
|
|
|
|
cp ${new} ${libgo}
|
|
|
|
else
|
|
|
|
# The libgo file has local changes.
|
|
|
|
set +e
|
|
|
|
diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
case $status in
|
|
|
|
0)
|
|
|
|
echo "merge.sh: $name: updating"
|
|
|
|
mv ${libgo}.tmp ${libgo}
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
echo "merge.sh: $name: CONFLICTS"
|
|
|
|
mv ${libgo}.tmp ${libgo}
|
|
|
|
hg resolve -u ${libgo}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo 1>&2 "merge.sh: $name: diff3 failure"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# The file does not exist in the old version.
|
|
|
|
if test -f ${libgo}; then
|
|
|
|
if ! cmp -s ${new} ${libgo}; then
|
|
|
|
echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "merge.sh: $name: NEW"
|
|
|
|
dir=`dirname ${libgo}`
|
|
|
|
if ! test -d ${dir}; then
|
|
|
|
mkdir -p ${dir}
|
|
|
|
fi
|
|
|
|
cp ${new} ${libgo}
|
|
|
|
hg add ${libgo}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
merge_c() {
|
|
|
|
from=$1
|
|
|
|
to=$2
|
2015-01-15 01:27:56 +01:00
|
|
|
oldfile=${OLDDIR}/src/runtime/$from
|
2011-12-03 03:17:34 +01:00
|
|
|
if test -f ${oldfile}; then
|
|
|
|
sed -e 's/·/_/g' < ${oldfile} > ${oldfile}.tmp
|
|
|
|
oldfile=${oldfile}.tmp
|
2015-01-15 01:27:56 +01:00
|
|
|
newfile=${NEWDIR}/src/runtime/$from
|
2011-12-03 03:17:34 +01:00
|
|
|
sed -e 's/·/_/g' < ${newfile} > ${newfile}.tmp
|
|
|
|
newfile=${newfile}.tmp
|
|
|
|
libgofile=runtime/$to
|
|
|
|
merge $from ${oldfile} ${newfile} ${libgofile}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-01-22 00:03:41 +01:00
|
|
|
if test -f VERSION; then
|
|
|
|
if ! cmp -s ${NEWDIR}/VERSION VERSION; then
|
|
|
|
cp ${NEWDIR}/VERSION .
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if test -f ${NEWDIR}/VERSION; then
|
|
|
|
cp ${NEWDIR}/VERSION .
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
(cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/src/$f
|
|
|
|
newfile=${NEWDIR}/src/$f
|
2010-12-03 05:34:57 +01:00
|
|
|
libgofile=go/$f
|
|
|
|
merge $f ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
(cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
|
|
|
|
oldtd=${OLDDIR}/src/$d
|
|
|
|
newtd=${NEWDIR}/src/$d
|
2010-12-03 05:34:57 +01:00
|
|
|
libgotd=go/$d
|
|
|
|
if ! test -d ${oldtd}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
(cd ${oldtd} && hg status -A .) | while read f; do
|
|
|
|
if test "`basename $f`" = ".hgignore"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
f=`echo $f | sed -e 's/^..//'`
|
|
|
|
name=$d/$f
|
|
|
|
oldfile=${oldtd}/$f
|
|
|
|
newfile=${newtd}/$f
|
|
|
|
libgofile=${libgotd}/$f
|
|
|
|
merge ${name} ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2015-01-07 00:26:02 +01:00
|
|
|
cmdlist="cgo go gofmt"
|
|
|
|
for c in $cmdlist; do
|
|
|
|
(cd ${NEWDIR}/src/cmd/$c && find . -name '*.go' -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/src/cmd/$c/$f
|
|
|
|
newfile=${NEWDIR}/src/cmd/$c/$f
|
|
|
|
libgofile=go/cmd/$c/$f
|
|
|
|
merge $f ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
|
|
|
|
(cd ${NEWDIR}/src/cmd/$c && find . -name testdata -print) | while read d; do
|
|
|
|
oldtd=${OLDDIR}/src/cmd/$c/$d
|
|
|
|
newtd=${NEWDIR}/src/cmd/$c/$d
|
|
|
|
libgotd=go/cmd/$c/$d
|
|
|
|
if ! test -d ${oldtd}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
(cd ${oldtd} && hg status -A .) | while read f; do
|
|
|
|
if test "`basename $f`" = ".hgignore"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
f=`echo $f | sed -e 's/^..//'`
|
|
|
|
name=$d/$f
|
|
|
|
oldfile=${oldtd}/$f
|
|
|
|
newfile=${newtd}/$f
|
|
|
|
libgofile=${libgotd}/$f
|
|
|
|
merge ${name} ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2014-07-19 10:53:52 +02:00
|
|
|
runtime="chan.goc chan.h cpuprof.goc env_posix.c heapdump.c lock_futex.c lfstack.goc lock_sema.c mcache.c mcentral.c mfixalloc.c mgc0.c mgc0.h mheap.c msize.c netpoll.goc netpoll_epoll.c netpoll_kqueue.c netpoll_stub.c panic.c print.c proc.c race.h rdebug.goc runtime.c runtime.h signal_unix.c signal_unix.h malloc.h malloc.goc mprof.goc parfor.c runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
|
2010-12-03 05:34:57 +01:00
|
|
|
for f in $runtime; do
|
2015-01-15 01:27:56 +01:00
|
|
|
# merge_c $f $f
|
|
|
|
true
|
2011-12-02 20:27:25 +01:00
|
|
|
done
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
# merge_c os_linux.c thread-linux.c
|
|
|
|
# merge_c mem_linux.c mem.c
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
(cd ${OLDDIR}/src && find . -name '*.go' -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/src/$f
|
|
|
|
newfile=${NEWDIR}/src/$f
|
2010-12-03 05:34:57 +01:00
|
|
|
libgofile=go/$f
|
|
|
|
if test -f ${newfile}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if ! test -f ${libgofile}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "merge.sh: ${libgofile}: REMOVED"
|
|
|
|
rm -f ${libgofile}
|
|
|
|
hg rm ${libgofile}
|
|
|
|
done
|
|
|
|
|
|
|
|
(echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
|
|
|
|
mv MERGE.tmp MERGE
|