monotone

monotone Mtn Source Tree

Root/contrib/ChangeLog.sh

  • Property mtn:execute set to true
1#!/bin/sh
2# Usage: ChangeLog [<num>] [-d database] [-r revision]
3# Construct and print a ChangeLog for the last <num> revisions from their
4# date, author, and changelog certs.
5
6# If <num> is not given, it defaults to 15
7
8# If this script is not run from the root of a monotone workspace, both
9# the -d and -r options are required.
10
11NUM=15
12MTN=mtn
13LANG=C; export LANG
14
15while ! [ $# -eq 0 ] ; do
16case "$1" in
17-r) shift; REV="$1";;
18-d) shift; DB="-d $1";;
19*) NUM=$(($1 - 1));;
20esac
21shift
22done
23
24if [ "x$REV" = "x" ]; then
25REV=`mtn automate get_base_revision_id 2>/dev/null`
26fi
27
28if [ "x$REV" = "x" ] || [ "x$DB" = "x" ]; then
29if ! mtn status >/dev/null 2>/dev/null; then
30echo "Both the -d and -r arguments are needed when this" >&2;
31echo "script is not run from inside a monotone workspace." >&2;
32exit 1;
33fi
34fi
35
36# Get the contents of a cert
37LOG='/^Name.*changelog$/,/^----/! D; /^Name/ D; /^----/ D'
38DATE='/^Name.*date$/,/^----/! D; /^Name/ D; /^----/ D'
39AUTHOR='/^Name.*author$/,/^----/! D; /^Name/ D; /^----/ D'
40
41# Remove "duplicate" lines (When the date+author line is unneeded because
42# the same info is in the changelog cert (won't match exactly, but should
43# both start with ^${year} ))
44# Keep the line from the changelog, instead of the generated one
45RD=':b; N; /^[[:digit:]]\{4\}.*\n[[:digit:]]\{4\}/ { s/^.*\n//; b b; }; P; D'
46
47get()
48{
49$MTN $DB ls certs "$2" | sed "$1" \
50| sed 's/^[^\:]\+\: //g'
51}
52
53getrevs()
54{
55$MTN $DB automate ancestors "$1" \
56| $MTN $DB automate toposort -@- \
57| tail -n "$2" | tac
58}
59
60getlogs()
61{
62for i in "$REV" `getrevs "$REV" "$NUM"`; do
63echo `get "$DATE" "$i"` '' `get "$AUTHOR" "$i"`
64get "$LOG" "$i" | sed 's/^\([^[:digit:]\t]\)/\t\1/g'
65done
66}
67
68
69if [ ! x$REV = x ]; then
70getlogs | sed "$RD" | sed '/^$/ d' \
71| sed 's/^\([[:digit:]]\{4\}.*\)$/\n\1\n/g'
72else
73echo "_MTN/revision does not exist!" >&2
74fi

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status