samples: . accepts previous comment as-is
When updating a sample configuration with a comment, a dot '.'
in the new comment keeps the previous comment.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
6 my_name="$( basename "${0}" )"
11 ${my_name} <repos_dir> <M.m.p>
18 [ -n "${repos}" ] || { usage; exit 1; }
19 [ -d "${repos}" ] || { printf "${my_name}: ${repos}: no such file or directory\n"; exit 1; }
20 [ -n "${version}" ] || { usage; exit 1; }
23 HGPLAIN=1 hg --config progress.disabled=true "$@"
32 split($2,a,":"); rev=a[1];
34 $0~/^summary:[[:space:]]*[[:digit:]]+\.[[:digit:]]+: '"${msg}"'/ \
36 printf( "%d\n", rev ); found=1;
40 r2=$( _hg log -b "${branch}" \
41 |awk '$1=="changeset:" {
43 printf( "%d\n", a[1] );
48 r1_log=$((r1+log_offset))
49 if [ ${#r1_log} -gt ${#r2} ]; then
60 I'm pleased to announce the release of crosstool-NG ${version}!
62 As usual, there has been quite a number of improvements, new features,
63 and bug fixes all around. The most notable changes are listed below:
66 YEM: PUT YOUR MESSAGE HERE
69 This marks the beginning of the ${ver_M}.${ver_m} maintenance branch, and the end of
70 the previous maintenance branch. As always, comments and suggestions
73 The release can be found at the following URLs:
74 Changelog: http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${version}.changelog
75 Tarball: http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${version}.tar.bz2
76 Patches: http://crosstool-ng.org/download/crosstool-ng/01-fixes/${version}/
78 As a reminder, the home for crosstool-NG is:
79 http://crosstool-ng.org/
81 Crosstool-NG also has a Freshmeat page:
82 http://freshmeat.net/projects/crosstool-ng
86 print_intro_changelog_full_release() {
88 crosstool-NG ${version} -- ${date}
90 This is a feature-release. Significant changes are:
93 YEM: PUT YOUR MESSAGE HERE
98 print_intro_changelog_bug_fix() {
100 crosstool-NG ${version} -- ${date}
102 This is a bug-fix-only release.
106 print_author_stats() {
107 printf "\nMany thanks to the people who contributed to this release:\n\n"
109 template='{author|person}\n'
110 _hg log -b "${branch}" -r "${r1_log}:${r2}" \
111 --template "${template}" \
112 |sed -r -e 's/"//g;' \
117 for( author in nb ) {
118 printf( " %4d %s\n", nb[author], author );
124 print_author_shortlog() {
125 printf "\nHere is the per-author shortlog:\n"
127 template='{author|person}|{rev}|{branches}|{desc|firstline}\n'
128 _hg log -b "${branch}" -r "${r1_log}:${r2}" \
129 --template "${template}" \
132 printf( "%s", gensub("\"","","g",a[1]) );
133 printf( "|%0*d", '${rev_w}', a[2] );
135 printf( "|%s", a[i] );
141 author="$( echo "${line}" |cut -d \| -f 1 )"
142 rev="$( echo "${line}" |cut -d \| -f 2 )"
143 br="$( echo "${line}" |cut -d \| -f 3 )"
144 desc="$( echo "${line}" |cut -d \| -f 4- )"
154 *": close "*" branch"*) continue;;
155 # *\(merged\)) continue;;
158 author="$( echo "${author}" |sed -r -e 's/"//g;' )"
160 if [ ! "${prev_author}" = "${author}" ]; then
162 printf " ${author}:\n"
163 prev_author="${author}"
165 rev="$( echo "${rev}" |sed -r -e 's/^0*//;' )"
167 printf "%s\n" "${desc}" \
169 |(first=1; while read l; do
170 if [ -n "${first}" ]; then
171 printf " [%*d] %s\n" ${rev_w} ${rev} "${l}"
174 printf " %*.*s %s\n" ${rev_w} ${rev_w} '' "${l}"
181 printf "\nThe diffstat follows:\n\n"
182 _hg diff -r "${r1}:${r2}" --color=never \
183 |diffstat -r 2 -p 1 -w 10 \
185 |sed -r -e 's/^ */ /;'
187 _hg diff -r "${r1}:${r2}" --color=never \
188 |diffstat -f 1 -r 2 -p 1 -w 10 \
190 |while read file line; do
191 if [ ${#file} -gt 57 ]; then
192 file="$( echo "${file}" |sed -r -e 's/^(.{,24}).*(.{28})$/\1.....\2/;' )"
194 printf " %-57s %s\n" "${file}" "${line}"
198 print_short_diffstat() {
199 printf "\nThe short diffstat follows:\n\n"
202 _hg diff -r "${r1}:${r2}" --color=never "${i}" \
203 |diffstat -r 2 -p 1 -w 10 \
205 |sed -r -e 's/^[[:space:]]*[[:digit:]]+ files? changed(,[[:space:]]+|$)//;' \
206 -e 's/([[:digit:]]+)[^-\+]+\((-|\+)\)/\1/g;' \
207 -e 's/,//g; s/ /+/; s/^$/0/;'
209 printf " %-24.24s %5d(+/-)\n" "Total" ${total}
220 _hg diff -r "${r1}:${r2}" --color=never "${i}" \
221 |diffstat -r 2 -p 1 -w 10 \
223 |sed -r -e 's/^[[:space:]]*[[:digit:]]+ files? changed(,[[:space:]]+|$)//;' \
224 -e 's/([[:digit:]]+)[^-\+]+\((-|\+)\)/\1/g;' \
225 -e 's/,//g; s/ /+/; s/^$/0/;'
227 if [ ${val} -gt $((total/100)) ]; then
228 printf "%d %s\n" $(((1000*val)/total)) "${i}"
229 others=$((others-val))
231 done; printf "%d Others\n" $(((1000*others)/total)); } \
233 |{ while read v i; do
234 if [ "${i}" = "Others" ]; then
237 printf " %-24.24s %3d.%d%%\n" "${i}" $((v/10)) $((v%10))
239 done; printf " %-24.24s %3d.%d%%\n" "Others" $((others/10)) $((others%10)); }
242 ver_M="$( printf "${version}" |cut -d . -f 1 )"
243 ver_m="$( printf "${version}" |cut -d . -f 2 )"
244 ver_p="$( printf "${version}" |cut -d . -f 3 )"
246 prefix="$(pwd)/crosstool-ng-${version}"
247 pushd "${repos}" >/dev/null 2>&1
249 printf "Checking for existing tag: "
250 if _hg tags |grep -E '^'"crosstool-ng-${version}"'\>' >/dev/null; then
251 printf "already tagged\n"
256 if [ ${ver_p} -eq 0 ]; then
258 print_intro_changelog="print_intro_changelog_full_release"
260 msg="create maintenance branch, (update|bump) version to [[:digit:]]+"'\'".[[:digit:]]+"'\'".0"'$'
265 print_intro_changelog="print_intro_changelog_bug_fix"
267 msg="(update|bump) version to ${ver_M}"'\'".${ver_m}"'\'".$((ver_p-1))"'\+hg$'
268 branch="${ver_M}.${ver_m}"
272 printf "Computing boundary revisions:"
274 printf " %d:%d\n" ${r1} ${r2}
276 printf "Tagging release:"
277 _hg up "${branch}" >/dev/null
278 if [ ${ver_p} -eq 0 ]; then
279 printf " update version"
280 _hg branch "${ver_M}.${ver_m}" >/dev/null
281 echo "${version}" >".version"
282 _hg ci -m "${ver_M}.${ver_m}: create maintenance branch, update version to ${version}"
284 printf " update version"
285 echo "${version}" >".version"
286 _hg ci -m "${ver_M}.${ver_m}: update version to ${version}"
290 _hg tag -m "Tagging release ${version}" crosstool-ng-${version}
292 printf ", update version"
293 echo "${version}+hg" >".version"
294 _hg ci -m "${ver_M}.${ver_m}: update version to ${version}+hg"
297 date="$( _hg log -r crosstool-ng-${version} --template '{date|isodate}\n' \
298 |sed -r -e 's/-|://g; s/ /./; s/ //;' \
302 if [ ${ver_p} -eq 0 ]; then
303 printf "Generating release mail:"
305 print_intro_mail > "${prefix}.mail"
307 print_author_stats >>"${prefix}.mail"
309 print_author_shortlog >>"${prefix}.mail"
311 print_short_diffstat >>"${prefix}.mail"
315 printf "Generating release changelog:"
317 ${print_intro_changelog} > "${prefix}.changelog"
319 print_author_stats >>"${prefix}.changelog"
321 print_author_shortlog >>"${prefix}.changelog"
323 print_diffstat >>"${prefix}.changelog"
328 printf "Creating tarball:"
329 prefix="crosstool-ng-${version}"
331 date="$( _hg log -R "${repos}" -r "${prefix}" --template '{date|rfc822date}\n' )"
332 tmpdir="$( mktemp -d --tmpdir XXXXXX )"
333 _hg archive --cwd "${repos}" -r "${prefix}" -X '.hg*' --type files "${tmpdir}/${prefix}"
335 pushd "${tmpdir}/${prefix}" >/dev/null 2>&1
336 ./bootstrap >/dev/null
337 rm -rf autom4te.cache
340 tar cjf "$(pwd)/${prefix}.tar.bz2" -C "${tmpdir}" "${prefix}"
343 for s in md5 sha1 sha512; do
344 ${s}sum "${prefix}.tar.bz2" >"${prefix}.tar.bz2.${s}"
347 touch -d "${date}" "${prefix}"*
350 if [ ${ver_p} -eq 0 ]; then
351 printf "\nAn editor will be launched for you to edit the mail.\n"
352 read -p "Press enter when ready..." foo
353 cp "${prefix}.mail"{,.orig}
355 diff -du -U 1 "${prefix}.mail"{.orig,} |patch -p0 "${prefix}.changelog" >/dev/null
356 rm -f "${prefix}".{mail,changelog}.orig
359 printf "\nAn editor will be launched for you to review the changelog.\n"
360 read -p "Press enter when ready..." foo
361 vi "${prefix}.changelog"
363 printf "\nNow, you can push the changes with: hg push -R '${repos}'\n"