# HG changeset patch # User Steve Losh # Date 1247622927 14400 # Node ID 03164fd405bb795f9f0c0fead7f7e7ef4e0f92dc # Parent d7e61ff5ecedca6d359998f57463ac759932440c Add timestamp checking so caching doesn't hammer remote repos. diff -r d7e61ff5eced -r 03164fd405bb prompt.py --- a/prompt.py Tue Jul 14 21:44:16 2009 -0400 +++ b/prompt.py Tue Jul 14 21:55:27 2009 -0400 @@ -11,10 +11,12 @@ import re import os import subprocess +import datetime from os import path from mercurial import extensions, hg, cmdutil CACHE_PATH = ".hg/prompt/cache" +CACHE_TIMEOUT = datetime.timedelta(minutes=10) def _with_groups(g, out): if any(g) and not all(g): @@ -98,11 +100,11 @@ def _incoming(m): g = m.groups() out_g = (g[0],) + (g[-1],) + cache = path.join(repo.root, CACHE_PATH, 'incoming') - cache = path.join(repo.root, CACHE_PATH, 'incoming') - cache_out = cache + '.out' - - subprocess.Popen(['hg', 'prompt', '--cache-incoming']) + c_refreshed = datetime.datetime.fromtimestamp(os.stat(cache).st_mtime) + if c_refreshed < datetime.datetime.now() - CACHE_TIMEOUT: + subprocess.Popen(['hg', 'prompt', '--cache-incoming']) if path.isfile(cache): with open(cache) as c: