cut -d
' ' -f 2 | grep -E
'(\.(cc|h|dox)$|Makefile\.am$)' |
while read file;
do echo $HGROOT/
$file;
done
function modified_files
() {
cut -d
' ' -f 2 | grep -E
'(\.(cc|h|dox)$|Makefile\.am$)' |
while read file;
do echo $HGROOT/
$file;
done
function changed_files
() {
hg status --rev
$HG_PARENT1:
$HG_NODE -a -m
hg status --rev
$HG_PARENT2:
$HG_NODE -a -m
} | cut -d
' ' -f 2 | grep -E
'(\.(cc|h|dox)$|Makefile\.am$)' |
while read file;
do echo $HGROOT/
$file;
done
function update_action
() {
if ! diff -q
$1 $2 >/dev/null
function update_warning
() {
echo Update
source files...
echo $CHANGED_FILES out of
$TOTAL_FILES files has been changed.
echo $WARNED_FILES out of
$TOTAL_FILES files has been warned.
function update_begin
() {
function check_action
() {
if ! diff -q
$1 $2 >/dev/null
function check_warning
() {
echo Check
source files...
echo $FAILED_FILES out of
$TOTAL_FILES files has been failed.
echo $WARNED_FILES out of
$TOTAL_FILES files has been warned.
if [ $FAILED_FILES -gt 0
]
elif [ $WARNED_FILES -gt 0
]
if [ "$WARNING" == 'INTERACTIVE' ]
echo -n
"Assume as normal behaviour? (yes/no) "
if [ "$answer" == 'yes' ]
elif [ "$answer" == 'no' ]
echo -n
"Assume as normal behaviour? (yes/no) "
elif [ "$WARNING" == 'WERROR' ]
function header_check
() {
if echo $1 | grep -q -E
'Makefile\.am$'
(echo "/* -*- mode: C++; indent-tabs-mode: nil; -*-
* This file is a part of LEMON, a generic C++ optimization library.
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
* This software is provided \"AS IS\" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
/\/\* / && pm==0 { pm=1;}
/[^:blank:]/ && (pm==0 || pm==2) { pm=3; print;}
"$ACTION"_action
"$TMP_FILE" "$1" header
if echo $1 | grep -q -v -E
'Makefile\.am$'
OLD_PATTERN=$(echo -e
'\t')
NEW_PATTERN=$(echo -e
'\t')
cat
$1 | sed -e
"s/$OLD_PATTERN/$NEW_PATTERN/g" >
$TMP_FILE
"$ACTION"_action
"$TMP_FILE" "$1" 'tabs'
function spaces_check
() {
cat
$1 | sed -e
's/ \+$//g' >
$TMP_FILE
"$ACTION"_action
"$TMP_FILE" "$1" 'spaces'
function long_lines_check
() {
if cat
$1 | grep -q -E
'.{81,}'
"$ACTION"_warning
$1 'long lines'
function process_file
() {
echo -n
" $ACTION " $1...
CHECKING="header tabs spaces long_lines"
if [ "$1" == '--help' ] || [ "$1" == '-h' ]
Check the given files, but do not modify them.
If --dry-run is specified and files are warned then a message is
prompted whether the warnings should be turned to errors.
If --dry-run is specified and the warnings are turned to errors.
All files in the repository will be checked.
Check only the modified source files. This option is proper to
use before a commit. E.g. all files which are modified or added
into the repository will be updated.
Check only the changed source files compared to the parent(s) of
the current hg node. This option is proper to use as hg hook
script. E.g. to check all your commited source files with this
script add the following section to the appropriate .hg/hgrc
pretxncommit.checksources = scripts/unify-sources.sh -c -n -i
The files to check/unify. If no file names are given, the
modified source will be checked/unified
elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ]
[ -n
"$ACTION" ] && echo "Invalid option $1" >&2
&& exit 1
elif [ "$1" == "--all" ] || [ "$1" == '-a' ]
[ -n
"$FILES" ] && echo "Invalid option $1" >&2
&& exit 1
elif [ "$1" == "--changed" ] || [ "$1" == '-c' ]
[ -n
"$FILES" ] && echo "Invalid option $1" >&2
&& exit 1
elif [ "$1" == "--modified" ] || [ "$1" == '-m' ]
[ -n
"$FILES" ] && echo "Invalid option $1" >&2
&& exit 1
elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ]
[ -n
"$WARNING" ] && echo "Invalid option $1" >&2
&& exit 1
elif [ "$1" == "--werror" ] || [ "$1" == "-w" ]
[ -n
"$WARNING" ] && echo "Invalid option $1" >&2
&& exit 1
elif [ $(echo $1 | cut -c 1
) == '-' ]
echo "Invalid option $1" >&2
&& exit 1
[ -n
"$FILES" ] && echo "Invalid option $1" >&2
&& exit 1