I want to create a script that will do something if hg incoming -v
contains specific file.
Say if hg incoming -v | grep models.py > 0
than do ./manage.py resetdb
. Something like this.
hg incoming -v | grep manage.py
result?if hg incoming -v | grep -q 'models\.py'; then
./manage.py resetdb
fi
However, this seems fragile: it matches when models.py is present in other output than files (such as description) and won't work when you modify models.py locally. You can set a variable within the above to control later actions, if that's what you meant by "set a flag."
count=`hg incoming -v | grep -c 'models\.py'`
if test $count -gt 0; then
./manage.py resetdb
fi
精彩评论