Patchwork [4,of,9,RFC] statprof: use absolute_imports

mail settings
Submitter Gregory Szorc
Date Aug. 16, 2016, 5:25 a.m.
Message ID <f125cafb95bdc382d3b1.1471325111@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16309/
State Superseded
Headers show


Gregory Szorc - Aug. 16, 2016, 5:25 a.m.
# HG changeset patch
# User Gregory Szorc <>
# Date 1471227303 25200
#      Sun Aug 14 19:15:03 2016 -0700
# Node ID f125cafb95bdc382d3b17b2c2e422b3cf8a08252
# Parent  2828b7bd26694c78c9d6e0bcaa865b93530cc6e6
statprof: use absolute_imports

This entails switching to Mercurial's import convention.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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 time
-from collections import defaultdict
-from contextlib import contextmanager
+import threading
+defaultdict = collections.defaultdict
+contextmanager = contextlib.contextmanager
 __all__ = ['start', 'stop', 'reset', 'display', 'profile']
 skips = set(["", "",
              "", "",
              "<lambda>", "",
              "", "",
              "", "",
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/
   hgext/fsmonitor/pywatchman/ not using absolute_import
   hgext/fsmonitor/pywatchman/ requires print_function
   hgext/fsmonitor/pywatchman/ not using absolute_import
   hgext/fsmonitor/pywatchman/ not using absolute_import
   i18n/ not using absolute_import
-  mercurial/ not using absolute_import
   mercurial/ requires print_function not using absolute_import
   tests/ not using absolute_import
 #if py3exe
   $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/
   doc/ invalid syntax: invalid syntax (<unknown>, line *) (glob)
   hgext/ error importing: <TypeError> str expected, not bytes (error at*) (glob)