# HG changeset patch # User Steve Losh # Date 1249739362 14400 # Node ID a1aca2ec2e5b02ec9f614fa24933493f1ba64be1 # Parent 7320aadbcca6ed9db1aec05c0ad9ca29937971ab Wrap push and pull to delete the prompt caches. diff -r 7320aadbcca6 -r a1aca2ec2e5b prompt.py --- a/prompt.py Sat Jul 25 12:03:15 2009 -0400 +++ b/prompt.py Sat Aug 08 09:49:22 2009 -0400 @@ -15,7 +15,7 @@ import subprocess from datetime import datetime, timedelta from os import path -from mercurial import extensions +from mercurial import extensions, commands from mercurial.node import hex, short CACHE_PATH = ".hg/prompt/cache" @@ -222,6 +222,26 @@ fs = re.sub(tag_start + tag + tag_end, repl, fs) ui.status(fs) +def _pull_with_cache(orig, ui, repo, *args, **opts): + """Wrap the pull command to delete the incoming cache as well.""" + res = orig(ui, repo, *args, **opts) + cache = path.join(repo.root, CACHE_PATH, 'incoming') + if path.isfile(cache): + os.remove(cache) + return res + +def _push_with_cache(orig, ui, repo, *args, **opts): + """Wrap the push command to delete the outgoing cache as well.""" + res = orig(ui, repo, *args, **opts) + cache = path.join(repo.root, CACHE_PATH, 'outgoing') + if path.isfile(cache): + os.remove(cache) + return res + +def uisetup(ui): + extensions.wrapcommand(commands.table, 'pull', _pull_with_cache) + extensions.wrapcommand(commands.table, 'push', _push_with_cache) + cmdtable = { "prompt": (prompt, [ @@ -229,4 +249,4 @@ ('', 'cache-outgoing', None, 'used internally by hg-prompt'), ], 'hg prompt STRING') -} +} \ No newline at end of file