# HG changeset patch # User IBBoard # Date 1699779852 0 # Node ID 912d1c33382f73a3d4548e9d4b38edc3b86167ed # Parent 961186621cc897f1912f410ec40934aede0e827d Handle missing files in Mercurial state check diff -r 961186621cc8 -r 912d1c33382f bashrc --- a/bashrc Sat Nov 11 20:29:16 2023 +0000 +++ b/bashrc Sun Nov 12 09:04:12 2023 +0000 @@ -72,12 +72,12 @@ HG_MODIFIED=$([ "$(rhg status -mard | head -c1)" ] && echo " *") HG_INCOMING_PATH="${HG_ROOT}"/.hg/prompt/cache/incoming HG_OUTGOING_PATH="${HG_ROOT}"/.hg/prompt/cache/outgoing - if [[ $(($(date +%s) - $(date -r "${HG_INCOMING_PATH}" +%s 2>/dev/null) )) -gt $HG_CACHE_TIMEOUT ]]; then + if [[ ! -f "${HG_INCOMING_PATH}" || $(($(date +%s) - $(date -r "${HG_INCOMING_PATH}" +%s 2>/dev/null || echo 0) )) -gt $HG_CACHE_TIMEOUT ]]; then hg incoming --quiet --config ui.interactive=False > "$HG_INCOMING_PATH" hg outgoing --quiet --config ui.interactive=False > "$HG_OUTGOING_PATH" fi - HG_IN=$(wc -l < "$HG_INCOMING_PATH") - HG_OUT=$(wc -l < "$HG_OUTGOING_PATH") + HG_IN=$([ -f "${HG_INCOMING_PATH}" ] && wc -l < "$HG_INCOMING_PATH" 2>/dev/null || echo 0) + HG_OUT=$([ -f "${HG_OUTGOING_PATH}" ] && wc -l < "$HG_OUTGOING_PATH" 2>/dev/null || echo 0) if [[ $HG_IN = "0" && $HG_OUT = "0" ]]; then HG_INOUT=" u=" else