diff options
author | Jonas Smedegaard <dr@jones.dk> | 2006-07-27 22:32:54 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2006-07-27 22:32:54 +0000 |
commit | d621aa3802b4c34dbf7a224cedac84dab0b929e1 (patch) | |
tree | fc30718e550f8a1b4614aaaf5a75d4158362239e | |
parent | b1e8a8c90d91f357958bfc9f9427971e734e9418 (diff) |
Add Version control system scripts.
-rwxr-xr-x | localsvnlog2cl | 84 | ||||
-rwxr-xr-x | localvcsactions | 112 | ||||
-rwxr-xr-x | xmc | 2 |
3 files changed, 197 insertions, 1 deletions
diff --git a/localsvnlog2cl b/localsvnlog2cl new file mode 100755 index 0000000..bf4ff44 --- /dev/null +++ b/localsvnlog2cl @@ -0,0 +1,84 @@ +#!/usr/bin/perl -w + +# Origin: /usr/share/doc/subversion/examples/gnuify-changelog.pl.gz + +# a script to munge the output of 'svn log' into something approaching the +# style of a GNU ChangeLog. +# +# to use this, just fill in the 'hackers' hash with the usernames and +# name/emails of the people who work on your project, go to the top level +# of your working copy, and run: +# +# $ svn log | /path/to/gnuify-changelog.pl > ChangeLog + +require 5.0; +use strict; + +my %hackers = ( +# "jonas" => 'Jonas Smedegaard <dr@jones.dk>', +); + +my $parse_next_line = 0; +my $last_line_empty = 0; +my $last_rev = ""; + +while (my $entry = <>) { + + # Axe windows style line endings, since we should try to be consistent, and + # the repos has both styles in its log entries + $entry =~ s/\r\n$/\n/; + + # Remove trailing whitespace + $entry =~ s/\s+$/\n/; + + my $this_line_empty = $entry eq "\n"; + + # Avoid duplicate empty lines + next if $this_line_empty and $last_line_empty; + + # Don't fail on valid dash-only lines + if ($entry =~ /^-+$/ and length($entry) >= 72) { + + # We're at the start of a log entry, so we need to parse the next line + $parse_next_line = 1; + + # Check to see if the final line of the commit message was blank, + # if not insert one + print "\n" if $last_rev ne "" and !$last_line_empty; + + } elsif ($parse_next_line) { + + # Transform from svn style to GNU style + $parse_next_line = 0; + + my @parts = split (/ /, $entry); + $last_rev = $parts[0]; + my $hacker = $parts[2]; + my $tstamp = $parts[4]; + + # Use alias if we can't resolve to name, email + $hacker = $hackers{$hacker} if defined $hackers{$hacker}; + + printf "%s %s\n", $tstamp, $hacker; + + } elsif ($this_line_empty) { + + print "\n"; + + } else { + + print "\t$entry"; + + } + + $last_line_empty = $this_line_empty; +} + +# As a HERE doc so it also sets the final changelog's coding +print <<LOCAL; +;; Local Variables: +;; coding: utf-8 +;; End: +LOCAL + +1; diff --git a/localvcsactions b/localvcsactions new file mode 100755 index 0000000..7352c3d --- /dev/null +++ b/localvcsactions @@ -0,0 +1,112 @@ +#!/bin/sh + +set -e + +action=$(basename $0 .sh) + +tar_excludes="--exclude CVSROOT --exclude .cvsignore --exclude .svn --exclude .arch-ids --exclude {arch} --exclude .hg --exclude .hgignore --exclude .hgtags" + +projects=${1:-$(find -mindepth 1 -maxdepth 1 -type d -printf '%f\n')} +for project in $projects; do + if [ -x $project/$action.sh ]; then + echo " ** Custom updating project $project... **" + (cd $project && ./$action.sh) + else + targets=${2:-$(find $project -mindepth 1 -maxdepth 1 -type d -printf '%f\n')} + for target in $targets; do + repository="" + branch="" + if [ -d "$project/$target/.hg" ]; then + versys="Mercurial" + versysfile="hg" + repository="$(cat $project/$target/.hg/hgrc | perl -n -e '/^default\s+=\s+(\S+)/ && print "$1\n"')" + elif [ -d "$project/$target/{arch}" ]; then + versys="ARCH" + versysfile="arch" + repository="$(cat $project/$target/{arch}/++default-version)" + elif [ -d "$project/$target/.svn" ]; then + versys="SVN" + versysfile="svn" + elif [ -d "$project/$target/CVS" ]; then + versys="CVS" + versysfile="cvs" + repository="$(cat $project/$target/CVS/Repository)" + # Get Tag if available + if [ -f $project/$target/CVS/Tag ]; then + branch="$(egrep '^N' $project/$target/CVS/Tag | sed 's/^N//')" + fi + else + echo "ERROR: Unknown version control system used for \"$project/$target\"." + exit 1 + fi + case $action in + update) + echo " ** Updating $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}" + case $versys in + CVS) + ( cd $project/$target && cvs -z3 update -dP 2>&1 || exit 1 ) \ + | egrep -v '^cvs(pserver)? (server|update): Updating' || [ $? -lt 2 ] # catch grep failures + ;; + SVN) + ( cd $project/$target && svn update ) + ;; + ARCH) + ( cd $project/$target && tla update ) + ;; + Mercurial) + ( cd $project/$target && hg pull -u ) + ;; + *) + echo "ERROR: Action \"$action\" not supported for \"$project/$target\"." + exit 1 + ;; + esac + ;; + archive) + echo " ** Creating snapshot of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}" + case $versys in + CVS|SVN|ARCH|Mercurial) + ( cd $project && tar chf - --exclude CVS $tar_excludes $target ) \ + | gzip -f9 > $project/$target-$versysfile$(date '+%Y%m%d').tar.gz + ;; + *) + echo "ERROR: Action \"$action\" not supported for \"$project/$target\"." + exit 1 + ;; + esac + ;; + mkchanges) + echo " ** Building changelog of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}" + case $versys in + CVS) +# ( cd $project/$target && cvs2cl --gmt -S --no-wrap -f ../$target.ChangeLog 2>&1 || exit 1 ) \ +# ( cd $project/$target && cvs2cl --gmt -S --no-wrap ${branch:+-F $branch} -f ../$target.ChangeLog 2>&1 || exit 1 ) \ + ( cd $project/$target && cvs2cl --gmt -S --no-wrap -F ${branch:-TRUNK} -f ../$target.ChangeLog 2>&1 || exit 1 ) \ + | egrep -v '^cvs(pserver)? (server|log): Logging' || [ $? -lt 2 ] # catch grep failures + ;; + SVN) + ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak ) + ( cd $project/$target && svn log -v | localsvnlog2cl > ../$target.ChangeLog ) + ;; + ARCH) + ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak ) + ( cd $project/$target && tla changelog > ../$target.ChangeLog ) + ;; + Mercurial) + ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak ) + ( cd $project/$target && hg log -v > ../$target.ChangeLog ) + ;; + *) + echo "ERROR: Action \"$action\" not supported for \"$project/$target\"." + exit 1 + ;; + esac + ;; + *) + echo "ERROR: Unknown action \"$action\" for \"$project/$target\"." + exit 1 + ;; + esac + done + fi +done @@ -1,7 +1,7 @@ #!/bin/bash # danish locale is broken - see http://bugs.debian.org/181027 -export LC_ALL=C +#export LC_ALL=C if [ $# -eq 0 ]; then xsh localhost mc |