Patchwork [04,of,10,V2] statprof: use absolute_imports

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 17, 2016, 4:03 p.m.
Message ID <289db60b052ad08ba2b9.1471449822@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16330/
State Changes Requested
Headers show

Comments

Gregory Szorc - Aug. 17, 2016, 4:03 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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)