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
This commit is contained in:
Stefan Filip 2020-04-07 14:23:11 -07:00 committed by Facebook GitHub Bot
parent 170dc08976
commit d1ba21803a
4 changed files with 20 additions and 0 deletions

View File

@ -372,6 +372,8 @@ remotefilelog=
cachepath=$TESTTMP/cachepath
[extensions]
commitextras=
[hint]
ack=*
EOF
}

View File

@ -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)

View File

@ -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()

View File

@ -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.