[PATCH 04 of 10 V2] statprof: use absolute_imports

Gregory Szorc gregory.szorc at gmail.com
Wed Aug 17 12:03:42 EDT 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1471448311 25200
#      Wed Aug 17 08:38:31 2016 -0700
# Node ID 289db60b052ad08ba2b9850937025654d7b8ded4
# Parent  2828b7bd26694c78c9d6e0bcaa865b93530cc6e6
statprof: use absolute_imports

This entails switching to Mercurial's import convention.

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -97,22 +97,32 @@ Threading
 
 Because signals only get delivered to the main thread in Python,
 statprof only profiles the main thread. However because the time
 reporting function uses per-process timers, the results can be
 significantly off if other threads' work patterns are not similar to the
 main thread's work patterns.
 """
 # no-check-code
-from __future__ import division
+from __future__ import absolute_import, division
 
-import inspect, json, os, signal, tempfile, sys, getopt, threading
+import collections
+import contextlib
+import getopt
+import inspect
+import json
+import os
+import signal
+import sys
+import tempfile
+import threading
 import time
-from collections import defaultdict
-from contextlib import contextmanager
+
+defaultdict = collections.defaultdict
+contextmanager = contextlib.contextmanager
 
 __all__ = ['start', 'stop', 'reset', 'display', 'profile']
 
 skips = set(["util.py:check", "extensions.py:closure",
              "color.py:colorcmd", "dispatch.py:checkargs",
              "dispatch.py:<lambda>", "dispatch.py:_runcatch",
              "dispatch.py:_dispatch", "dispatch.py:_runcommand",
              "pager.py:pagecmd", "dispatch.py:run",
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -4,17 +4,16 @@
   $ cd "$TESTDIR"/..
 
   $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
   hgext/fsmonitor/pywatchman/__init__.py not using absolute_import
   hgext/fsmonitor/pywatchman/__init__.py requires print_function
   hgext/fsmonitor/pywatchman/capabilities.py not using absolute_import
   hgext/fsmonitor/pywatchman/pybser.py not using absolute_import
   i18n/check-translation.py not using absolute_import
-  mercurial/statprof.py not using absolute_import
   mercurial/statprof.py requires print_function
   setup.py not using absolute_import
   tests/test-demandimport.py not using absolute_import
 
 #if py3exe
   $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py
   doc/hgmanpage.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   hgext/acl.py: error importing: <TypeError> str expected, not bytes (error at encoding.py:*) (glob)


More information about the Mercurial-devel mailing list