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

Archive Download this file

Branches

Tags

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