diff options
author | 2006-02-06 13:49:20 +0000 | |
---|---|---|
committer | 2006-02-06 13:49:20 +0000 | |
commit | c2b1dd1eeaeb4bd4b0aaa6e3760dd5eac9e8e2fd (patch) | |
tree | b09b04264cac5963ee63a18d32e05e6e1b22fdc1 /scripts | |
parent | Revert last change, and add comment. (diff) | |
download | sandbox-c2b1dd1eeaeb4bd4b0aaa6e3760dd5eac9e8e2fd.tar.gz sandbox-c2b1dd1eeaeb4bd4b0aaa6e3760dd5eac9e8e2fd.tar.bz2 sandbox-c2b1dd1eeaeb4bd4b0aaa6e3760dd5eac9e8e2fd.zip |
Update svn2cl and fix parse issue with latest libxslt-1.1.15.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/svn2cl.sh | 97 | ||||
-rw-r--r-- | scripts/svn2cl.xsl | 79 |
2 files changed, 132 insertions, 44 deletions
diff --git a/scripts/svn2cl.sh b/scripts/svn2cl.sh index bf89bb0..06eba0e 100755 --- a/scripts/svn2cl.sh +++ b/scripts/svn2cl.sh @@ -32,46 +32,84 @@ # exit on any failures set -e +# report unset variables +set -u # svn2cl version -VERSION="0.3" +VERSION="0.5" # set default parameters -STRIPPREFIX=`basename $(pwd)` +PWD=`pwd` +STRIPPREFIX=`basename $PWD` LINELEN=75 GROUPBYDAY="no" INCLUDEREV="no" -CHANGELOG="ChangeLog" +CHANGELOG="" +OUTSTYLE="cl" +SVNCMD="svn --verbose --xml log" # do command line checking prog=`basename $0` -while [ -n "$1" ] +while [ $# -gt 0 ] do case "$1" in --strip-prefix) STRIPPREFIX="$2" - shift 2 + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --strip-prefix=*) + STRIPPREFIX="`echo "$1" | sed 's/--strip-prefix=//'`" + shift ;; --linelen) LINELEN="$2"; - shift 2 + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --linelen=*) + LINELEN="`echo "$1" | sed 's/--linelen=//'`" + shift ;; --group-by-day) GROUPBYDAY="yes"; shift ;; - -r|--include-rev) + -i|--include-rev) INCLUDEREV="yes"; shift ;; - -o|--output) + -f|--file|-o|--output) CHANGELOG="$2" - shift 2 + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --file=*|--output=*) + CHANGELOG="`echo "$1" | sed 's/--[^=]*=//'`" + shift ;; --stdout) CHANGELOG="-" shift ;; + --html) + OUTSTYLE="html" + shift + ;; + -r|--revision|--targets|--username|--password|--config-dir|--limit) + # add these as extra options to the command (with argument) + arg=`echo "$2" | sed "s/'/'\"'\"'/g"` + SVNCMD="$SVNCMD $1 '$arg'" + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --revision=*|--targets=*|--username=*|--password=*|--config-dir=*|--limit=*) + # these are single argument versions of the above + arg=`echo "$1" | sed "s/'/'\"'\"'/g"` + SVNCMD="$SVNCMD '$arg'" + shift + ;; + --stop-on-copy|--no-auth-cache|--non-interactive) + # add these as simple options + SVNCMD="$SVNCMD $1" + shift + ;; -V|--version) echo "$prog $VERSION"; echo "Written by Arthur de Jong." @@ -82,26 +120,37 @@ do exit 0 ;; -h|--help) - echo "Usage: $prog [OPTION]..." - echo "Generate a ChangeLog from a checked out subversion repository." + echo "Usage: $prog [OPTION]... [PATH]..." + echo "Generate a ChangeLog from a subversion repository." echo "" - echo " --strip-prefix NAME prefix to strip from all entries, defaults" + echo " --strip-prefix=NAME prefix to strip from all entries, defaults" echo " to the name of the current directory" - echo " --linelen NUM maximum length of an output line" + echo " --linelen=NUM maximum length of an output line" echo " --group-by-day group changelog entries by day" - echo " -r, --include-rev include revision numbers" - echo " -o, --output FILE output to FILE instead of ChangeLog" - echo " -f, --file FILE alias for -o, --output" + echo " -i, --include-rev include revision numbers" + echo " -o, --output=FILE output to FILE instead of ChangeLog" + echo " -f, --file=FILE alias for -o, --output" echo " --stdout output to stdout instead of ChangeLog" + echo " --html output as html instead of plain text" echo " -h, --help display this help and exit" echo " -V, --version output version information and exit" + echo "" + echo "PATH arguments and the following options are passed to the svn log" + echo "command: -r, --revision, --target --stop-on-copy, --username," + echo "--password, --no-auth-cache, --non-interactive, --config-dir," + echo "--limit (see \`svn help log' for more information)." exit 0 ;; - *) + -*) echo "$prog: invalid option -- $1" echo "Try \`$prog --help' for more information." exit 1 ;; + *) + arg=`echo "$1" | sed "s/'/'\"'\"'/g"` + SVNCMD="$SVNCMD '$arg'" + shift + ;; esac done @@ -109,11 +158,19 @@ done prog="$0" while [ -h "$prog" ] do - prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$(dirname "$prog")/,"` + dir=`dirname "$prog"` + prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$dir/,"` done dir=`dirname $prog` dir=`cd $dir && pwd` -XSL="$dir/svn2cl.xsl" +XSL="$dir/svn2${OUTSTYLE}.xsl" + +# if no filename was specified, make one up +if [ -z "$CHANGELOG" ] +then + CHANGELOG="ChangeLog" + [ "$OUTSTYLE" != "cl" ] && CHANGELOG="$CHANGELOG.$OUTSTYLE" +fi # redirect stdout to the changelog file if needed if [ "x$CHANGELOG" != "x-" ] @@ -122,7 +179,7 @@ then fi # actually run the command we need -svn --verbose --xml log | \ +eval "$SVNCMD" | \ xsltproc --stringparam strip-prefix "$STRIPPREFIX" \ --stringparam linelen $LINELEN \ --stringparam groupbyday $GROUPBYDAY \ diff --git a/scripts/svn2cl.xsl b/scripts/svn2cl.xsl index 3672035..e3e5d74 100644 --- a/scripts/svn2cl.xsl +++ b/scripts/svn2cl.xsl @@ -5,7 +5,8 @@ svn2cl.xsl - xslt stylesheet for converting svn log to a normal changelog - Usage (replace ++ with two minus signs): + Usage (replace ++ with two minus signs which aren't allowed + inside xml comments): svn ++verbose ++xml log | \ xsltproc ++stringparam strip-prefix `basename $(pwd)` \ ++stringparam linelen 75 \ @@ -48,27 +49,17 @@ <!DOCTYPE page [ <!ENTITY tab "	"> - <!ENTITY newl " "> + <!ENTITY newl " "> <!ENTITY space " "> ]> -<!-- - TODO - - make external lookups of author names possible - - find a place for revision numbers - - mark deleted files as such - - combine paths - - make path formatting nicer ---> - <xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns="http://www.w3.org/1999/xhtml"> + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" - encoding="iso-8859-15" + encoding="utf-8" media-type="text/plain" omit-xml-declaration="yes" standalone="yes" @@ -97,14 +88,14 @@ <!-- format one entry from the log --> <xsl:template match="logentry"> <!-- save log entry number --> - <xsl:variable name="pos" select="position()"/> + <xsl:variable name="pos" select="position()" /> <!-- fetch previous entry's date --> <xsl:variable name="prevdate"> - <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date"/> + <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" /> </xsl:variable> <!-- fetch previous entry's author --> <xsl:variable name="prevauthor"> - <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author"/> + <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author" /> </xsl:variable> <!-- fetch this entry's date --> <xsl:variable name="date"> @@ -132,20 +123,27 @@ <!-- get paths string --> <xsl:variable name="paths"> <xsl:apply-templates select="paths" /> + <xsl:text>:&space;</xsl:text> </xsl:variable> <!-- get revision number --> <xsl:variable name="rev"> <xsl:if test="$include-rev='yes'"> <xsl:text>[r</xsl:text> - <xsl:value-of select="@revision"/> + <xsl:value-of select="@revision" /> <xsl:text>]&space;</xsl:text> </xsl:if> </xsl:variable> + <!-- trim trailing newlines --> + <xsl:variable name="msg"> + <xsl:call-template name="trim-newln"> + <xsl:with-param name="txt" select="msg" /> + </xsl:call-template> + </xsl:variable> <!-- first line is indented (other indents are done in wrap template) --> <xsl:text>&tab;*&space;</xsl:text> <!-- print the paths and message nicely wrapped --> <xsl:call-template name="wrap"> - <xsl:with-param name="txt" select="concat($rev,$paths,normalize-space(msg))" /> + <xsl:with-param name="txt" select="concat($rev,$paths,$msg)" /> </xsl:call-template> </xsl:template> @@ -175,10 +173,8 @@ <xsl:text>,&space;</xsl:text> </xsl:if> <!-- print the path name --> - <xsl:apply-templates select="."/> + <xsl:apply-templates select="." /> </xsl:for-each> - <!-- end the list with a colon --> - <xsl:text>:&space;</xsl:text> </xsl:template> <!-- transform path to something printable --> @@ -245,6 +241,18 @@ <xsl:template name="wrap"> <xsl:param name="txt" /> <xsl:choose> + <xsl:when test="contains($txt,'
')"> + <!-- text contains newlines, do the first line --> + <xsl:call-template name="wrap"> + <xsl:with-param name="txt" select="substring-before($txt,'
')" /> + </xsl:call-template> + <!-- print tab --> + <xsl:text>&tab;&space;&space;</xsl:text> + <!-- wrap the rest of the text --> + <xsl:call-template name="wrap"> + <xsl:with-param name="txt" select="substring-after($txt,'
')" /> + </xsl:call-template> + </xsl:when> <xsl:when test="(string-length($txt) < (($linelen)-9)) or not(contains($txt,' '))"> <!-- this is easy, nothing to do --> <xsl:value-of select="$txt" /> @@ -271,7 +279,7 @@ <xsl:text>&newl;&tab;&space;&space;</xsl:text> <!-- wrap the rest of the text --> <xsl:call-template name="wrap"> - <xsl:with-param name="txt" select="normalize-space(substring($txt,string-length($line)+1))" /> + <xsl:with-param name="txt" select="substring($txt,string-length($line)+1)" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> @@ -282,7 +290,7 @@ <xsl:param name="txt" /> <xsl:choose> <xsl:when test="substring($txt,string-length($txt),1) = ' '"> - <xsl:value-of select="normalize-space($txt)" /> + <xsl:value-of select="$txt" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="find-line"> @@ -292,4 +300,27 @@ </xsl:choose> </xsl:template> + <!-- template to trim trailing and starting newlines --> + <xsl:template name="trim-newln"> + <xsl:param name="txt" /> + <xsl:choose> + <!-- find starting newlines --> + <xsl:when test="substring($txt,1,1) = '
'"> + <xsl:call-template name="trim-newln"> + <xsl:with-param name="txt" select="substring($txt,2)" /> + </xsl:call-template> + </xsl:when> + <!-- find trailing newlines --> + <xsl:when test="substring($txt,string-length($txt),1) = '
'"> + <xsl:call-template name="trim-newln"> + <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" /> + </xsl:call-template> + </xsl:when> + <!-- no newlines found, we're done --> + <xsl:otherwise> + <xsl:value-of select="$txt" /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + </xsl:stylesheet> |