From d1ba21803afe2ff55e0f9b0971472fc81ce13cf9 Mon Sep 17 00:00:00 2001 From: Stefan Filip Date: Tue, 7 Apr 2020 14:23:11 -0700 Subject: [PATCH] version: warn users when they are running an old build Summary: Old is defined by being based on a commit that is more than 30 days old. The build date is taken from the version string. One observation is that if we fail to release in more than 30 days then all users will start seeing this message without any way of turning it off. Doesn't seem worth while to add a config for silencing it though. Reviewed By: quark-zju Differential Revision: D20825399 fbshipit-source-id: f97518031bbda5e2c49226f3df634c5b80651c5b --- eden/mononoke/tests/integration/library.sh | 2 ++ eden/scm/edenscm/mercurial/dispatch.py | 3 +++ eden/scm/edenscm/mercurial/hintutil.py | 3 +++ eden/scm/edenscm/mercurial/util.py | 12 ++++++++++++ 4 files changed, 20 insertions(+) diff --git a/eden/mononoke/tests/integration/library.sh b/eden/mononoke/tests/integration/library.sh index 10a1183785..f4b92db41a 100644 --- a/eden/mononoke/tests/integration/library.sh +++ b/eden/mononoke/tests/integration/library.sh @@ -372,6 +372,8 @@ remotefilelog= cachepath=$TESTTMP/cachepath [extensions] commitextras= +[hint] +ack=* EOF } diff --git a/eden/scm/edenscm/mercurial/dispatch.py b/eden/scm/edenscm/mercurial/dispatch.py index 420b21c05f..94f82fdd30 100644 --- a/eden/scm/edenscm/mercurial/dispatch.py +++ b/eden/scm/edenscm/mercurial/dispatch.py @@ -440,6 +440,9 @@ def dispatch(req): ) blackbox.sync() + if util.isoldversion(): + hintutil.trigger("old-version") + # by registering this exit handler here, we guarantee that it runs # after other exithandlers, like the killpager one req.ui.atexit(logatexit) diff --git a/eden/scm/edenscm/mercurial/hintutil.py b/eden/scm/edenscm/mercurial/hintutil.py index 6e27c28623..641d62ad4b 100644 --- a/eden/scm/edenscm/mercurial/hintutil.py +++ b/eden/scm/edenscm/mercurial/hintutil.py @@ -40,6 +40,9 @@ hinttable = { "graph-renderer": lambda: _( "The new graph renderer is in use. See fburl.com/wiki/8zhodl1g for customization and troubleshooting." ), + "old-version": lambda: _( + "WARNING! You are running an old version of Mercurial. Please upgrade your installation." + ), } messages = [] triggered = set() diff --git a/eden/scm/edenscm/mercurial/util.py b/eden/scm/edenscm/mercurial/util.py index 9c472ae54d..73b8d90a94 100644 --- a/eden/scm/edenscm/mercurial/util.py +++ b/eden/scm/edenscm/mercurial/util.py @@ -402,6 +402,18 @@ def version(): return "unknown" +def isoldversion(): + """Returns approximate date information for the current version if available""" + try: + v = version() + parts = remod.split("_", v) + approxbuilddate = datetime.datetime.strptime(parts[1], "%Y%m%d") + now = datetime.datetime.now() + return (now - approxbuilddate).days > 31 + except Exception: + return None + + def versiontuple(v=None, n=4): """Parses a Mercurial version string into an N-tuple.