OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [merge.sh] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
#!/bin/sh
2
 
3
# Copyright 2009 The Go Authors. All rights reserved.
4
# Use of this source code is governed by a BSD-style
5
# license that can be found in the LICENSE file.
6
 
7
# This script merges changes from the master copy of the Go library
8
# into the libgo library.  This does the easy stuff; the hard stuff is
9
# left to the user.
10
 
11
# The file MERGE should hold the Mercurial revision number of the last
12
# revision which was merged into these sources.  Given that, and given
13
# the current sources, we can run the usual diff3 algorithm to merge
14
# all changes into our sources.
15
 
16
set -e
17
 
18
TMPDIR=${TMPDIR:-/tmp}
19
 
20
OLDDIR=${TMPDIR}/libgo-merge-old
21
NEWDIR=${TMPDIR}/libgo-merge-new
22
 
23
if ! test -f MERGE; then
24
  echo 1>&2 "merge.sh: must be run in libgo source directory"
25
  exit 1
26
fi
27
 
28
rev=weekly
29
case $# in
30
1) ;;
31
2) rev=$2 ;;
32
*)
33
  echo 1>&2 "merge.sh: Usage: merge.sh mercurial-repository [revision]"
34
  exit 1
35
  ;;
36
esac
37
 
38
repository=$1
39
 
40
old_rev=`sed 1q MERGE`
41
 
42
rm -rf ${OLDDIR}
43
hg clone -r ${old_rev} ${repository} ${OLDDIR}
44
 
45
rm -rf ${NEWDIR}
46
hg clone -u ${rev} ${repository} ${NEWDIR}
47
 
48
new_rev=`cd ${NEWDIR} && hg log -r ${rev} | sed 1q | sed -e 's/.*://'`
49
 
50
merge() {
51
  name=$1
52
  old=$2
53
  new=$3
54
  libgo=$4
55
  if ! test -f ${new}; then
56
    # The file does not exist in the new version.
57
    if ! test -f ${old}; then
58
      echo 1>&2 "merge.sh internal error no files $old $new"
59
      exit 1
60
    fi
61
    if ! test -f ${libgo}; then
62
      # File removed in new version and libgo.
63
      :;
64
    else
65
      echo "merge.sh: ${name}: REMOVED"
66
      rm -f ${libgo}
67
      hg rm ${libgo}
68
    fi
69
  elif test -f ${old}; then
70
    # The file exists in the old version.
71
    if ! test -f ${libgo}; then
72
      echo "merge.sh: $name: skipping: exists in old and new hg, but not in libgo"
73
      continue
74
    fi
75
    if cmp -s ${old} ${libgo}; then
76
      # The libgo file is unchanged from the old version.
77
      if cmp -s ${new} ${libgo}; then
78
        # File is unchanged from old to new version.
79
        continue
80
      fi
81
      # Update file in libgo.
82
      echo "merge.sh: $name: updating"
83
      cp ${new} ${libgo}
84
    else
85
      # The libgo file has local changes.
86
      set +e
87
      diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
88
      status=$?
89
      set -e
90
      case $status in
91
      0)
92
        echo "merge.sh: $name: updating"
93
        mv ${libgo}.tmp ${libgo}
94
        ;;
95
      1)
96
        echo "merge.sh: $name: CONFLICTS"
97
        mv ${libgo}.tmp ${libgo}
98
        hg resolve -u ${libgo}
99
        ;;
100
      *)
101
        echo 1>&2 "merge.sh: $name: diff3 failure"
102
        exit 1
103
        ;;
104
      esac
105
    fi
106
  else
107
    # The file does not exist in the old version.
108
    if test -f ${libgo}; then
109
      if ! cmp -s ${new} ${libgo}; then
110
        echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
111
      fi
112
    else
113
      echo "merge.sh: $name: NEW"
114
      dir=`dirname ${libgo}`
115
      if ! test -d ${dir}; then
116
        mkdir -p ${dir}
117
      fi
118
      cp ${new} ${libgo}
119
      hg add ${libgo}
120
    fi
121
  fi
122
}
123
 
124
merge_c() {
125
  from=$1
126
  to=$2
127
  oldfile=${OLDDIR}/src/pkg/runtime/$from
128
  if test -f ${oldfile}; then
129
    sed -e 's/·/_/g' < ${oldfile} > ${oldfile}.tmp
130
    oldfile=${oldfile}.tmp
131
    newfile=${NEWDIR}/src/pkg/runtime/$from
132
    sed -e 's/·/_/g' < ${newfile} > ${newfile}.tmp
133
    newfile=${newfile}.tmp
134
    libgofile=runtime/$to
135
    merge $from ${oldfile} ${newfile} ${libgofile}
136
  fi
137
}
138
 
139
(cd ${NEWDIR}/src/pkg && find . -name '*.go' -print) | while read f; do
140
  oldfile=${OLDDIR}/src/pkg/$f
141
  newfile=${NEWDIR}/src/pkg/$f
142
  libgofile=go/$f
143
  merge $f ${oldfile} ${newfile} ${libgofile}
144
done
145
 
146
(cd ${NEWDIR}/src/pkg && find . -name testdata -print) | while read d; do
147
  oldtd=${OLDDIR}/src/pkg/$d
148
  newtd=${NEWDIR}/src/pkg/$d
149
  libgotd=go/$d
150
  if ! test -d ${oldtd}; then
151
    continue
152
  fi
153
  (cd ${oldtd} && hg status -A .) | while read f; do
154
    if test "`basename $f`" = ".hgignore"; then
155
      continue
156
    fi
157
    f=`echo $f | sed -e 's/^..//'`
158
    name=$d/$f
159
    oldfile=${oldtd}/$f
160
    newfile=${newtd}/$f
161
    libgofile=${libgotd}/$f
162
    merge ${name} ${oldfile} ${newfile} ${libgofile}
163
  done
164
done
165
 
166
runtime="chan.c cpuprof.c goc2c.c lock_futex.c lock_sema.c mcache.c mcentral.c mfinal.c mfixalloc.c mgc0.c mheap.c msize.c proc.c runtime.c runtime.h malloc.h malloc.goc mprof.goc runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
167
for f in $runtime; do
168
  merge_c $f $f
169
done
170
 
171
merge_c thread_linux.c thread-linux.c
172
merge_c mem_linux.c mem.c
173
 
174
(cd ${OLDDIR}/src/pkg && find . -name '*.go' -print) | while read f; do
175
  oldfile=${OLDDIR}/src/pkg/$f
176
  newfile=${NEWDIR}/src/pkg/$f
177
  libgofile=go/$f
178
  if test -f ${newfile}; then
179
    continue
180
  fi
181
  if ! test -f ${libgofile}; then
182
    continue
183
  fi
184
  echo "merge.sh: ${libgofile}: REMOVED"
185
  rm -f ${libgofile}
186
  hg rm ${libgofile}
187
done
188
 
189
(echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
190
mv MERGE.tmp MERGE

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.