sapling/inhibitwarn.py
Laurent Charignon 37e7425cfa inhibitwarn: improve the warning message
Summary:
We had some complain about the warning message, this is a rework of
the wording to make it clearer. The diff is not complete until we have the
link for the Source Control FYI post coming this morning.

Test Plan: N/A

Reviewers: pyd, durham

Differential Revision: https://phabricator.fb.com/D2315002
2015-08-05 10:42:58 -07:00

73 lines
3.6 KiB
Python

# inhibitwarn.py - Warn beta evolve users of the new inhibit extension
#
# Copyright 2015 Facebook, Inc.
#
# As we are rolling out inhibit, our evolve beta testers have to change their
# config to keep using evolve unhinibitted as before. The goal of this extension
# is to warn these users about inhibit and tell them how to deactivate it.
#
# To know who those users are we check the date of oldest obsolescence marker.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from mercurial import extensions
from mercurial import localrepo
import datetime
defaultmsg = """
+------------------------------------------------------------------------------+
|You seems to be a beta user of Changeset Evolution |
|https://fb.facebook.com/groups/630370820344870/ |
| |
|We just rolled out a major change to our mercurial |
|https://fb.facebook.com/groups/scm.fyi/permalink/711128702353004/ |
| |
|The rollout contains a lightweight version of Evolution that break your usual |
|workflow using the "hg evolve" commands: |
| https://fb.facebook.com/groups/630370820344870/permalink/907861022595847/ |
| |
|If you want to keep using evolve run `hg config -e` and add this to your |
|config: |
|[extensions] |
|inhibit=! |
|directaccess=! |
|[experimental] |
|evolution=all |
| |
|If you have no recollection of using evolution or stopped using it. run |
|`hg config -e` and add this to your config: |
|[inhibit] |
|bypass-warning=True |
+------------------------------------------------------------------------------+
"""
# Wether the warning message has been displayed already
state = {'displayed': False}
def reposetup(ui, repo):
# No need to check anything if inhibit is not enabled
try:
if not extensions.find('inhibit'):
return
except KeyError:
return
bypass = repo.ui.configbool('inhibit', 'bypass-warning', False)
if bypass:
return
cutoffdate = repo.ui.config('inhibit', 'cutoff') or '2015-05-18'
cutofftime = int(datetime.datetime.strptime(cutoffdate,
'%Y-%m-%d').strftime("%s"))
if repo.local():
for marker in repo.obsstore._all:
timestamp = marker[4][0]
if timestamp < cutofftime and not state['displayed']:
state['displayed'] = True
configmsg = ui.config('inhibitwarn', 'education')
if configmsg:
ui.write_err(configmsg + "\n")
else:
ui.write_err(defaultmsg)
# Only the first marker is checked as they are ordered chronologically
break