| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
|
| 3 | 3 |
YEAR=`date +%Y` |
| 4 | 4 |
HGROOT=`hg root` |
| 5 | 5 |
|
| 6 | 6 |
function hg_year() {
|
| 7 | 7 |
if [ -n "$(hg st $1)" ]; then |
| 8 | 8 |
echo $YEAR |
| 9 |
else |
|
| 10 |
hg log -l 1 --template='{date|isodate}\n' $1 |
|
|
| 11 |
cut -d '-' -f 1 |
|
| 12 |
fi |
|
| 9 | 13 |
} |
| 10 | 14 |
|
| 11 | 15 |
# file enumaration modes |
| 12 | 16 |
|
| 13 | 17 |
function all_files() {
|
| 14 | 18 |
hg status -a -m -c | |
| 15 | 19 |
cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | |
| 16 | 20 |
while read file; do echo $HGROOT/$file; done |
| 17 | 21 |
} |
| 18 | 22 |
|
| 19 | 23 |
function modified_files() {
|
| 20 | 24 |
hg status -a -m | |
| 21 | 25 |
cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | |
| 22 | 26 |
while read file; do echo $HGROOT/$file; done |
| 23 | 27 |
} |
| 24 | 28 |
|
| 25 | 29 |
function changed_files() {
|
| 26 | 30 |
{
|
| 27 | 31 |
if [ -n "$HG_PARENT1" ] |
| 28 | 32 |
then |
| 29 | 33 |
hg status --rev $HG_PARENT1:$HG_NODE -a -m |
| 30 | 34 |
fi |
| 31 | 35 |
if [ -n "$HG_PARENT2" ] |
| 32 | 36 |
then |
| 33 | 37 |
hg status --rev $HG_PARENT2:$HG_NODE -a -m |
| 34 | 38 |
fi |
| 35 | 39 |
} | cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | |
| 36 | 40 |
sort | uniq | |
| 37 | 41 |
while read file; do echo $HGROOT/$file; done |
| 38 | 42 |
} |
| 39 | 43 |
|
| 40 | 44 |
function given_files() {
|
| 41 | 45 |
for file in $GIVEN_FILES |
| 42 | 46 |
do |
| 43 | 47 |
echo $file |
| 44 | 48 |
done |
| 45 | 49 |
} |
| 46 | 50 |
|
| 47 | 51 |
# actions |
| 48 | 52 |
|
| 49 | 53 |
function update_action() {
|
| 50 | 54 |
if ! diff -q $1 $2 >/dev/null |
| 51 | 55 |
then |
| 52 | 56 |
echo -n " [$3 updated]" |
| 53 | 57 |
rm $2 |
| 54 | 58 |
mv $1 $2 |
| 55 | 59 |
CHANGED=YES |
| 56 | 60 |
fi |
0 comments (0 inline)