diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -446,8 +446,6 @@ ), (r'^import urlparse', "don't use urlparse, use util.urlreq"), (r'^import xmlrpclib', "don't use xmlrpclib, use util.xmlrpclib"), - (r'^import cPickle', "don't use cPickle, use util.pickle"), - (r'^import pickle', "don't use pickle, use util.pickle"), (r'^import httplib', "don't use httplib, use util.httplib"), (r'^import BaseHTTPServer', "use util.httpserver instead"), ( diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -10,6 +10,7 @@ import datetime import errno import os +import pickle import re import shlex import subprocess @@ -25,7 +26,6 @@ ) from mercurial.utils import procutil -pickle = util.pickle propertycache = util.propertycache diff --git a/hgext/convert/cvsps.py b/hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py +++ b/hgext/convert/cvsps.py @@ -8,6 +8,7 @@ import functools import os +import pickle import re from mercurial.i18n import _ @@ -25,8 +26,6 @@ stringutil, ) -pickle = util.pickle - class logentry(object): """Class logentry has the following attributes: diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -6,6 +6,7 @@ import codecs import locale import os +import pickle import re import xml.dom.minidom @@ -26,7 +27,6 @@ from . import common -pickle = util.pickle stringio = util.stringio propertycache = util.propertycache urlerr = util.urlerr diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -202,6 +202,7 @@ import functools import os +import pickle import struct from mercurial.i18n import _ @@ -245,7 +246,6 @@ urlutil, ) -pickle = util.pickle cmdtable = {} command = registrar.command(cmdtable) diff --git a/mercurial/formatter.py b/mercurial/formatter.py --- a/mercurial/formatter.py +++ b/mercurial/formatter.py @@ -110,6 +110,7 @@ import contextlib import itertools import os +import pickle from .i18n import _ from .node import ( @@ -133,8 +134,6 @@ stringutil, ) -pickle = util.pickle - def isprintable(obj): """Check if the given object can be directly passed in to formatter's diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -76,7 +76,6 @@ cookielib = pycompat.cookielib httplib = pycompat.httplib -pickle = pycompat.pickle safehasattr = pycompat.safehasattr socketserver = pycompat.socketserver bytesio = pycompat.bytesio diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -9,6 +9,7 @@ import errno import os +import pickle import signal import sys import threading @@ -27,7 +28,6 @@ error, pycompat, scmutil, - util, ) @@ -255,7 +255,7 @@ os.close(w) os.close(rfd) for result in func(*(staticargs + (pargs,))): - os.write(wfd, util.pickle.dumps(result)) + os.write(wfd, pickle.dumps(result)) return 0 ret = scmutil.callcatch(ui, workerfunc) @@ -291,7 +291,7 @@ while openpipes > 0: for key, events in selector.select(): try: - res = util.pickle.load(_blockingreader(key.fileobj)) + res = pickle.load(_blockingreader(key.fileobj)) if hasretval and res[0]: retval.update(res[1]) else: diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -316,8 +316,8 @@ $ hg status -A -Tpickle > pickle >>> from __future__ import print_function + >>> import pickle >>> from mercurial import util - >>> pickle = util.pickle >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb"))) >>> for s, p in data: print("%s %s" % (s, p)) ! deleted diff --git a/tests/test-stdio.py b/tests/test-stdio.py --- a/tests/test-stdio.py +++ b/tests/test-stdio.py @@ -7,6 +7,7 @@ import contextlib import errno import os +import pickle import signal import subprocess import sys @@ -335,7 +336,7 @@ proc.stdin.close() def post_child_check(): - err = util.pickle.load(err_f) + err = pickle.load(err_f) self.assertEqual(err.errno, errno.EPIPE) self.assertEqual(err.strerror, "Broken pipe")