D961: test-check-code: fail new commits which use 'atexit' instead of 'ui.atexit'

singhsrb (Saurabh Singh) phabricator at mercurial-scm.org
Thu Oct 5 21:20:28 UTC 2017


singhsrb created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D961

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -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"),



To: singhsrb, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list