~ubuntu-branches/ubuntu/wily/installation-guide/wily

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/bash

# This script can be used to update the revision comment in translations
# after an update in an English original. Result is that translators won't
# need to check changes.
# This script is intended only for use by people working on the original
# English text and then only if they know exactly what they are doing!

# The script takes a revision number as argument, looks for English files
# modified in that commit and finds the previous revision of the file.
# It then changes the revision comment for any translation that was
# up-to-date with the previous revision.

[ -d en/ ] || exit 1

if [ "$1" ]; then
	REV="$1"
else
	echo "Usage: unfuzzy-xml <revision>"
	exit 1
fi

cd en/
MODIFIED="$(find . -name "*.xml" | xargs grep "^<.*\$Id:.*$REV" | cut -d: -f1)"
cd ..

for XML in $MODIFIED; do
	PREVREV="$(svn cat -r $(($REV - 1)) en/$XML | grep "^<.*\$Id:" | \
		   sed "s/^.*\.xml \([0-9]*\) .*/\1/")"
	echo "$XML: $PREVREV -> $REV"
	if [ "$PREVREV" ] && [ "$PREVREV" -lt "$REV" ]; then
		sed -i "s/^\(.*original version: \)$PREVREV\(.*\)$/\1$REV\2/" */$XML
	else
		echo "*** Invalid previous revision: '$PREVREV'"
	fi
done