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

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


Gregory Szorc - Aug. 17, 2016, 4:03 p.m.
# HG changeset patch
# User Gregory Szorc <>
# 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/ 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 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(["", "",
              "", "",
              "<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)