# HG changeset patch # User Saurabh Singh # Date 1507238335 25200 # Node ID b521b3a79afd63047f0e30491602389d5c98e65f # Parent 30ae924a9e0005b4af48baaf90bfc37a23a14744 test-check-code: fail new commits which use 'atexit' instead of 'ui.atexit' Callbacks registered with 'atexit' are sometimes not called (like when hg aborts and calls os._exit). On the other hand, callbacks registered with 'ui.atexit' are called in most cases. Therefore, encouraging the use of 'ui.atexit' by failing the test 'test-check-code.t' appropriately. Test Plan: Ran the test 'test-check-code.t' after importing 'atexit' in one of the py files and confirmed that the test fails. Differential Revision: https://phab.mercurial-scm.org/D961 diff -r 30ae924a9e00 -r b521b3a79afd contrib/check-code.py --- a/contrib/check-code.py Thu Oct 05 20:46:49 2017 +0000 +++ b/contrib/check-code.py Thu Oct 05 14:18:55 2017 -0700 @@ -345,6 +345,7 @@ (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"), (r'\butil\.Abort\b', "directly use error.Abort"), (r'^@(\w*\.)?cachefunc', "module-level @cachefunc is risky, please avoid"), + (r'^import atexit', "don't use atexit, use ui.atexit"), (r'^import Queue', "don't use Queue, use util.queue + util.empty"), (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"), (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"),