changeset 141:13435b80c672

Replace c09729100dd2 with a wrapper hook implementation
author IBBoard <dev@ibboard.co.uk>
date Sat, 18 Jan 2020 21:01:23 +0000
parents f5dd593cc018
children 503a7a8df2e2
files prompt.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/prompt.py	Sat Jan 18 20:54:13 2020 +0000
+++ b/prompt.py	Sat Jan 18 21:01:23 2020 +0000
@@ -283,8 +283,7 @@
 
             cache_time = (datetime.fromtimestamp(os.stat(cache).st_mtime)
                           if cache_exists else None)
-            if not cache_exists or cache_time < datetime.now() - CACHE_TIMEOUT \
-                or (kind == b'outgoing' and cache_time < datetime.fromtimestamp(os.stat('.hg/last-message.txt').st_mtime)):
+            if not cache_exists or cache_time < datetime.now() - CACHE_TIMEOUT:
                 if not cache_exists:
                     open(cache, 'w').close()
                 subprocess.Popen(['hg', 'prompt', '--cache-%s' % kind.decode('ascii')])
@@ -450,6 +449,14 @@
 
     ui.status(fs)
 
+def _commit_with_cache(orig, ui, repo, *args, **opts):
+    """Wrap the commit command to fake an entry until we re-cache"""
+    res = orig(ui, repo, *args, **opts)
+    cache = path.join(repo.root, CACHE_PATH, b'outgoing')
+    if path.isfile(cache):
+        with open(cache, 'a') as cache_file:
+            cache_file.write('Local Commit\n')
+
 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)
@@ -467,6 +474,7 @@
     return res
 
 def uisetup(ui):
+    extensions.wrapcommand(commands.table, b'commit', _commit_with_cache)
     extensions.wrapcommand(commands.table, b'pull', _pull_with_cache)
     extensions.wrapcommand(commands.table, b'push', _push_with_cache)
     try: