D12217: merge: remove direct rustmod reference
Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We shouldn't rely on this member being present in `dirstate.py`, this creates unnecessary coupling. This also can trigger certain issues in edge-cases where the policy is changed at runtime or multiple Python environments fight, which is an added bonus. REPOSITORY rHG Mercurial BRANCH stable REVISION DETAIL https://phab.mercurial-scm.org/D12217 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -25,6 +25,7 @@ mergestate as mergestatemod, obsutil, pathutil, +policy, pycompat, scmutil, subrepoutil, @@ -1764,9 +1765,9 @@ b'fsmonitor', b'warn_update_file_count' ) # avoid cycle dirstate -> sparse -> merge -> dirstate -from . import dirstate +dirstate_rustmod = policy.importrust("dirstate") -if dirstate.rustmod is not None: +if dirstate_rustmod is not None: # When using rust status, fsmonitor becomes necessary at higher sizes fsmonitorthreshold = repo.ui.configint( b'fsmonitor', To: Alphare, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: pycompat.py strategy
On 2/22/22 23:06, Joerg Sonnenberger wrote: Am Mon, Feb 21, 2022 at 11:47:36AM -0700 schrieb Gregory Szorc: Some options: a) Attempt to delete as much as pycompat.py as possible (leaving only the pieces needed to abstract over differences in Python 3.5-3.x). b) Leave the ~complete API provided by pycompat.py and delete pycompat usage within the repo as much as possible. c) Leave the ~complete API provided by pycompat.py and still use pycompat heavily within the repo. Personally, I'd prefer to start with (c) and gradually go to (b). Care to elaborate? :) Joerg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: pycompat.py strategy
Am Tue, Mar 01, 2022 at 11:20:41AM +0100 schrieb Raphaël Gomès: > > On 2/22/22 23:06, Joerg Sonnenberger wrote: > > Am Mon, Feb 21, 2022 at 11:47:36AM -0700 schrieb Gregory Szorc: > > > Some options: > > > > > > a) Attempt to delete as much as pycompat.py as possible (leaving only the > > > pieces needed to abstract over differences in Python 3.5-3.x). > > > b) Leave the ~complete API provided by pycompat.py and delete pycompat > > > usage within the repo as much as possible. > > > c) Leave the ~complete API provided by pycompat.py and still use pycompat > > > heavily within the repo. > > Personally, I'd prefer to start with (c) and gradually go to (b). > Care to elaborate? :) We can start just nuking the non-py3 case in pycompat and then slowly inline it in the rest of the tree. Ideally using a tool for the mechnical part of it. Joerg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@48808: 6 new changesets (5 on stable)
6 new changesets (5 on stable) in mercurial: https://www.mercurial-scm.org/repo/hg/rev/60950aef856c changeset: 48803:60950aef856c branch: stable user:Raphaël Gomès date:Fri Feb 18 13:14:32 2022 +0100 summary: relnotes: add 6.0.3 https://www.mercurial-scm.org/repo/hg/rev/f0081a551f37 changeset: 48804:f0081a551f37 branch: stable user:Raphaël Gomès date:Mon Feb 21 11:22:40 2022 +0100 summary: relnotes: add 6.1 https://www.mercurial-scm.org/repo/hg/rev/d4486810a179 changeset: 48805:d4486810a179 branch: stable tag: 6.1 user:Raphaël Gomès date:Mon Feb 28 18:34:23 2022 +0100 summary: merge: remove direct rustmod reference https://www.mercurial-scm.org/repo/hg/rev/f97778b53b66 changeset: 48806:f97778b53b66 branch: stable user:Raphaël Gomès date:Tue Mar 01 16:39:06 2022 +0100 summary: Added tag 6.1 for changeset d4486810a179 https://www.mercurial-scm.org/repo/hg/rev/1ceca11e6546 changeset: 48807:1ceca11e6546 branch: stable user:Raphaël Gomès date:Tue Mar 01 16:39:14 2022 +0100 summary: Added signature for changeset d4486810a179 https://www.mercurial-scm.org/repo/hg/rev/db023e33b652 changeset: 48808:db023e33b652 bookmark:@ tag: tip parent: 48799:f835f6a4ee9a parent: 48807:1ceca11e6546 user:Raphaël Gomès date:Tue Mar 01 16:44:59 2022 +0100 summary: branching: merge stable into default -- Repository URL: https://www.mercurial-scm.org/repo/hg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: Python 3.x version support / dropping 3.5 and 3.6
On 2/27/22 22:19, Gregory Szorc wrote: 6.1 will be the last release to support Python 2.7. That means 6.2 will be Python 3 only. Currently our Python 3 support is for 3.5-3.10. Python 3.5 dropped out of support in September 2020 and Python 3.6 in December 2021 (https://endoflife.date/python). Do we have any interest in dropping support for 3.5 or 3.6 in the 6.2 release? Features of interest in 3.6: * Variable type annotations. (Annotating on <3.6 requires special syntax in comments) * Stabilization of async (unsure how much we'll adopt async though) * PEP 519 path protocol. This might enable us to clean up path handling throughout the codebase by adopting richly typed path objects with nice path-like primitives. * Enhancements to typing module to make it more useful. Features of interest in 3.7: * Postponed evaluation of type annotations (this is likely huge for managing startup time) * importlib.resources (allows us to clean up non-module file loading) * @dataclass and data classes I think the only in-support major distro still supporting 3.5 is Debian 9 Stretch, which goes out of support on 2022-06-30. 3.6 is more complicated. CentOS/RHEL 7 and Ubuntu 18.04 ship Python 3.6. Although the former is already out of support. Ubuntu 18.04 is still in main support until 2023-04-03 and has security support for another few years. My pulse on the larger Python ecosystem is that 3.5 is mostly dead and 3.6 is starting to wilt but not quite dead. Tons of projects dropped 3.5 in the past year. **So I'd like to propose dropping support for Python 3.5 in 6.2.** That would mean 6.1 is our last release with both Python 2.7 and 3.5 support. Agreed, I think this is cautious enough. I don't think I can in good faith recommend dropping 3.6 support at this time since it is still in wide use. But I do like the allure of the above highlighted features in 3.7 and think they could lead to a higher quality Mercurial and cleaner code base. If anyone else wants to make the case for dropping 3.6 despite its apparent use in supported distros, I'd love to hear it. +1 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12219: automation: upgrade black to 22.1.0
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We just reformatted the repo with black 22.1.0. Let's install this version of black in the Linux automation. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12219 AFFECTED FILES contrib/automation/linux-requirements-py3.txt contrib/automation/linux-requirements.txt.in CHANGE DETAILS diff --git a/contrib/automation/linux-requirements.txt.in b/contrib/automation/linux-requirements.txt.in --- a/contrib/automation/linux-requirements.txt.in +++ b/contrib/automation/linux-requirements.txt.in @@ -1,5 +1,5 @@ # black pulls in typed-ast, which doesn't install on PyPy. -black==19.10b0 ; python_version >= '3.6' and platform_python_implementation != 'PyPy' +black==22.1.0 ; python_version >= '3.6' and platform_python_implementation != 'PyPy' # Bazaar doesn't work with Python 3 nor PyPy. bzr ; python_version <= '2.7' and platform_python_implementation == 'CPython' docutils diff --git a/contrib/automation/linux-requirements-py3.txt b/contrib/automation/linux-requirements-py3.txt --- a/contrib/automation/linux-requirements-py3.txt +++ b/contrib/automation/linux-requirements-py3.txt @@ -1,28 +1,41 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # #pip-compile --generate-hashes --output-file=contrib/automation/linux-requirements-py3.txt contrib/automation/linux-requirements.txt.in # -appdirs==1.4.4 \ - --hash=sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41 \ - --hash=sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128 -# via black astroid==2.5.6 \ --hash=sha256:4db03ab5fc3340cf619dbc25e42c2cc3755154ce6009469766d7143d1fc2ee4e \ --hash=sha256:8a398dfce302c13f14bab13e2b14fe385d32b73f4e4853b9bdfb64598baa1975 # via pylint -attrs==21.1.0 \ - --hash=sha256:3901be1cb7c2a780f14668691474d9252c070a756be0a9ead98cfeabfa11aeb8 \ - --hash=sha256:8ee1e5f5a1afc5b19bdfae4fdf0c35ed324074bdce3500c939842c8f818645d9 -# via black -black==19.10b0 ; python_version >= "3.6" and platform_python_implementation != "PyPy" \ - --hash=sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b \ - --hash=sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539 +black==22.1.0 ; python_version >= "3.6" and platform_python_implementation != "PyPy" \ + --hash=sha256:07e5c049442d7ca1a2fc273c79d1aecbbf1bc858f62e8184abe1ad175c4f7cc2 \ + --hash=sha256:0e21e1f1efa65a50e3960edd068b6ae6d64ad6235bd8bfea116a03b21836af71 \ + --hash=sha256:1297c63b9e1b96a3d0da2d85d11cd9bf8664251fd69ddac068b98dc4f34f73b6 \ + --hash=sha256:228b5ae2c8e3d6227e4bde5920d2fc66cc3400fde7bcc74f480cb07ef0b570d5 \ + --hash=sha256:2d6f331c02f0f40aa51a22e479c8209d37fcd520c77721c034517d44eecf5912 \ + --hash=sha256:2ff96450d3ad9ea499fc4c60e425a1439c2120cbbc1ab959ff20f7c76ec7e866 \ + --hash=sha256:3524739d76b6b3ed1132422bf9d82123cd1705086723bc3e235ca39fd21c667d \ + --hash=sha256:35944b7100af4a985abfcaa860b06af15590deb1f392f06c8683b4381e8eeaf0 \ + --hash=sha256:373922fc66676133ddc3e754e4509196a8c392fec3f5ca4486673e685a421321 \ + --hash=sha256:5fa1db02410b1924b6749c245ab38d30621564e658297484952f3d8a39fce7e8 \ + --hash=sha256:6f2f01381f91c1efb1451998bd65a129b3ed6f64f79663a55fe0e9b74a5f81fd \ + --hash=sha256:742ce9af3086e5bd07e58c8feb09dbb2b047b7f566eb5f5bc63fd455814979f3 \ + --hash=sha256:7835fee5238fc0a0baf6c9268fb816b5f5cd9b8793423a75e8cd663c48d073ba \ + --hash=sha256:8871fcb4b447206904932b54b567923e5be802b9b19b744fdff092bd2f3118d0 \ + --hash=sha256:a7c0192d35635f6fc1174be575cb7915e92e5dd629ee79fdaf0dcfa41a80afb5 \ + --hash=sha256:b1a5ed73ab4c482208d20434f700d514f66ffe2840f63a6252ecc43a9bc77e8a \ + --hash=sha256:c8226f50b8c34a14608b848dc23a46e5d08397d009446353dad45e04af0c8e28 \ + --hash=sha256:ccad888050f5393f0d6029deea2a33e5ae371fd182a697313bdbd835d3edaf9c \ + --hash=sha256:dae63f2dbf82882fa3b2a3c49c32bffe144970a573cd68d247af6560fc493ae1 \ + --hash=sha256:e2f69158a7d120fd641d1fa9a921d898e20d52e44a74a6fbbcc570a62a6bc8ab \ + --hash=sha256:efbadd9b52c060a8fc3b9658744091cb33c31f830b3f074422ed27bad2b18e8f \ + --hash=sha256:f5660feab44c2e3cb24b2419b998846cbb01c23c7fe645fee45087efa3da2d61 \ + --hash=sha256:fdb8754b453fb15fad3f72cd9cad3e16776f0964d67cf30ebcbf10327a3777a3 # via -r contrib/automation/linux-requirements.txt.in -click==7.1.2 \ - --hash=sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a \ - --hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc +click==8.0.4 \ + --hash=sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1 \ + --hash=sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb # via
D12220: tests: require black 22.1.0
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We recently reformatted the repo with black 22.1.0. Since black 22.1.0 is the first non-beta release of black and black is committed to keeping the style stable for 1 year, I think it makes sense to bump the required black verion to this version. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12220 AFFECTED FILES tests/hghave.py CHANGE DETAILS diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -1119,13 +1119,13 @@ return matchoutput('emacs --version', b'GNU Emacs 2(4.4|4.5|5|6|7|8|9)') -@check('black', 'the black formatter for python (>= 20.8b1)') +@check('black', 'the black formatter for python (>= 22.1.0)') def has_black(): blackcmd = 'black --version' version_regex = b'black, version ([0-9a-b.]+)' version = matchoutput(blackcmd, version_regex) sv = distutils.version.StrictVersion -return version and sv(_bytes2sys(version.group(1))) >= sv('20.8b1') +return version and sv(_bytes2sys(version.group(1))) >= sv('22.1.0') @check('pytype', 'the pytype type checker') To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12222: cext: drop preprocessor PyInt aliases
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Now that we dropped support for Python 2 we can use the Python 3 native functions. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D1 AFFECTED FILES mercurial/cext/charencode.c CHANGE DETAILS diff --git a/mercurial/cext/charencode.c b/mercurial/cext/charencode.c --- a/mercurial/cext/charencode.c +++ b/mercurial/cext/charencode.c @@ -15,14 +15,6 @@ #include "compat.h" #include "util.h" -#ifdef IS_PY3K -/* The mapping of Python types is meant to be temporary to get Python - * 3 to compile. We should remove this once Python 3 support is fully - * supported and proper types are used in the extensions themselves. */ -#define PyInt_Type PyLong_Type -#define PyInt_AS_LONG PyLong_AS_LONG -#endif - /* clang-format off */ static const char lowertable[128] = { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', @@ -228,12 +220,12 @@ const char *table; if (!PyArg_ParseTuple(args, "O!O!O!:make_file_foldmap", &PyDict_Type, - &dmap, &PyInt_Type, &spec_obj, &PyFunction_Type, + &dmap, &PyLong_Type, &spec_obj, &PyFunction_Type, &normcase_fallback)) { goto quit; } - spec = (int)PyInt_AS_LONG(spec_obj); + spec = (int)PyLong_AS_LONG(spec_obj); switch (spec) { case NORMCASE_LOWER: table = lowertable; To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12223: cext: unconditionally use PyLong_FromLong()
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We no longer support Python 2. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12223 AFFECTED FILES mercurial/cext/dirs.c CHANGE DETAILS diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c --- a/mercurial/cext/dirs.c +++ b/mercurial/cext/dirs.c @@ -100,11 +100,7 @@ } /* Force Python to not reuse a small shared int. */ -#ifdef IS_PY3K val = PyLong_FromLong(0x1eadbeef); -#else - val = PyInt_FromLong(0x1eadbeef); -#endif if (val == NULL) goto bail; To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12224: cext: remove some conditional preprocessor defines
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We may want to inline these defines. But for now, getting rid of the Python 2 support is a step forward. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12224 AFFECTED FILES mercurial/cext/manifest.c CHANGE DETAILS diff --git a/mercurial/cext/manifest.c b/mercurial/cext/manifest.c --- a/mercurial/cext/manifest.c +++ b/mercurial/cext/manifest.c @@ -317,12 +317,7 @@ return ret; } -#ifdef IS_PY3K #define LAZYMANIFESTENTRIESITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT -#else -#define LAZYMANIFESTENTRIESITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT \ - | Py_TPFLAGS_HAVE_ITER -#endif static PyTypeObject lazymanifestEntriesIterator = { PyVarObject_HEAD_INIT(NULL, 0) /* header */ @@ -365,12 +360,7 @@ return PyBytes_FromStringAndSize(l->start, pl); } -#ifdef IS_PY3K #define LAZYMANIFESTKEYSITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT -#else -#define LAZYMANIFESTKEYSITERATOR_TPFLAGS Py_TPFLAGS_DEFAULT \ - | Py_TPFLAGS_HAVE_ITER -#endif static PyTypeObject lazymanifestKeysIterator = { PyVarObject_HEAD_INIT(NULL, 0) /* header */ @@ -955,11 +945,7 @@ {NULL}, }; -#ifdef IS_PY3K #define LAZYMANIFEST_TPFLAGS Py_TPFLAGS_DEFAULT -#else -#define LAZYMANIFEST_TPFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_SEQUENCE_IN -#endif static PyTypeObject lazymanifestType = { PyVarObject_HEAD_INIT(NULL, 0) /* header */ To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12225: cext: remove Python 2 variant of listdir_slot()
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12225 AFFECTED FILES mercurial/cext/osutil.c CHANGE DETAILS diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c --- a/mercurial/cext/osutil.c +++ b/mercurial/cext/osutil.c @@ -73,19 +73,11 @@ }; #endif -#ifdef IS_PY3K #define listdir_slot(name) \ static PyObject *listdir_stat_##name(PyObject *self, void *x) \ { \ return PyLong_FromLong(((struct listdir_stat *)self)->st.name); \ } -#else -#define listdir_slot(name) \ - static PyObject *listdir_stat_##name(PyObject *self, void *x) \ - { \ - return PyInt_FromLong(((struct listdir_stat *)self)->st.name); \ - } -#endif listdir_slot(st_dev) listdir_slot(st_mode) To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12226: cext: remove Python 2 file handling code
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12226 AFFECTED FILES mercurial/cext/osutil.c CHANGE DETAILS diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c --- a/mercurial/cext/osutil.c +++ b/mercurial/cext/osutil.c @@ -1219,9 +1219,7 @@ char fpmode[4]; int fppos = 0; int plus; -#ifndef IS_PY3K FILE *fp; -#endif if (!PyArg_ParseTupleAndKeywords(args, kwds, PY23("et|si:posixfile", "et|yi:posixfile"), @@ -1294,7 +1292,6 @@ PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); goto bail; } -#ifndef IS_PY3K fp = _fdopen(fd, fpmode); if (fp == NULL) { _close(fd); @@ -1309,11 +1306,6 @@ } PyFile_SetBufSize(file_obj, bufsize); -#else - file_obj = PyFile_FromFd(fd, name, mode, bufsize, NULL, NULL, NULL, 1); - if (file_obj == NULL) - goto bail; -#endif bail: PyMem_Free(name); return file_obj; To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12227: cext: remove Python 2 support
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We still alias the Python 2 symbols. This will be cleaned up in a separate commit. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12227 AFFECTED FILES mercurial/cext/parsers.c CHANGE DETAILS diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -17,7 +17,6 @@ #include "charencode.h" #include "util.h" -#ifdef IS_PY3K /* The mapping of Python types is meant to be temporary to get Python * 3 to compile. We should remove this once Python 3 support is fully * supported and proper types are used in the extensions themselves. */ @@ -25,13 +24,6 @@ #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong -#else -/* Windows on Python 2.7 doesn't define S_IFLNK. Python 3+ defines via - * pyport.h. */ -#ifndef S_IFLNK -#define S_IFLNK 012 -#endif -#endif static const char *const versionerrortext = "Python minor version mismatch"; To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12221: cext: remove Python 2 module initializer functions
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We no longer need these since we dropped support for Python 2. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12221 AFFECTED FILES mercurial/cext/base85.c mercurial/cext/bdiff.c mercurial/cext/mpatch.c mercurial/cext/osutil.c mercurial/cext/parsers.c CHANGE DETAILS diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -1307,7 +1307,6 @@ return 0; } -#ifdef IS_PY3K static struct PyModuleDef parsers_module = {PyModuleDef_HEAD_INIT, "parsers", parsers_doc, -1, methods}; @@ -1321,15 +1320,3 @@ module_init(mod); return mod; } -#else -PyMODINIT_FUNC initparsers(void) -{ - PyObject *mod; - - if (check_python_version() == -1) { - return; - } - mod = Py_InitModule3("parsers", methods, parsers_doc); - module_init(mod); -} -#endif diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c --- a/mercurial/cext/osutil.c +++ b/mercurial/cext/osutil.c @@ -1387,7 +1387,6 @@ static const int version = 4; -#ifdef IS_PY3K static struct PyModuleDef osutil_module = { PyModuleDef_HEAD_INIT, "osutil", @@ -1406,14 +1405,3 @@ PyModule_AddIntConstant(m, "version", version); return m; } -#else -PyMODINIT_FUNC initosutil(void) -{ - PyObject *m; - if (PyType_Ready(&listdir_stat_type) == -1) - return; - - m = Py_InitModule3("osutil", methods, osutil_doc); - PyModule_AddIntConstant(m, "version", version); -} -#endif diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c --- a/mercurial/cext/mpatch.c +++ b/mercurial/cext/mpatch.c @@ -182,7 +182,6 @@ static const int version = 1; -#ifdef IS_PY3K static struct PyModuleDef mpatch_module = { PyModuleDef_HEAD_INIT, "mpatch", mpatch_doc, -1, methods, }; @@ -203,13 +202,3 @@ return m; } -#else -PyMODINIT_FUNC initmpatch(void) -{ - PyObject *m; - m = Py_InitModule3("mpatch", methods, mpatch_doc); - mpatch_Error = - PyErr_NewException("mercurial.cext.mpatch.mpatchError", NULL, NULL); - PyModule_AddIntConstant(m, "version", version); -} -#endif diff --git a/mercurial/cext/bdiff.c b/mercurial/cext/bdiff.c --- a/mercurial/cext/bdiff.c +++ b/mercurial/cext/bdiff.c @@ -337,7 +337,6 @@ static const int version = 3; -#ifdef IS_PY3K static struct PyModuleDef bdiff_module = { PyModuleDef_HEAD_INIT, "bdiff", mdiff_doc, -1, methods, }; @@ -349,11 +348,3 @@ PyModule_AddIntConstant(m, "version", version); return m; } -#else -PyMODINIT_FUNC initbdiff(void) -{ - PyObject *m; - m = Py_InitModule3("bdiff", methods, mdiff_doc); - PyModule_AddIntConstant(m, "version", version); -} -#endif diff --git a/mercurial/cext/base85.c b/mercurial/cext/base85.c --- a/mercurial/cext/base85.c +++ b/mercurial/cext/base85.c @@ -177,7 +177,6 @@ static const int version = 1; -#ifdef IS_PY3K static struct PyModuleDef base85_module = { PyModuleDef_HEAD_INIT, "base85", base85_doc, -1, methods, }; @@ -191,13 +190,3 @@ PyModule_AddIntConstant(m, "version", version); return m; } -#else -PyMODINIT_FUNC initbase85(void) -{ - PyObject *m; - m = Py_InitModule3("base85", methods, base85_doc); - - b85prep(); - PyModule_AddIntConstant(m, "version", version); -} -#endif To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12228: cext: use PyLong symbols
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We no longer need to support Python 2. So use the Python 3 symbol names directly. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12228 AFFECTED FILES mercurial/cext/parsers.c CHANGE DETAILS diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -17,14 +17,6 @@ #include "charencode.h" #include "util.h" -/* The mapping of Python types is meant to be temporary to get Python - * 3 to compile. We should remove this once Python 3 support is fully - * supported and proper types are used in the extensions themselves. */ -#define PyInt_Check PyLong_Check -#define PyInt_FromLong PyLong_FromLong -#define PyInt_FromSsize_t PyLong_FromSsize_t -#define PyInt_AsLong PyLong_AsLong - static const char *const versionerrortext = "Python minor version mismatch"; static const int dirstate_v1_from_p2 = -2; @@ -305,17 +297,17 @@ static PyObject *dirstate_item_v1_mode(dirstateItemObject *self) { - return PyInt_FromLong(dirstate_item_c_v1_mode(self)); + return PyLong_FromLong(dirstate_item_c_v1_mode(self)); }; static PyObject *dirstate_item_v1_size(dirstateItemObject *self) { - return PyInt_FromLong(dirstate_item_c_v1_size(self)); + return PyLong_FromLong(dirstate_item_c_v1_size(self)); }; static PyObject *dirstate_item_v1_mtime(dirstateItemObject *self) { - return PyInt_FromLong(dirstate_item_c_v1_mtime(self)); + return PyLong_FromLong(dirstate_item_c_v1_mtime(self)); }; static PyObject *dirstate_item_mtime_likely_equal_to(dirstateItemObject *self, @@ -561,17 +553,17 @@ static PyObject *dirstate_item_get_mode(dirstateItemObject *self) { - return PyInt_FromLong(dirstate_item_c_v1_mode(self)); + return PyLong_FromLong(dirstate_item_c_v1_mode(self)); }; static PyObject *dirstate_item_get_size(dirstateItemObject *self) { - return PyInt_FromLong(dirstate_item_c_v1_size(self)); + return PyLong_FromLong(dirstate_item_c_v1_size(self)); }; static PyObject *dirstate_item_get_mtime(dirstateItemObject *self) { - return PyInt_FromLong(dirstate_item_c_v1_mtime(self)); + return PyLong_FromLong(dirstate_item_c_v1_mtime(self)); }; static PyObject *dirstate_item_get_state(dirstateItemObject *self) @@ -1279,7 +1271,7 @@ if (!ver) { return -1; } - hexversion = PyInt_AsLong(ver); + hexversion = PyLong_AsLong(ver); Py_DECREF(ver); /* sys.hexversion is a 32-bit number by default, so the -1 case * should only occur in unusual circumstances (e.g. if sys.hexversion To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12230: cext: unconditionalize PYLONG_VALUE()
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We only support Python 3 now. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12230 AFFECTED FILES mercurial/cext/dirs.c CHANGE DETAILS diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c --- a/mercurial/cext/dirs.c +++ b/mercurial/cext/dirs.c @@ -13,11 +13,7 @@ #include "util.h" -#ifdef IS_PY3K #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0] -#else -#define PYLONG_VALUE(o) PyInt_AS_LONG(o) -#endif /* * This is a multiset of directory names, built from the files that To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12229: cext: use PyLong symbols
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We no longer support Python 2. So we can unconditionally use the Python 3 symbol names. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12229 AFFECTED FILES mercurial/cext/revlog.c CHANGE DETAILS diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -23,16 +23,6 @@ #include "revlog.h" #include "util.h" -#ifdef IS_PY3K -/* The mapping of Python types is meant to be temporary to get Python - * 3 to compile. We should remove this once Python 3 support is fully - * supported and proper types are used in the extensions themselves. */ -#define PyInt_Check PyLong_Check -#define PyInt_FromLong PyLong_FromLong -#define PyInt_FromSsize_t PyLong_FromSsize_t -#define PyInt_AsLong PyLong_AsLong -#endif - typedef struct indexObjectStruct indexObject; typedef struct { @@ -802,7 +792,7 @@ #define istat(__n, __d) \ do { \ s = PyBytes_FromString(__d); \ - t = PyInt_FromSsize_t(self->__n); \ + t = PyLong_FromSsize_t(self->__n); \ if (!s || !t) \ goto bail; \ if (PyDict_SetItem(obj, s, t) == -1) \ @@ -953,7 +943,7 @@ l = PyList_GET_SIZE(roots); for (i = 0; i < l; i++) { - revnum = PyInt_AsLong(PyList_GET_ITEM(roots, i)); + revnum = PyLong_AsLong(PyList_GET_ITEM(roots, i)); if (revnum == -1 && PyErr_Occurred()) goto bail; /* If root is out of range, e.g. wdir(), it must be unreachable @@ -966,7 +956,7 @@ /* Populate tovisit with all the heads */ l = PyList_GET_SIZE(heads); for (i = 0; i < l; i++) { - revnum = PyInt_AsLong(PyList_GET_ITEM(heads, i)); + revnum = PyLong_AsLong(PyList_GET_ITEM(heads, i)); if (revnum == -1 && PyErr_Occurred()) goto bail; if (revnum + 1 < 0 || revnum + 1 >= len + 1) { @@ -986,7 +976,7 @@ revnum = tovisit[k++]; if (revstates[revnum + 1] & RS_ROOT) { revstates[revnum + 1] |= RS_REACHABLE; - val = PyInt_FromLong(revnum); + val = PyLong_FromLong(revnum); if (val == NULL) goto bail; r = PyList_Append(reachable, val); @@ -1031,7 +1021,7 @@ RS_REACHABLE) && !(revstates[i + 1] & RS_REACHABLE)) { revstates[i + 1] |= RS_REACHABLE; - val = PyInt_FromSsize_t(i); + val = PyLong_FromSsize_t(i); if (val == NULL) goto bail; r = PyList_Append(reachable, val); @@ -1116,7 +1106,7 @@ } for (i = 0; i < numphases; ++i) { - PyObject *pyphase = PyInt_FromLong(trackedphases[i]); + PyObject *pyphase = PyLong_FromLong(trackedphases[i]); PyObject *phaseroots = NULL; if (pyphase == NULL) goto release; @@ -1175,7 +1165,7 @@ "bad phase number in internal list"); goto release; } - pyrev = PyInt_FromLong(rev); + pyrev = PyLong_FromLong(rev); if (pyrev == NULL) goto release; if (PySet_Add(pyphase, pyrev) == -1) { @@ -1189,7 +1179,7 @@ if (phasesetsdict == NULL) goto release; for (i = 0; i < numphases; ++i) { - PyObject *pyphase = PyInt_FromLong(trackedphases[i]); + PyObject *pyphase = PyLong_FromLong(trackedphases[i]); if (pyphase == NULL) goto release; if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) == @@ -1247,7 +1237,7 @@ if (heads == NULL) goto bail; if (len == 0) { - PyObject *nullid = PyInt_FromLong(-1); + PyObject *nullid = PyLong_FromLong(-1); if (nullid == NULL || PyList_Append(heads, nullid) == -1) { Py_XDECREF(nullid); goto bail; @@ -1296,7 +1286,7 @@ if (nothead[i])
D12231: cext: unconditionalize PySlice_GetIndicesEx()
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We only support Python 3 now. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12231 AFFECTED FILES mercurial/cext/revlog.c CHANGE DETAILS diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -2825,14 +2825,8 @@ Py_ssize_t length = index_length(self) + 1; int ret = 0; -/* Argument changed from PySliceObject* to PyObject* in Python 3. */ -#ifdef IS_PY3K if (PySlice_GetIndicesEx(item, length, &start, &stop, &step, &slicelength) < 0) -#else - if (PySlice_GetIndicesEx((PySliceObject *)item, length, &start, &stop, -&step, &slicelength) < 0) -#endif return -1; if (slicelength <= 0) To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12233: cext: remove inline rewriting of argv
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This only worked on Python 2. And since we dropped support for Python 2, we can drop support for this functionality. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12233 AFFECTED FILES mercurial/cext/osutil.c mercurial/cext/util.h CHANGE DETAILS diff --git a/mercurial/cext/util.h b/mercurial/cext/util.h --- a/mercurial/cext/util.h +++ b/mercurial/cext/util.h @@ -10,10 +10,6 @@ #include "compat.h" -#if PY_MAJOR_VERSION >= 3 -#define IS_PY3K -#endif - /* clang-format off */ typedef struct { PyObject_HEAD diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c --- a/mercurial/cext/osutil.c +++ b/mercurial/cext/osutil.c @@ -759,10 +759,6 @@ #if defined(HAVE_SETPROCTITLE) /* setproctitle is the first choice - available in FreeBSD */ #define SETPROCNAME_USE_SETPROCTITLE -#elif (defined(__linux__) || defined(__APPLE__)) && PY_MAJOR_VERSION == 2 -/* rewrite the argv buffer in place - works in Linux and OS X. Py_GetArgcArgv - * in Python 3 returns the copied wchar_t **argv, thus unsupported. */ -#define SETPROCNAME_USE_ARGVREWRITE #else #define SETPROCNAME_USE_NONE #endif @@ -777,44 +773,6 @@ #if defined(SETPROCNAME_USE_SETPROCTITLE) setproctitle("%s", name); -#elif defined(SETPROCNAME_USE_ARGVREWRITE) - { - static char *argvstart = NULL; - static size_t argvsize = 0; - if (argvstart == NULL) { - int argc = 0, i; - char **argv = NULL; - char *argvend; - extern void Py_GetArgcArgv(int *argc, char ***argv); - Py_GetArgcArgv(&argc, &argv); - /* Py_GetArgcArgv may not do much if a custom python -* launcher is used that doesn't record the information -* it needs. Let's handle this gracefully instead of -* segfaulting. */ - if (argv != NULL) - argvend = argvstart = argv[0]; - else - argvend = argvstart = NULL; - - /* Check the memory we can use. Typically, argv[i] and -* argv[i + 1] are continuous. */ - for (i = 0; i < argc; ++i) { - size_t len; - if (argv[i] > argvend || argv[i] < argvstart) - break; /* not continuous */ - len = strlen(argv[i]); - argvend = argv[i] + len + 1 /* '\0' */; - } - if (argvend > argvstart) /* sanity check */ - argvsize = argvend - argvstart; - } - - if (argvstart && argvsize > 1) { - int n = snprintf(argvstart, argvsize, "%s", name); - if (n >= 0 && (size_t)n < argvsize) - memset(argvstart + n, 0, argvsize - n); - } - } #endif Py_RETURN_NONE; To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12232: cext: remove PY23()
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Since we always run on Python 3 now, we no longer need this macro to support Python 2. We refactor all users to just use the 2nd argument. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12232 AFFECTED FILES mercurial/cext/base85.c mercurial/cext/bdiff.c mercurial/cext/charencode.c mercurial/cext/manifest.c mercurial/cext/mpatch.c mercurial/cext/osutil.c mercurial/cext/parsers.c mercurial/cext/pathencode.c mercurial/cext/revlog.c mercurial/cext/util.h CHANGE DETAILS diff --git a/mercurial/cext/util.h b/mercurial/cext/util.h --- a/mercurial/cext/util.h +++ b/mercurial/cext/util.h @@ -14,13 +14,6 @@ #define IS_PY3K #endif -/* helper to switch things like string literal depending on Python version */ -#ifdef IS_PY3K -#define PY23(py2, py3) py3 -#else -#define PY23(py2, py3) py2 -#endif - /* clang-format off */ typedef struct { PyObject_HEAD diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -109,11 +109,9 @@ static int index_find_node(indexObject *self, const char *node); #if LONG_MAX == 0x7fffL -static const char *const tuple_format = -PY23("Kiis#KiBBi", "Kiiy#KiBBi"); +static const char *const tuple_format = "Kiiy#KiBBi"; #else -static const char *const tuple_format = -PY23("kiis#kiBBi", "kiiy#kiBBi"); +static const char *const tuple_format = "kiiy#kiBBi"; #endif /* A RevlogNG v1 index entry is 64 bytes long. */ @@ -720,9 +718,9 @@ char comp_mode; char *data; #if LONG_MAX == 0x7fffL - const char *const sidedata_format = PY23("nKiKB", "nKiKB"); + const char *const sidedata_format = "nKiKB"; #else - const char *const sidedata_format = PY23("nkikB", "nkikB"); + const char *const sidedata_format = "nkikB"; #endif if (self->entry_size == v1_entry_size || self->inlined) { @@ -2301,7 +2299,7 @@ char *node; int rev, i; - if (!PyArg_ParseTuple(args, PY23("s#", "y#"), &node, &nodelen)) + if (!PyArg_ParseTuple(args, "y#", &node, &nodelen)) return NULL; if (nodelen < 1) { @@ -3012,10 +3010,9 @@ self->entry_size = cl2_entry_size; } - self->nullentry = - Py_BuildValue(PY23("iiis#iiBBi", "iiiy#iiBBi"), 0, 0, 0, -1, - -1, -1, -1, nullid, self->nodelen, 0, 0, - comp_mode_inline, comp_mode_inline, rank_unknown); + self->nullentry = Py_BuildValue( + "iiiy#iiBBi", 0, 0, 0, -1, -1, -1, -1, nullid, self->nodelen, 0, + 0, comp_mode_inline, comp_mode_inline, rank_unknown); if (!self->nullentry) return -1; diff --git a/mercurial/cext/pathencode.c b/mercurial/cext/pathencode.c --- a/mercurial/cext/pathencode.c +++ b/mercurial/cext/pathencode.c @@ -535,8 +535,7 @@ Py_ssize_t len, newlen; PyObject *ret; - if (!PyArg_ParseTuple(args, PY23("s#:lowerencode", "y#:lowerencode"), - &path, &len)) { + if (!PyArg_ParseTuple(args, "y#:lowerencode", &path, &len)) { return NULL; } @@ -711,7 +710,7 @@ } } - shaobj = PyObject_CallFunction(shafunc, PY23("s#", "y#"), str, len); + shaobj = PyObject_CallFunction(shafunc, "y#", str, len); if (shaobj == NULL) { return -1; diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -813,9 +813,8 @@ Py_ssize_t len = 40; Py_ssize_t readlen; - if (!PyArg_ParseTuple( - args, PY23("O!O!s#:parse_dirstate", "O!O!y#:parse_dirstate"), - &PyDict_Type, &dmap, &PyDict_Type, &cmap, &str, &readlen)) { + if (!PyArg_ParseTuple(args, "O!O!y#:parse_dirstate", &PyDict_Type, + &dmap, &PyDict_Type, &cmap, &str, &readlen)) { goto quit; } @@ -828,8 +827,8 @@ goto quit; } - parents = Py_BuildValue(PY23("s#s#", "y#y#"), str, (Py_ssize_t)20, - str + 20, (Py_ssize_t)20); + parents = Py_BuildValue("y#y#", str, (Py_ssize_t)20, str + 20, + (Py_ssize_t)20); if (!parents) { goto quit; } @@ -1158,8 +1157,7 @@ Py_ssize_t datalen, offset, stop; PyObject *markers = NULL; - if (!PyArg_ParseTuple(args, PY23("s#nn", "y#nn"), &data, &datalen, - &offset, &stop)) { + if (!PyArg_ParseTuple(args, "y#nn", &data, &datalen, &offset, &stop)) { return NULL; } if (offset < 0) { diff --git a/mercurial/cext/osutil.
D12218: black: blacken with 22.1.0
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY black 22.1.0 is the first non-beta release of black. I think it makes sense for us to adopt this version of black. This commit blackens the repo with version 22.1.0. skip-blame: formatting only changes with black REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12218 AFFECTED FILES contrib/byteify-strings.py contrib/check-config.py contrib/fuzz/mpatch_corpus.py contrib/hgclient.py contrib/perf.py contrib/python-zstandard/tests/test_decompressor.py contrib/revsetbenchmarks.py contrib/testparseutil.py hgext/fsmonitor/pywatchman/__init__.py hgext/fsmonitor/pywatchman/compat.py hgext/fsmonitor/pywatchman/encoding.py hgext/remotefilelog/basepack.py hgext/remotefilelog/datapack.py i18n/polib.py mercurial/bundlerepo.py mercurial/cext/bdiff.pyi mercurial/cext/parsers.pyi mercurial/changegroup.py mercurial/copies.py mercurial/dispatch.py mercurial/mail.py mercurial/patch.py mercurial/posix.py mercurial/pure/osutil.py mercurial/revlog.py mercurial/store.py mercurial/subrepo.py mercurial/urllibcompat.py mercurial/util.py mercurial/utils/cborutil.py mercurial/utils/compression.py mercurial/utils/procutil.py mercurial/utils/resourceutil.py mercurial/win32.py mercurial/worker.py setup.py tests/dumbhttp.py tests/fsmonitor-run-tests.py tests/hghave.py tests/killdaemons.py tests/test-cbor.py tests/test-remotefilelog-datapack.py tests/test-revlog-raw.py tests/test-stdio.py tests/test-verify-repo-operations.py CHANGE DETAILS diff --git a/tests/test-verify-repo-operations.py b/tests/test-verify-repo-operations.py --- a/tests/test-verify-repo-operations.py +++ b/tests/test-verify-repo-operations.py @@ -619,8 +619,8 @@ settings( timeout=-1, stateful_step_count=1000, -max_examples=10 ** 8, -max_iterations=10 ** 8, +max_examples=10**8, +max_iterations=10**8, database=writeonlydatabase(settings.default.database), ), ) diff --git a/tests/test-stdio.py b/tests/test-stdio.py --- a/tests/test-stdio.py +++ b/tests/test-stdio.py @@ -22,7 +22,6 @@ # On Python 3, file descriptors are non-inheritable by default. pass - else: if pycompat.iswindows: # unused diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py --- a/tests/test-revlog-raw.py +++ b/tests/test-revlog-raw.py @@ -252,7 +252,7 @@ That is to say, given any x, y where both x, and y are in range(2 ** n), there is an x followed immediately by y in the generated sequence. """ -m = 2 ** n +m = 2**n # Gray Code. See https://en.wikipedia.org/wiki/Gray_code gray = lambda x: x ^ (x >> 1) diff --git a/tests/test-remotefilelog-datapack.py b/tests/test-remotefilelog-datapack.py --- a/tests/test-remotefilelog-datapack.py +++ b/tests/test-remotefilelog-datapack.py @@ -187,7 +187,7 @@ content = b'put-something-here \n' * i node = self.getHash(content) meta = { -constants.METAKEYFLAG: i ** 4, +constants.METAKEYFLAG: i**4, constants.METAKEYSIZE: len(content), b'Z': b'random_string', b'_': b'\0' * i, diff --git a/tests/test-cbor.py b/tests/test-cbor.py --- a/tests/test-cbor.py +++ b/tests/test-cbor.py @@ -218,11 +218,11 @@ for size in lens: if size < 24: hlen = 1 -elif size < 2 ** 8: +elif size < 2**8: hlen = 2 -elif size < 2 ** 16: +elif size < 2**16: hlen = 3 -elif size < 2 ** 32: +elif size < 2**32: hlen = 5 else: assert False @@ -489,7 +489,7 @@ ) def testdecodepartialushort(self): -encoded = b''.join(cborutil.streamencode(2 ** 15)) +encoded = b''.join(cborutil.streamencode(2**15)) self.assertEqual( cborutil.decodeitem(encoded[0:1]), @@ -501,7 +501,7 @@ ) self.assertEqual( cborutil.decodeitem(encoded[0:5]), -(True, 2 ** 15, 3, cborutil.SPECIAL_NONE), +(True, 2**15, 3, cborutil.SPECIAL_NONE), ) def testdecodepartialshort(self): @@ -521,7 +521,7 @@ ) def testdecodepartialulong(self): -encoded = b''.join(cborutil.streamencode(2 ** 28)) +encoded = b''.join(cborutil.streamencode(2**28)) self.assertEqual( cborutil.decodeitem(encoded[0:1]), @@ -541,7 +541,7 @@ ) self.assertEqual( cborutil.decodeitem(encoded[0:5]), -(True, 2 ** 28, 5, cborutil.SPECIAL_NONE), +(True, 2**28, 5, cborutil.SPECIAL_NONE), ) def testd
D12234: tests: require Python 3.5+ in run-tests.py
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We change the version check logic to hard fail if running on <= 3.5.0. The branch for <3.5 has been deleted. And the >=3.5 branch block has been dedented. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12234 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -45,6 +45,7 @@ from __future__ import absolute_import, print_function + import argparse import collections import contextlib @@ -154,81 +155,70 @@ origenviron = os.environ.copy() - -if sys.version_info > (3, 5, 0): -PYTHON3 = True -xrange = range # we use xrange in one place, and we'd rather not use range - -def _sys2bytes(p): -if p is None: -return p -return p.encode('utf-8') - -def _bytes2sys(p): -if p is None: -return p -return p.decode('utf-8') - -osenvironb = getattr(os, 'environb', None) -if osenvironb is None: -# Windows lacks os.environb, for instance. A proxy over the real thing -# instead of a copy allows the environment to be updated via bytes on -# all platforms. -class environbytes(object): -def __init__(self, strenv): -self.__len__ = strenv.__len__ -self.clear = strenv.clear -self._strenv = strenv - -def __getitem__(self, k): -v = self._strenv.__getitem__(_bytes2sys(k)) -return _sys2bytes(v) - -def __setitem__(self, k, v): -self._strenv.__setitem__(_bytes2sys(k), _bytes2sys(v)) - -def __delitem__(self, k): -self._strenv.__delitem__(_bytes2sys(k)) - -def __contains__(self, k): -return self._strenv.__contains__(_bytes2sys(k)) - -def __iter__(self): -return iter([_sys2bytes(k) for k in iter(self._strenv)]) - -def get(self, k, default=None): -v = self._strenv.get(_bytes2sys(k), _bytes2sys(default)) -return _sys2bytes(v) - -def pop(self, k, default=None): -v = self._strenv.pop(_bytes2sys(k), _bytes2sys(default)) -return _sys2bytes(v) - -osenvironb = environbytes(os.environ) - -getcwdb = getattr(os, 'getcwdb') -if not getcwdb or WINDOWS: -getcwdb = lambda: _sys2bytes(os.getcwd()) - -elif sys.version_info >= (3, 0, 0): +if sys.version_info < (3, 5, 0): print( -'%s is only supported on Python 3.5+ and 2.7, not %s' +'%s is only supported on Python 3.5+, not %s' % (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3])) ) sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` -else: -PYTHON3 = False - -# In python 2.x, path operations are generally done using -# bytestrings by default, so we don't have to do any extra -# fiddling there. We define the wrapper functions anyway just to -# help keep code consistent between platforms. -def _sys2bytes(p): + +PYTHON3 = True +xrange = range # we use xrange in one place, and we'd rather not use range + + +def _sys2bytes(p): +if p is None: +return p +return p.encode('utf-8') + + +def _bytes2sys(p): +if p is None: return p - -_bytes2sys = _sys2bytes -osenvironb = os.environ -getcwdb = os.getcwd +return p.decode('utf-8') + + +osenvironb = getattr(os, 'environb', None) +if osenvironb is None: +# Windows lacks os.environb, for instance. A proxy over the real thing +# instead of a copy allows the environment to be updated via bytes on +# all platforms. +class environbytes(object): +def __init__(self, strenv): +self.__len__ = strenv.__len__ +self.clear = strenv.clear +self._strenv = strenv + +def __getitem__(self, k): +v = self._strenv.__getitem__(_bytes2sys(k)) +return _sys2bytes(v) + +def __setitem__(self, k, v): +self._strenv.__setitem__(_bytes2sys(k), _bytes2sys(v)) + +def __delitem__(self, k): +self._strenv.__delitem__(_bytes2sys(k)) + +def __contains__(self, k): +return self._strenv.__contains__(_bytes2sys(k)) + +def __iter__(self): +return iter([_sys2bytes(k) for k in iter(self._strenv)]) + +def get(self, k, default=None): +v = self._strenv.get(_bytes2sys(k), _bytes2sys(default)) +return _sys2bytes(v) + +def pop(self, k, default=None): +v = self._strenv.pop(_bytes2sys(k), _bytes2sys(default)) +return _sys2bytes(v) + +osenvironb = environbytes(os.environ) + +getcwdb = getattr(os, 'getcwdb') +if not getcwdb or WINDOWS: +g
D12235: tests: collapse some more trivial if PYTHON3 blocks
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This doesn't account for all of the references to PYTHON3. But it accounts for the ones that are more trivial and don't entail logical changes. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12235 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -362,18 +362,10 @@ def which(exe): -if PYTHON3: -# shutil.which only accept bytes from 3.8 -cmd = _bytes2sys(exe) -real_exec = shutil.which(cmd) -return _sys2bytes(real_exec) -else: -# let us do the os work -for p in osenvironb[b'PATH'].split(os.pathsep): -f = os.path.join(p, exe) -if os.path.isfile(f): -return f -return None +# shutil.which only accept bytes from 3.8 +cmd = _bytes2sys(exe) +real_exec = shutil.which(cmd) +return _sys2bytes(real_exec) def parselistfiles(files, listtype, warn=True): @@ -1864,11 +1856,8 @@ script.append(b'alias pwd="pwd -W"\n') if hgcatapult and hgcatapult != os.devnull: -if PYTHON3: -hgcatapult = hgcatapult.encode('utf8') -cataname = self.name.encode('utf8') -else: -cataname = self.name +hgcatapult = hgcatapult.encode('utf8') +cataname = self.name.encode('utf8') # Kludge: use a while loop to keep the pipe from getting # closed by our echo commands. The still-running file gets @@ -2173,11 +2162,8 @@ return "retry", False if el.endswith(b" (esc)\n"): -if PYTHON3: -el = el[:-7].decode('unicode_escape') + '\n' -el = el.encode('latin-1') -else: -el = el[:-7].decode('string-escape') + '\n' +el = el[:-7].decode('unicode_escape') + '\n' +el = el.encode('latin-1') if el == l or WINDOWS and el[:-1] + b'\r\n' == l: return True, True if el.endswith(b" (re)\n"): @@ -2225,10 +2211,7 @@ firstlock = threading.RLock() firsterror = False -if PYTHON3: -base_class = unittest.TextTestResult -else: -base_class = unittest._TextTestResult +base_class = unittest.TextTestResult class TestResult(base_class): @@ -2352,13 +2335,9 @@ self.stream.write('\n') for line in lines: line = highlightdiff(line, self.color) -if PYTHON3: -self.stream.flush() -self.stream.buffer.write(line) -self.stream.buffer.flush() -else: -self.stream.write(line) -self.stream.flush() +self.stream.flush() +self.stream.buffer.write(line) +self.stream.buffer.flush() if servefail: raise test.failureException( @@ -3247,10 +3226,7 @@ fileb = _sys2bytes(__file__) runtestdir = os.path.abspath(os.path.dirname(fileb)) osenvironb[b'RUNTESTDIR'] = runtestdir -if PYTHON3: -sepb = _sys2bytes(os.pathsep) -else: -sepb = os.pathsep +sepb = _sys2bytes(os.pathsep) path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb) if os.path.islink(__file__): # test helper will likely be at the end of the symlink @@ -3598,10 +3574,8 @@ pyexe_names = [b'python', b'python3', b'python.exe'] elif WINDOWS: pyexe_names = [b'python', b'python.exe'] -elif PYTHON3: +else: pyexe_names = [b'python', b'python3'] -else: -pyexe_names = [b'python', b'python2'] # os.symlink() is a thing with py3 on Windows, but it requires # Administrator rights. @@ -3766,10 +3740,7 @@ else: with open(installerrs, 'rb') as f: for line in f: -if PYTHON3: -sys.stdout.buffer.write(line) -else: -sys.stdout.write(line) +sys.stdout.buffer.write(line) sys.exit(1) os.chdir(self._testdir) @@ -3862,10 +3833,7 @@ ) out, _err = proc.communicate() if proc.returncode != 0: -if PYTHON3: -sys.stdout.buffer.write(out) -else: -sys.stdout.write(out) +sys.stdout.buffer.write(out) sys.exit(1) def _installrhg(self): @@ -3889,10 +3857,7 @@ ) out, _err = proc.communicate() if proc.returncode != 0: -
D12236: tests: collapse elif PYTHON3 block
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY PYTHON3 is always True now so this logic should be identical as to before. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12236 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -278,12 +278,11 @@ except socket.error as exc: if WINDOWS and exc.errno == errno.WSAEACCES: return False -elif PYTHON3: -# TODO: make a proper exception handler after dropping py2. This -# works because socket.error is an alias for OSError on py3, -# which is also the baseclass of PermissionError. -if isinstance(exc, PermissionError): -return False +# TODO: make a proper exception handler after dropping py2. This +# works because socket.error is an alias for OSError on py3, +# which is also the baseclass of PermissionError. +elif isinstance(exc, PermissionError): +return False if exc.errno not in ( errno.EADDRINUSE, errno.EADDRNOTAVAIL, To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12237: tests: unconditionalize _unified_diff
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Now that we're Python 3 only we can make this logic simpler. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12237 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -52,6 +52,7 @@ import difflib import distutils.version as version import errno +import functools import json import multiprocessing import os @@ -879,11 +880,7 @@ pass -_unified_diff = difflib.unified_diff -if PYTHON3: -import functools - -_unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) +_unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) def getdiff(expected, output, ref, err): To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12240: tests: remove Python 3 conditionalizing from variables
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12240 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -3675,12 +3675,9 @@ setup_opts = b"--no-rust" # Run installer in hg root -script = os.path.realpath(sys.argv[0]) -exe = sysexecutable -if PYTHON3: -compiler = _sys2bytes(compiler) -script = _sys2bytes(script) -exe = _sys2bytes(exe) +compiler = _sys2bytes(compiler) +script = _sys2bytes(os.path.realpath(sys.argv[0])) +exe = _sys2bytes(sysexecutable) hgroot = os.path.dirname(os.path.dirname(script)) self._hgroot = hgroot os.chdir(hgroot) To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12238: tests: unconditionalize bchr
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We could probably just do bytes([x]) everywhere. But this eliminates use of PYTHON3. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12238 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1655,9 +1655,7 @@ re.compile(br'.*\$LOCALIP.*$'), ] -bchr = chr -if PYTHON3: -bchr = lambda x: bytes([x]) +bchr = lambda x: bytes([x]) WARN_UNDEFINED = 1 WARN_YES = 2 To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12239: tests: always encode session
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12239 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1794,9 +1794,7 @@ script.append(b'echo %s %d $?\n' % (salt, line)) activetrace = [] -session = str(uuid.uuid4()) -if PYTHON3: -session = session.encode('ascii') +session = str(uuid.uuid4()).encode('ascii') hgcatapult = os.getenv('HGTESTCATAPULTSERVERPIPE') or os.getenv( 'HGCATAPULTSERVERPIPE' ) To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12241: tests: unconditionalize _bytes2sys()
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY As part of requiring Python 3. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12241 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -3790,9 +3790,7 @@ return self._hgpath cmd = b'"%s" -c "import mercurial; print (mercurial.__path__[0])"' -cmd = cmd % PYTHON -if PYTHON3: -cmd = _bytes2sys(cmd) +cmd = _bytes2sys(cmd % PYTHON) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) out, err = p.communicate() To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12242: tests: delete some not PYTHON3 blocks
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY These can never be used anymore. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12242 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -3610,14 +3610,6 @@ f.write(b'%s "$@"\n' % esc_executable) if WINDOWS: -if not PYTHON3: -# lets try to build a valid python3 executable for the -# scrip that requires it. -py3exe_name = os.path.join(self._custom_bin_dir, b'python3') -with open(py3exe_name, 'wb') as f: -f.write(b'#!/bin/sh\n') -f.write(b'py -3 "$@"\n') - # adjust the path to make sur the main python finds it own dll path = os.environ['PATH'].split(os.pathsep) main_exec_dir = os.path.dirname(sysexecutable) @@ -3630,8 +3622,6 @@ if appdata is not None: python_dir = 'Python%d%d' % (vi[0], vi[1]) scripts_path = [appdata, 'Python', python_dir, 'Scripts'] -if not PYTHON3: -scripts_path = [appdata, 'Python', 'Scripts'] scripts_dir = os.path.join(*scripts_path) extra_paths.append(scripts_dir) To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12243: tests: simplify Windows and PYTHON3 conditionals
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY PYTHON3 is always True. So this flow can be reduced. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12243 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -3562,10 +3562,8 @@ def _usecorrectpython(self): """Configure the environment to use the appropriate Python in tests.""" # Tests must use the same interpreter as us or bad things will happen. -if WINDOWS and PYTHON3: +if WINDOWS: pyexe_names = [b'python', b'python3', b'python.exe'] -elif WINDOWS: -pyexe_names = [b'python', b'python.exe'] else: pyexe_names = [b'python', b'python3'] To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12245: tests: unconditionalize some imports
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Now that we require Python 3 we can simplify these imports. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12245 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -57,8 +57,10 @@ import multiprocessing import os import platform +import queue import random import re +import shlex import shutil import signal import socket @@ -73,20 +75,7 @@ import xml.dom.minidom as minidom WINDOWS = os.name == r'nt' - -try: -import Queue as queue -except ImportError: -import queue - -try: -import shlex - -shellquote = shlex.quote -except (ImportError, AttributeError): -import pipes - -shellquote = pipes.quote +shellquote = shlex.quote processlock = threading.Lock() To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12244: tests: remove last references to PYTHON3
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This removes the last references to PYTHON3. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12244 AFFECTED FILES tests/run-tests.py CHANGE DETAILS diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -163,7 +163,6 @@ ) sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` -PYTHON3 = True xrange = range # we use xrange in one place, and we'd rather not use range @@ -1464,7 +1463,7 @@ # This has the same effect as Py_LegacyWindowsStdioFlag in exewrapper.c, # but this is needed for testing python instances like dummyssh, # dummysmtpd.py, and dumbhttp.py. -if PYTHON3 and WINDOWS: +if WINDOWS: env['PYTHONLEGACYWINDOWSSTDIO'] = '1' # Modified HOME in test environment can confuse Rust tools. So set @@ -3414,7 +3413,7 @@ failed = False kws = self.options.keywords -if kws is not None and PYTHON3: +if kws is not None: kws = kws.encode('utf-8') suite = TestSuite( To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12246: import-checker: assume absolute and use modern import checker
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Since we require Python 3 now, we can assume we always use absolute imports and the modern import checker should be used. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12246 AFFECTED FILES contrib/import-checker.py CHANGE DETAILS diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -58,21 +58,6 @@ } -def usingabsolute(root): -"""Whether absolute imports are being used.""" -if sys.version_info[0] >= 3: -return True - -for node in ast.walk(root): -if isinstance(node, ast.ImportFrom): -if node.module == '__future__': -for n in node.names: -if n.name == 'absolute_import': -return True - -return False - - def walklocal(root): """Recursively yield all descendant nodes but not in a different scope""" todo = collections.deque(ast.iter_child_nodes(root)) @@ -402,21 +387,10 @@ def verify_import_convention(module, source, localmods): -"""Verify imports match our established coding convention. - -We have 2 conventions: legacy and modern. The modern convention is in -effect when using absolute imports. +"""Verify imports match our established coding convention.""" +root = ast.parse(source) -The legacy convention only looks for mixed imports. The modern convention -is much more thorough. -""" -root = ast.parse(source) -absolute = usingabsolute(root) - -if absolute: -return verify_modern_convention(module, root, localmods) -else: -return verify_stdlib_on_own_line(root) +return verify_modern_convention(module, root, localmods) def verify_modern_convention(module, root, localmods, root_col_offset=0): @@ -617,33 +591,6 @@ ) -def verify_stdlib_on_own_line(root): -"""Given some python source, verify that stdlib imports are done -in separate statements from relative local module imports. - ->>> list(verify_stdlib_on_own_line(ast.parse('import sys, foo'))) -[('mixed imports\\n stdlib:sys\\n relative: foo', 1)] ->>> list(verify_stdlib_on_own_line(ast.parse('import sys, os'))) -[] ->>> list(verify_stdlib_on_own_line(ast.parse('import foo, bar'))) -[] -""" -for node in ast.walk(root): -if isinstance(node, ast.Import): -from_stdlib = {False: [], True: []} -for n in node.names: -from_stdlib[n.name in stdlib_modules].append(n.name) -if from_stdlib[True] and from_stdlib[False]: -yield ( -'mixed imports\n stdlib:%s\n relative: %s' -% ( -', '.join(sorted(from_stdlib[True])), -', '.join(sorted(from_stdlib[False])), -), -node.lineno, -) - - class CircularImport(Exception): pass To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12247: pycompat: remove first not ispy3 block
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We now require Python 3. So we can remove the first block supporting Python 2. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12247 AFFECTED FILES mercurial/pycompat.py CHANGE DETAILS diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -10,13 +10,20 @@ from __future__ import absolute_import +import builtins +import concurrent.futures as futures import getopt +import http.client as httplib +import http.cookiejar as cookielib import inspect import json import os +import queue import shlex +import socketserver import sys import tempfile +import xmlrpc.client as xmlrpclib ispy3 = sys.version_info[0] >= 3 ispypy = '__pypy__' in sys.builtin_module_names @@ -27,36 +34,12 @@ TYPE_CHECKING = typing.TYPE_CHECKING -if not ispy3: -import cookielib -import cPickle as pickle -import httplib -import Queue as queue -import SocketServer as socketserver -import xmlrpclib - -from .thirdparty.concurrent import futures - -def future_set_exception_info(f, exc_info): -f.set_exception_info(*exc_info) -# this is close enough for our usage -FileNotFoundError = OSError +def future_set_exception_info(f, exc_info): +f.set_exception(exc_info[0]) -else: -import builtins -import concurrent.futures as futures -import http.cookiejar as cookielib -import http.client as httplib -import pickle -import queue as queue -import socketserver -import xmlrpc.client as xmlrpclib -def future_set_exception_info(f, exc_info): -f.set_exception(exc_info[0]) - -FileNotFoundError = builtins.FileNotFoundError +FileNotFoundError = builtins.FileNotFoundError def identity(a): To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12251: check-py3-compat: drop support for Python 2
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We no longer support Python 2 so we can drop support for linting code for Python 2 support. This gets rid of the check for `from __future__`, enabling us to delete those imports. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12251 AFFECTED FILES contrib/check-py3-compat.py CHANGE DETAILS diff --git a/contrib/check-py3-compat.py b/contrib/check-py3-compat.py --- a/contrib/check-py3-compat.py +++ b/contrib/check-py3-compat.py @@ -17,31 +17,6 @@ import warnings -def check_compat_py2(f): -"""Check Python 3 compatibility for a file with Python 2""" -with open(f, 'rb') as fh: -content = fh.read() -root = ast.parse(content) - -# Ignore empty files. -if not root.body: -return - -futures = set() -haveprint = False -for node in ast.walk(root): -if isinstance(node, ast.ImportFrom): -if node.module == '__future__': -futures |= {n.name for n in node.names} -elif isinstance(node, ast.Print): -haveprint = True - -if 'absolute_import' not in futures: -print('%s not using absolute_import' % f) -if haveprint and 'print_function' not in futures: -print('%s requires print_function' % f) - - def check_compat_py3(f): """Check Python 3 compatibility of a file with Python 3.""" with open(f, 'rb') as fh: @@ -94,23 +69,19 @@ if __name__ == '__main__': -if sys.version_info[0] == 2: -fn = check_compat_py2 -else: -# check_compat_py3 will import every filename we specify as long as it -# starts with one of a few prefixes. It does this by converting -# specified filenames like 'mercurial/foo.py' to 'mercurial.foo' and -# importing that. When running standalone (not as part of a test), this -# means we actually import the installed versions, not the files we just -# specified. When running as test-check-py3-compat.t, we technically -# would import the correct paths, but it's cleaner to have both cases -# use the same import logic. -sys.path.insert(0, '.') -fn = check_compat_py3 +# check_compat_py3 will import every filename we specify as long as it +# starts with one of a few prefixes. It does this by converting +# specified filenames like 'mercurial/foo.py' to 'mercurial.foo' and +# importing that. When running standalone (not as part of a test), this +# means we actually import the installed versions, not the files we just +# specified. When running as test-check-py3-compat.t, we technically +# would import the correct paths, but it's cleaner to have both cases +# use the same import logic. +sys.path.insert(0, '.') for f in sys.argv[1:]: with warnings.catch_warnings(record=True) as warns: -fn(f) +check_compat_py3(f) for w in warns: print( To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12250: pycompat: remove large Python 2 block
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We no longer support Python 2. So we can delete its compatibility code and remove the conditional and dedent the Python 3 code. In order to make the linter happy, we had to inline imports in the stanza at the top of the file. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12250 AFFECTED FILES mercurial/pycompat.py CHANGE DETAILS diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -11,20 +11,25 @@ from __future__ import absolute_import import builtins +import codecs import concurrent.futures as futures +import functools import getopt import http.client as httplib import http.cookiejar as cookielib import inspect +import io import json import os import queue import shlex import socketserver +import struct import sys import tempfile import xmlrpc.client as xmlrpclib + ispy3 = sys.version_info[0] >= 3 ispypy = '__pypy__' in sys.builtin_module_names TYPE_CHECKING = False @@ -81,401 +86,339 @@ return _rapply(f, xs) -if ispy3: -import builtins -import codecs -import functools -import io -import struct - -if os.name == r'nt' and sys.version_info >= (3, 6): -# MBCS (or ANSI) filesystem encoding must be used as before. -# Otherwise non-ASCII filenames in existing repositories would be -# corrupted. -# This must be set once prior to any fsencode/fsdecode calls. -sys._enablelegacywindowsfsencoding() # pytype: disable=module-attr +if os.name == r'nt' and sys.version_info >= (3, 6): +# MBCS (or ANSI) filesystem encoding must be used as before. +# Otherwise non-ASCII filenames in existing repositories would be +# corrupted. +# This must be set once prior to any fsencode/fsdecode calls. +sys._enablelegacywindowsfsencoding() # pytype: disable=module-attr -fsencode = os.fsencode -fsdecode = os.fsdecode -oscurdir = os.curdir.encode('ascii') -oslinesep = os.linesep.encode('ascii') -osname = os.name.encode('ascii') -ospathsep = os.pathsep.encode('ascii') -ospardir = os.pardir.encode('ascii') -ossep = os.sep.encode('ascii') -osaltsep = os.altsep -if osaltsep: -osaltsep = osaltsep.encode('ascii') -osdevnull = os.devnull.encode('ascii') +fsencode = os.fsencode +fsdecode = os.fsdecode +oscurdir = os.curdir.encode('ascii') +oslinesep = os.linesep.encode('ascii') +osname = os.name.encode('ascii') +ospathsep = os.pathsep.encode('ascii') +ospardir = os.pardir.encode('ascii') +ossep = os.sep.encode('ascii') +osaltsep = os.altsep +if osaltsep: +osaltsep = osaltsep.encode('ascii') +osdevnull = os.devnull.encode('ascii') -sysplatform = sys.platform.encode('ascii') -sysexecutable = sys.executable -if sysexecutable: -sysexecutable = os.fsencode(sysexecutable) -bytesio = io.BytesIO -# TODO deprecate stringio name, as it is a lie on Python 3. -stringio = bytesio +sysplatform = sys.platform.encode('ascii') +sysexecutable = sys.executable +if sysexecutable: +sysexecutable = os.fsencode(sysexecutable) +bytesio = io.BytesIO +# TODO deprecate stringio name, as it is a lie on Python 3. +stringio = bytesio -def maplist(*args): -return list(map(*args)) + +def maplist(*args): +return list(map(*args)) -def rangelist(*args): -return list(range(*args)) + +def rangelist(*args): +return list(range(*args)) -def ziplist(*args): -return list(zip(*args)) + +def ziplist(*args): +return list(zip(*args)) + -rawinput = input -getargspec = inspect.getfullargspec +rawinput = input +getargspec = inspect.getfullargspec -long = int +long = int -if getattr(sys, 'argv', None) is not None: -# On POSIX, the char** argv array is converted to Python str using -# Py_DecodeLocale(). The inverse of this is Py_EncodeLocale(), which -# isn't directly callable from Python code. In practice, os.fsencode() -# can be used instead (this is recommended by Python's documentation -# for sys.argv). -# -# On Windows, the wchar_t **argv is passed into the interpreter as-is. -# Like POSIX, we need to emulate what Py_EncodeLocale() would do. But -# there's an additional wrinkle. What we really want to access is the -# ANSI codepage representation of the arguments, as this is what -# `int main()` would receive if Python 3 didn't define `int wmain()` -# (this is how Python 2 worked). To get that, we encode with the mbcs -# encoding, which will pass CP_ACP to the underlying Windows API to -# produce bytes. -if os.name == r'nt': -sysargv = [a.encode("mbcs", "ignore") for a in sys.argv] -else: -sysargv
D12248: thirdparty: delete concurrent.futures
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Now that we require Python 3 we no longer need this library as the functionality provided by the standard library is sufficient. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12248 AFFECTED FILES mercurial/thirdparty/concurrent/LICENSE mercurial/thirdparty/concurrent/__init__.py mercurial/thirdparty/concurrent/futures/__init__.py mercurial/thirdparty/concurrent/futures/_base.py mercurial/thirdparty/concurrent/futures/process.py mercurial/thirdparty/concurrent/futures/thread.py setup.py CHANGE DETAILS diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1336,13 +1336,6 @@ ): packages.append('mercurial.templates.%s' % name) -if sys.version_info[0] == 2: -packages.extend( -[ -'mercurial.thirdparty.concurrent', -'mercurial.thirdparty.concurrent.futures', -] -) if 'HG_PY2EXE_EXTRA_INSTALL_PACKAGES' in os.environ: # py2exe can't cope with namespace packages very well, so we have to diff --git a/mercurial/thirdparty/concurrent/futures/thread.py b/mercurial/thirdparty/concurrent/futures/thread.py deleted file mode 100644 --- a/mercurial/thirdparty/concurrent/futures/thread.py +++ /dev/null @@ -1,162 +0,0 @@ -# Copyright 2009 Brian Quinlan. All Rights Reserved. -# Licensed to PSF under a Contributor Agreement. - -"""Implements ThreadPoolExecutor.""" - -from __future__ import absolute_import - -import atexit -from . import _base -import itertools -import Queue as queue -import threading -import weakref -import sys - -try: -from multiprocessing import cpu_count -except ImportError: -# some platforms don't have multiprocessing -def cpu_count(): -return None - -__author__ = 'Brian Quinlan (br...@sweetapp.com)' - -# Workers are created as daemon threads. This is done to allow the interpreter -# to exit when there are still idle threads in a ThreadPoolExecutor's thread -# pool (i.e. shutdown() was not called). However, allowing workers to die with -# the interpreter has two undesirable properties: -# - The workers would still be running during interpretor shutdown, -# meaning that they would fail in unpredictable ways. -# - The workers could be killed while evaluating a work item, which could -# be bad if the callable being evaluated has external side-effects e.g. -# writing to a file. -# -# To work around this problem, an exit handler is installed which tells the -# workers to exit when their work queues are empty and then waits until the -# threads finish. - -_threads_queues = weakref.WeakKeyDictionary() -_shutdown = False - -def _python_exit(): -global _shutdown -_shutdown = True -items = list(_threads_queues.items()) if _threads_queues else () -for t, q in items: -q.put(None) -for t, q in items: -t.join(sys.maxint) - -atexit.register(_python_exit) - -class _WorkItem(object): -def __init__(self, future, fn, args, kwargs): -self.future = future -self.fn = fn -self.args = args -self.kwargs = kwargs - -def run(self): -if not self.future.set_running_or_notify_cancel(): -return - -try: -result = self.fn(*self.args, **self.kwargs) -except: -e, tb = sys.exc_info()[1:] -self.future.set_exception_info(e, tb) -else: -self.future.set_result(result) - -def _worker(executor_reference, work_queue): -try: -while True: -work_item = work_queue.get(block=True) -if work_item is not None: -work_item.run() -# Delete references to object. See issue16284 -del work_item -continue -executor = executor_reference() -# Exit if: -# - The interpreter is shutting down OR -# - The executor that owns the worker has been collected OR -# - The executor that owns the worker has been shutdown. -if _shutdown or executor is None or executor._shutdown: -# Notice other workers -work_queue.put(None) -return -del executor -except: -_base.LOGGER.critical('Exception in worker', exc_info=True) - - -class ThreadPoolExecutor(_base.Executor): - -# Used to assign unique thread names when thread_name_prefix is not supplied. -_counter = itertools.count().next - -def __init__(self, max_workers=None, thread_name_prefix=''): -"""Initializes a new ThreadPoolExecutor instance. - -Args: -max_workers: The maximum number of threads that can be used to -execute the given calls. -thread_name_prefix: An optional name prefix to give our threads. -""" -if max_worke
D12254: py2: remove simple from __future__ statements
indygreg created this revision. Herald added a reviewer: durin42. Herald added a reviewer: durin42. Herald added a reviewer: martinvonz. Herald added a reviewer: martinvonz. Herald added subscribers: mercurial-patches, Kwan. Herald added a reviewer: hg-reviewers. REVISION SUMMARY These were needed for Python 2 support. Now that our linter no longer mandates these, we can start deleting them. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12254 AFFECTED FILES contrib/bdiff-torture.py contrib/benchmarks/__init__.py contrib/benchmarks/perf.py contrib/benchmarks/revset.py contrib/byteify-strings.py contrib/casesmash.py contrib/catapipe.py contrib/check-code.py contrib/check-commit contrib/check-config.py contrib/check-py3-compat.py contrib/debugcmdserver.py contrib/debugshell.py contrib/dumprevlog contrib/fuzz/dirs_corpus.py contrib/fuzz/dirstate_corpus.py contrib/fuzz/fm1readmarkers_corpus.py contrib/fuzz/manifest_corpus.py contrib/fuzz/mpatch_corpus.py contrib/fuzz/revlog_corpus.py contrib/genosxversion.py contrib/hg-ssh contrib/hgclient.py contrib/import-checker.py contrib/memory.py contrib/perf-utils/perf-revlog-write-plot.py contrib/perf-utils/search-discovery-case contrib/perf.py contrib/phab-clean.py contrib/python-hook-examples.py contrib/python-zstandard/make_cffi.py contrib/python-zstandard/setup.py contrib/python-zstandard/tests/test_module_attributes.py contrib/python-zstandard/zstandard/__init__.py contrib/python-zstandard/zstandard/cffi.py contrib/python3-ratchet.py contrib/revsetbenchmarks.py contrib/showstack.py contrib/simplemerge contrib/synthrepo.py contrib/testparseutil.py contrib/undumprevlog contrib/win32/hgwebdir_wsgi.py doc/check-seclevel.py doc/docchecker doc/gendoc.py doc/hgmanpage.py doc/runrst hg hgdemandimport/__init__.py hgdemandimport/demandimportpy2.py hgdemandimport/demandimportpy3.py hgdemandimport/tracing.py hgext/__init__.py hgext/absorb.py hgext/acl.py hgext/amend.py hgext/automv.py hgext/beautifygraph.py hgext/blackbox.py hgext/bookflow.py hgext/bugzilla.py hgext/censor.py hgext/children.py hgext/churn.py hgext/clonebundles.py hgext/closehead.py hgext/commitextras.py hgext/convert/__init__.py hgext/convert/bzr.py hgext/convert/common.py hgext/convert/convcmd.py hgext/convert/cvs.py hgext/convert/cvsps.py hgext/convert/darcs.py hgext/convert/filemap.py hgext/convert/git.py hgext/convert/gnuarch.py hgext/convert/hg.py hgext/convert/monotone.py hgext/convert/p4.py hgext/convert/subversion.py hgext/convert/transport.py hgext/eol.py hgext/extdiff.py hgext/factotum.py hgext/fastannotate/__init__.py hgext/fastannotate/commands.py hgext/fastannotate/context.py hgext/fastannotate/error.py hgext/fastannotate/formatter.py hgext/fastannotate/protocol.py hgext/fastannotate/revmap.py hgext/fastannotate/support.py hgext/fastexport.py hgext/fetch.py hgext/fix.py hgext/fsmonitor/__init__.py hgext/fsmonitor/pywatchman/__init__.py hgext/fsmonitor/pywatchman/capabilities.py hgext/fsmonitor/pywatchman/compat.py hgext/fsmonitor/pywatchman/encoding.py hgext/fsmonitor/pywatchman/load.py hgext/fsmonitor/pywatchman/pybser.py hgext/fsmonitor/state.py hgext/fsmonitor/watchmanclient.py hgext/git/__init__.py hgext/git/dirstate.py hgext/git/gitlog.py hgext/git/gitutil.py hgext/git/index.py hgext/git/manifest.py hgext/githelp.py hgext/gpg.py hgext/graphlog.py hgext/hgk.py hgext/highlight/__init__.py hgext/highlight/highlight.py hgext/histedit.py hgext/hooklib/__init__.py hgext/hooklib/changeset_obsoleted.py hgext/hooklib/changeset_published.py hgext/hooklib/enforce_draft_commits.py hgext/hooklib/reject_merge_commits.py hgext/hooklib/reject_new_heads.py hgext/infinitepush/__init__.py hgext/infinitepush/bundleparts.py hgext/infinitepush/common.py hgext/infinitepush/fileindexapi.py hgext/infinitepush/indexapi.py hgext/infinitepush/sqlindexapi.py hgext/infinitepush/store.py hgext/journal.py hgext/keyword.py hgext/largefiles/__init__.py hgext/largefiles/basestore.py hgext/largefiles/lfcommands.py hgext/largefiles/lfutil.py hgext/largefiles/localstore.py hgext/largefiles/overrides.py hgext/largefiles/proto.py hgext/largefiles/remotestore.py hgext/largefiles/reposetup.py hgext/largefiles/storefactory.py hgext/largefiles/wirestore.py hgext/lfs/__init__.py hgext/lfs/blobstore.py hgext/lfs/pointer.py hgext/lfs/wireprotolfsserver.py hgext/lfs/wrapper.py hgext/logtoprocess.py hgext/mq.py hgext/narrow/__init__.py hgext/narrow/narrowbundle2.py hgext/narrow/narrowcommands.py hgext/narrow/narrowdirstate.py hgext/narrow/narrowrepo.py hgext/narrow/narrowtemplates.py hgext/narrow/narrowwirepeer.py hgext/notify.py hgext/pager.py hgext/patchbomb.py h
D12252: py3: use io.BytesIO directly
indygreg created this revision. Herald added subscribers: mercurial-patches, Kwan. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Previously, pycompat.bytesio and pycompat.stringio referred to io.BytesIO. And util.bytesio and util.stringio aliased the pycompat symbols. This commit switches everything to use io.BytesIO directly. util.bytesio and util.stringio still exist to provide backwards compatibility, as they were the preferred symbols. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12252 AFFECTED FILES hgext/phabricator.py mercurial/pure/mpatch.py mercurial/pure/parsers.py mercurial/pycompat.py mercurial/util.py tests/test-basic.t tests/test-util.py CHANGE DETAILS diff --git a/tests/test-util.py b/tests/test-util.py --- a/tests/test-util.py +++ b/tests/test-util.py @@ -2,6 +2,7 @@ from __future__ import absolute_import import contextlib +import io import itertools import unittest @@ -55,7 +56,7 @@ @contextlib.contextmanager def capturestderr(): -"""Replace utils.procutil.stderr with a pycompat.bytesio instance +"""Replace utils.procutil.stderr with an io.BytesIO instance The instance is made available as the return value of __enter__. @@ -63,7 +64,7 @@ """ orig = utils.procutil.stderr -utils.procutil.stderr = pycompat.bytesio() +utils.procutil.stderr = io.BytesIO() try: yield utils.procutil.stderr finally: diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -240,15 +240,16 @@ Underlying message streams should be updated when ui.fout/ferr are set: $ cat <<'EOF' > capui.py - > from mercurial import pycompat, registrar + > import io + > from mercurial import registrar > cmdtable = {} > command = registrar.command(cmdtable) > @command(b'capui', norepo=True) > def capui(ui): > out = ui.fout - > ui.fout = pycompat.bytesio() + > ui.fout = io.BytesIO() > ui.status(b'status\n') - > ui.ferr = pycompat.bytesio() + > ui.ferr = io.BytesIO() > ui.warn(b'warn\n') > out.write(b'stdout: %s' % ui.fout.getvalue()) > out.write(b'stderr: %s' % ui.ferr.getvalue()) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -21,6 +21,7 @@ import errno import gc import hashlib +import io import itertools import locale import mmap @@ -79,7 +80,7 @@ httplib = pycompat.httplib safehasattr = pycompat.safehasattr socketserver = pycompat.socketserver -bytesio = pycompat.bytesio +bytesio = io.BytesIO # TODO deprecate stringio name, as it is a lie on Python 3. stringio = bytesio xmlrpclib = pycompat.xmlrpclib diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -110,9 +110,6 @@ sysexecutable = sys.executable if sysexecutable: sysexecutable = os.fsencode(sysexecutable) -bytesio = io.BytesIO -# TODO deprecate stringio name, as it is a lie on Python 3. -stringio = bytesio def maplist(*args): diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -7,6 +7,7 @@ from __future__ import absolute_import +import io import stat import struct import zlib @@ -26,7 +27,7 @@ from ..revlogutils import nodemap as nodemaputil from ..revlogutils import constants as revlog_constants -stringio = pycompat.bytesio +stringio = io.BytesIO _pack = struct.pack diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py --- a/mercurial/pure/mpatch.py +++ b/mercurial/pure/mpatch.py @@ -7,11 +7,11 @@ from __future__ import absolute_import +import io import struct -from .. import pycompat -stringio = pycompat.bytesio +stringio = io.BytesIO class mpatchError(Exception): diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -62,6 +62,7 @@ import base64 import contextlib import hashlib +import io import itertools import json import mimetypes @@ -2200,7 +2201,7 @@ for drev, contents in patches: ui.status(_(b'applying patch from D%s\n') % drev) -with patch.extract(ui, pycompat.bytesio(contents)) as patchdata: +with patch.extract(ui, io.BytesIO(contents)) as patchdata: msg, node, rej = cmdutil.tryimportone( ui, repo, To: indygreg, #hg-reviewers Cc: Kwan, mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12256: tests: remove __future__ import from test-debugcommands.t
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This one is slightly more involved since it affects test output. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12256 AFFECTED FILES tests/test-debugcommands.t CHANGE DETAILS diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t --- a/tests/test-debugcommands.t +++ b/tests/test-debugcommands.t @@ -570,7 +570,6 @@ Test internal debugstacktrace command $ cat > debugstacktrace.py << EOF - > from __future__ import absolute_import > from mercurial import ( > util, > ) @@ -589,15 +588,15 @@ > EOF $ "$PYTHON" debugstacktrace.py stacktrace at: - *debugstacktrace.py:16 in * (glob) - *debugstacktrace.py:9 in f (glob) + *debugstacktrace.py:15 in * (glob) + *debugstacktrace.py:8 in f (glob) hello from g at: - *debugstacktrace.py:16 in * (glob) - *debugstacktrace.py:10 in f (glob) + *debugstacktrace.py:15 in * (glob) + *debugstacktrace.py:9 in f (glob) hi ... from h hidden in g at: - *debugstacktrace.py:10 in f (glob) - *debugstacktrace.py:13 in g (glob) + *debugstacktrace.py:9 in f (glob) + *debugstacktrace.py:12 in g (glob) Test debugcapabilities command: To: indygreg, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D12257: tests: delete some no-py3 blocks
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY And drop some nearby avoidable py3 checks in close proximity while we are here. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12257 AFFECTED FILES tests/test-archive.t tests/test-check-py3-compat.t tests/test-extension.t tests/test-subrepo-git.t CHANGE DETAILS diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t --- a/tests/test-subrepo-git.t +++ b/tests/test-subrepo-git.t @@ -1,20 +1,5 @@ #require git -# XXX-CHG When running with python2 + chg this test tend to get stuck and end up -# as a time-out error. My effort to reproduce this outside of the CI failed. The -# test itself seems to pass fine, but never "complete". Debugging it is slow and -# tedious. This as a bad impact on the development process as most CI run end up -# wasting abotu 1h until that one fails. -# -# Pierre-Yves David, Augie Fackler and Raphaël Gomès all agreed to disable this -# case in that specific case until we figure this out (or we drop python2 o:-) ) - -#if no-py3 chg - $ echo 'skipped: this test get stuck on the CI with python2 + chg. investigation needed' - $ exit 80 -#endif - - make git commits repeatable $ cat >> $HGRCPATH < $TESTTMP/libroot/mod/ambigrel.py < import ambig # should load "libroot/mod/ambig.py" - > s = ambig.s - > NO_CHECK_EOF - $ cat > loadrel.py < import mod.ambigrel as ambigrel - > def extsetup(ui): - > print('ambigrel.s=%s' % ambigrel.s, flush=True) - > NO_CHECK_EOF - $ "$PYTHON" $TESTTMP/unflush.py loadrel.py - $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root) - ambigrel.s=libroot/mod/ambig.py - $TESTTMP/a -#endif - Check absolute/relative import of extension specific modules $ mkdir $TESTTMP/extroot @@ -373,39 +357,6 @@ (extroot) import extroot.bar in func(): this is extroot.bar $TESTTMP/a -#if no-py3 - $ rm "$TESTTMP"/extroot/foo.* - $ rm -Rf "$TESTTMP/extroot/__pycache__" - $ cat > $TESTTMP/extroot/foo.py < # test relative import - > buf = [] - > def func(): - > # "not locals" case - > import bar - > buf.append('import bar in func(): %s' % bar.s) - > return '\n(extroot) '.join(buf) - > # "fromlist == ('*',)" case - > from bar import * - > buf.append('from bar import *: %s' % s) - > # "not fromlist" and "if '.' in name" case - > import sub1.baz - > buf.append('import sub1.baz: %s' % sub1.baz.s) - > # "not fromlist" and NOT "if '.' in name" case - > import sub1 - > buf.append('import sub1: %s' % sub1.s) - > # NOT "not fromlist" and NOT "level != -1" case - > from bar import s - > buf.append('from bar import s: %s' % s) - > NO_CHECK_EOF - $ hg --config extensions.extroot=$TESTTMP/extroot root - (extroot) from bar import *: this is extroot.bar - (extroot) import sub1.baz: this is extroot.sub1.baz - (extroot) import sub1: this is extroot.sub1.__init__ - (extroot) from bar import s: this is extroot.bar - (extroot) import bar in func(): this is extroot.bar - $TESTTMP/a -#endif - #if demandimport Examine whether module loading is delayed until actual referring, even 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 @@ -3,33 +3,6 @@ $ . "$TESTDIR/helpers-testrepo.sh" $ cd "$TESTDIR"/.. -#if no-py3 - $ testrepohg files 'set:(**.py)' \ - > -X contrib/automation/ \ - > -X contrib/packaging/hgpackaging/ \ - > -X contrib/packaging/inno/ \ - > -X contrib/packaging/packaging.py \ - > -X contrib/packaging/wix/ \ - > -X hgdemandimport/demandimportpy2.py \ - > -X mercurial/thirdparty/cbor \ - > | sed 's|\\|/|g' | xargs "$PYTHON" contrib/check-py3-compat.py - contrib/python-zstandard/setup.py not using absolute_import - contrib/python-zstandard/setup_zstd.py not using absolute_import - contrib/python-zstandard/tests/common.py not using absolute_import - contrib/python-zstandard/tests/test_buffer_util.py not using absolute_import - contrib/python-zstandard/tests/test_compressor.py not using absolute_import - contrib/python-zstandard/tests/test_compressor_fuzzing.py not using absolute_import - contrib/python-zstandard/tests/test_data_structures.py not using absolute_import - contrib/python-zstandard/tests/test_data_structures_fuzzing.py not using absolute_import - contrib/python-zstandard/tests/test_decompressor.py not using absolute_import - contrib/python-zstandard/tests/test_decompressor_fuzzing.py not using absolute_import - contrib/python-zstandard/tests/test_estimate_sizes.py not using absolute_import - contrib/python-zstandard/tests/test_module_attributes.py not using absolute_import - contrib/python-zstandard/tests/test_train_dictionary.py not using absolute_import - setup.py not using absolute_import -#endif - -#if py3 $ tes
D12249: py3: use pickle directly
indygreg created this revision. Herald added a reviewer: durin42. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY pycompat.pickle abstracted over the different pickle modules in Python 2 and 3. Now that we're Python 3 only, it is safe to use the `pickle` module directly. So this commit does that. As part of this we remove the rules from check-code.py that were forbidden direct pickle module use. We retain the `util.pickle` symbol for backwards compatibility, just in case some extensions were using it. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12249 AFFECTED FILES contrib/check-code.py hgext/convert/common.py hgext/convert/cvsps.py hgext/convert/subversion.py hgext/histedit.py mercurial/formatter.py mercurial/util.py mercurial/worker.py tests/test-status.t tests/test-stdio.py CHANGE DETAILS 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") 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/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 @@ -255,7 +256,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 +292,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/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -25,6 +25,7 @@ import locale import mmap import os +import pickle import platform as pyplatform import re as remod import shutil @@ -76,7 +77,6 @@ cookielib = pycompat.cookielib httplib = pycompat.httplib -pickle = pycompat.pickle safehasattr = pycompat.safehasattr socketserver = pycompat.socketserver bytesio = pycompat.bytesio 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/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/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/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/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -10,6 +10,7 @@ im
D12253: tests: remove output conditionalized on no-py3
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY I simply did a search for `^.* \(no-py3 !\)\n` and removed all matched lines. There are still some references to no-py3. But these were the simpler ones to match against. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12253 AFFECTED FILES tests/test-bad-extension.t tests/test-contrib-perf.t tests/test-debugcommands.t tests/test-extension.t tests/test-flagprocessor.t tests/test-hook.t tests/test-http-bad-server.t tests/test-install.t tests/test-lfs-serve-access.t tests/test-notify.t tests/test-patchbomb.t tests/test-remotefilelog-corrupt-cache.t tests/test-run-tests.t tests/test-ssh.t tests/test-upgrade-repo.t tests/test-worker.t CHANGE DETAILS diff --git a/tests/test-worker.t b/tests/test-worker.t --- a/tests/test-worker.t +++ b/tests/test-worker.t @@ -88,9 +88,7 @@ > test 10.0 abort --traceback 2>&1 | egrep '(WorkerError|Abort)' raise error.Abort(b'known exception') mercurial.error.Abort: known exception (py3 !) - Abort: known exception (no-py3 !) raise error.WorkerError(status) - WorkerError: 255 (no-py3 !) mercurial.error.WorkerError: 255 (py3 !) Traceback must be printed for unknown exceptions diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t --- a/tests/test-upgrade-repo.t +++ b/tests/test-upgrade-repo.t @@ -958,7 +958,6 @@ Check that the repo still works fine $ hg log -G --stat - @ changeset: 2:76d4395f5413 (no-py3 !) @ changeset: 2:fca376863211 (py3 !) | tag: tip | parent: 0:ba592bf28da2 diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -326,7 +326,6 @@ remote: added 1 changesets with 1 changes to 1 files (py3 !) remote: KABOOM remote: KABOOM IN PROCESS - remote: added 1 changesets with 1 changes to 1 files (no-py3 !) #endif diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -2086,5 +2086,4 @@ $ ./test-py3.py 3.* (glob) $ ./test-py.py - 2.* (glob) (no-py3 !) 3.* (glob) (py3 !) diff --git a/tests/test-remotefilelog-corrupt-cache.t b/tests/test-remotefilelog-corrupt-cache.t --- a/tests/test-remotefilelog-corrupt-cache.t +++ b/tests/test-remotefilelog-corrupt-cache.t @@ -38,7 +38,6 @@ $ chmod u+w $CACHEDIR/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 $ echo x > $CACHEDIR/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1406e74118627694268417491f018a4a883152f0 $ hg up tip 2>&1 | egrep "^[^ ].*unexpected remotefilelog" - abort: unexpected remotefilelog header: illegal format (no-py3 !) hgext.remotefilelog.shallowutil.BadRemotefilelogHeader: unexpected remotefilelog header: illegal format (py3 !) Verify detection and remediation when remotefilelog.validatecachelog is set diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t --- a/tests/test-patchbomb.t +++ b/tests/test-patchbomb.t @@ -514,7 +514,6 @@ X-Mercurial-Series-Id: User-Agent: Mercurial-patchbomb/* (glob) Date: Thu, 01 Jan 1970 00:04:00 + - From: Q (no-py3 !) From: =?iso-8859-1?q?Q?= (py3 !) To: foo Cc: bar @@ -2400,9 +2399,6 @@ User-Agent: Mercurial-patchbomb/* (glob) Date: Tue, 01 Jan 1980 00:01:00 + From: quux - To: spam , eggs, toast (no-py3 !) - Cc: foo, b...@example.com, "A, B <>" (no-py3 !) - Bcc: "Quux, A." (no-py3 !) To: =?iso-8859-1?q?spam?= , eggs, toast (py3 !) Cc: foo, b...@example.com, =?iso-8859-1?q?A=2C_B_=3C=3E?= (py3 !) Bcc: =?iso-8859-1?q?Quux=2C_A=2E?= (py3 !) @@ -2722,7 +2718,6 @@ MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable - Subject: [PATCH 2 of 6] \xe7a (esc) (no-py3 !) Subject: =?utf-8?b?W1BBVENIIDIgb2YgNl0gw6dh?= (py3 !) X-Mercurial-Node: f81ef97829467e868fc405fccbcfa66217e4d3e6 X-Mercurial-Series-Index: 2 diff --git a/tests/test-notify.t b/tests/test-notify.t --- a/tests/test-notify.t +++ b/tests/test-notify.t @@ -469,7 +469,6 @@ Content-Transfer-Encoding: 8bit X-Test: foo Date: * (glob) - Subject: \xc3\xa0... (esc) (no-py3 !) Subject: =?utf-8?b?w6AuLi4=?= (py3 !) From: t...@test.com X-Hg-Notification: changeset 0f25f9c22b4c diff --git a/tests/test-lfs-serve-access.t b/tests/test-lfs-serve-access.t --- a/tests/test-lfs-serve-access.t +++ b/tests/test-lfs-serve-access.t @@ -355,7 +355,6 @@ $LOCALIP - - [$ERRDATE$] HG error: super(badstore, self).download(oid, src, contentlength) $LOCALIP - - [$ERRDATE$] HG error: raise LfsCorruptionError( (glob) (py38 !) $LOCALIP - - [$ERRDATE$] HG error: _(b'corrupt remote lfs object: %s') % oid (glob) (no-py38 !) - $LOCALIP - - [$ERRDATE$] HG error: LfsCorruptionError: corrupt remot
D12258: py2: drop some more from __future__ statements
indygreg created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY These are no longer needed after dropping support for Python 2. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12258 AFFECTED FILES contrib/import-checker.py tests/test-commandserver.t tests/test-convert-git.t tests/test-generaldelta.t tests/test-hgrc.t tests/test-hgweb.t tests/test-keyword.t tests/test-lfs-serve.t tests/test-notify-changegroup.t tests/test-pull-network.t tests/test-rename.t tests/test-status.t tests/test-subrepo-svn.t tests/test-template-functions.t tests/test-unified-test.t tests/test-upgrade-repo.t CHANGE DETAILS diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t --- a/tests/test-upgrade-repo.t +++ b/tests/test-upgrade-repo.t @@ -734,7 +734,6 @@ $ touch FooBarDirectory.d/f1 $ hg -q commit -A -m 'add f1' $ hg -q up -r 0 - >>> from __future__ import absolute_import, print_function >>> import random >>> random.seed(0) # have a reproducible content >>> with open("f2", "wb") as f: diff --git a/tests/test-unified-test.t b/tests/test-unified-test.t --- a/tests/test-unified-test.t +++ b/tests/test-unified-test.t @@ -26,7 +26,6 @@ Doctest commands: - >>> from __future__ import print_function >>> print('foo') foo $ echo interleaved diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t --- a/tests/test-template-functions.t +++ b/tests/test-template-functions.t @@ -192,7 +192,6 @@ $ cd unstable-hash $ hg log --template '{date|age}\n' > /dev/null || exit 1 - >>> from __future__ import absolute_import >>> import datetime >>> fp = open('a', 'wb') >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7) diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t --- a/tests/test-subrepo-svn.t +++ b/tests/test-subrepo-svn.t @@ -249,7 +249,7 @@ verify subrepo is contained within the repo directory - $ "$PYTHON" -c "from __future__ import print_function; import os.path; print(os.path.exists('s'))" + $ "$PYTHON" -c "import os.path; print(os.path.exists('s'))" True update to nullrev (must delete the subrepo) diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -315,7 +315,6 @@ ] $ hg status -A -Tpickle > pickle - >>> from __future__ import print_function >>> import pickle >>> from mercurial import util >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb"))) diff --git a/tests/test-rename.t b/tests/test-rename.t --- a/tests/test-rename.t +++ b/tests/test-rename.t @@ -682,7 +682,6 @@ "hg cp" does not preserve the mtime, so it should be newer than the 2009 timestamp. $ hg cp -q mtime mtime_cp - >>> from __future__ import print_function >>> import os >>> filename = "mtime_cp/f" >>> print(os.stat(filename).st_mtime < 1234567999) @@ -691,7 +690,6 @@ (modulo some fudge factor due to not every system supporting 1s-level precision). $ hg mv -q mtime mtime_mv - >>> from __future__ import print_function >>> import os >>> filename = "mtime_mv/f" >>> print(os.stat(filename).st_mtime < 1234567999) diff --git a/tests/test-pull-network.t b/tests/test-pull-network.t --- a/tests/test-pull-network.t +++ b/tests/test-pull-network.t @@ -90,12 +90,12 @@ It's tricky to make file:// URLs working on every platform with regular shell commands. - $ URL=`"$PYTHON" -c "from __future__ import print_function; import os; print('file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"` + $ URL=`"$PYTHON" -c "import os; print('file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"` $ hg pull -q "$URL" abort: file:// URLs can only refer to localhost [255] - $ URL=`"$PYTHON" -c "from __future__ import print_function; import os; print('file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"` + $ URL=`"$PYTHON" -c "import os; print('file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"` $ hg pull -q "$URL" SEC: check for unsafe ssh url diff --git a/tests/test-notify-changegroup.t b/tests/test-notify-changegroup.t --- a/tests/test-notify-changegroup.t +++ b/tests/test-notify-changegroup.t @@ -40,7 +40,7 @@ $ hg --traceback --cwd b push ../a 2>&1 | > "$PYTHON" $TESTDIR/unwrap-message-id.py | \ - > "$PYTHON" -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")' + > "$PYTHON" -c 'import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")' pushing to ../a searching for changes adding changesets @@ -95,7 +95,7 @@ $ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2
D12255: tests: remove from __future__ from inline Python in tests
indygreg created this revision. Herald added a reviewer: durin42. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is no longer required since we require Python 3 and the linter no longer requires these statements. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12255 AFFECTED FILES tests/test-annotate.t tests/test-arbitraryfilectx.t tests/test-archive.t tests/test-bisect.t tests/test-blackbox.t tests/test-bookmarks.t tests/test-bugzilla.t tests/test-bundle.t tests/test-bundle2-pushback.t tests/test-check-help.t tests/test-chg.t tests/test-commit-interactive.t tests/test-commit.t tests/test-context-metadata.t tests/test-convert-clonebranches.t tests/test-dirstate.t tests/test-eol.t tests/test-extension.t tests/test-fastannotate-hg.t tests/test-filebranch.t tests/test-fncache.t tests/test-hardlinks.t tests/test-help.t tests/test-hgweb-no-path-info.t tests/test-hgweb-no-request-uri.t tests/test-hgweb-non-interactive.t tests/test-hook.t tests/test-impexp-branch.t tests/test-import.t tests/test-imports-checker.t tests/test-inherit-mode.t tests/test-largefiles-cache.t tests/test-largefiles-small-disk.t tests/test-log-exthook.t tests/test-log.t tests/test-logtoprocess.t tests/test-merge-symlinks.t tests/test-merge1.t tests/test-narrow-clone-non-narrow-server.t tests/test-notify.t tests/test-obsolete.t tests/test-pager.t tests/test-parseindex.t tests/test-patch.t tests/test-patchbomb.t tests/test-profile.t tests/test-progress.t tests/test-rebase-dest.t tests/test-rebase-scenario-global.t tests/test-relink.t tests/test-requires.t tests/test-revert.t tests/test-revlog-mmapindex.t tests/test-revset.t tests/test-share-bookmarks.t tests/test-ssh-proto-unbundle.t tests/test-strip.t tests/test-template-functions.t tests/test-template-map.t tests/test-update-atomic.t tests/test-verify.t tests/test-walk.t tests/test-worker.t CHANGE DETAILS diff --git a/tests/test-worker.t b/tests/test-worker.t --- a/tests/test-worker.t +++ b/tests/test-worker.t @@ -1,7 +1,6 @@ Test UI worker interaction $ cat > t.py < from __future__ import absolute_import, print_function > import sys > import time > from mercurial import ( @@ -100,7 +99,6 @@ Workers should not do cleanups in all cases $ cat > $TESTTMP/detectcleanup.py < from __future__ import absolute_import > import atexit > import os > import sys @@ -134,7 +132,6 @@ Do not crash on partially read result $ cat > $TESTTMP/detecttruncated.py < from __future__ import absolute_import > import os > import sys > import time diff --git a/tests/test-walk.t b/tests/test-walk.t --- a/tests/test-walk.t +++ b/tests/test-walk.t @@ -640,7 +640,6 @@ $ cd t $ echo fennel > overflow.list $ cat >> printnum.py < from __future__ import print_function > for i in range(2 // 100): > print('x' * 100) > EOF diff --git a/tests/test-verify.t b/tests/test-verify.t --- a/tests/test-verify.t +++ b/tests/test-verify.t @@ -338,7 +338,6 @@ checked 1 changesets with 1 changes to 1 files $ cat >> $TESTTMP/break-base64.py < from __future__ import absolute_import > import base64 > base64.b64decode=lambda x: x > EOF diff --git a/tests/test-update-atomic.t b/tests/test-update-atomic.t --- a/tests/test-update-atomic.t +++ b/tests/test-update-atomic.t @@ -3,7 +3,6 @@ Checking that experimental.atomic-file works. $ cat > $TESTTMP/show_mode.py < from __future__ import print_function > import os > import stat > import sys @@ -20,7 +19,6 @@ $ cd repo $ cat > .hg/showwrites.py < from __future__ import print_function > from mercurial import pycompat > from mercurial.utils import stringutil > def uisetup(ui): diff --git a/tests/test-template-map.t b/tests/test-template-map.t --- a/tests/test-template-map.t +++ b/tests/test-template-map.t @@ -722,7 +722,6 @@ test CBOR style: $ cat <<'EOF' > "$TESTTMP/decodecborarray.py" - > from __future__ import absolute_import > from mercurial import ( > dispatch, > ) diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t --- a/tests/test-template-functions.t +++ b/tests/test-template-functions.t @@ -1572,7 +1572,6 @@ Test cbor filter: $ cat <<'EOF' > "$TESTTMP/decodecbor.py" - > from __future__ import absolute_import > from mercurial import ( > dispatch, > ) diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -1290,7 +1290,6 @@ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo 3 >> I $ cat > $TESTTMP/delayedstrip.py < from __future__ import absolute_import > from mercurial import commands, registrar, repair > cmdtable = {} > command = registrar.command(cmdtable) diff --git a/tests/test-s
Re: pycompat.py strategy
On Tue, Mar 1, 2022 at 5:08 AM Joerg Sonnenberger wrote: > Am Tue, Mar 01, 2022 at 11:20:41AM +0100 schrieb Raphaël Gomès: > > > > On 2/22/22 23:06, Joerg Sonnenberger wrote: > > > Am Mon, Feb 21, 2022 at 11:47:36AM -0700 schrieb Gregory Szorc: > > > > Some options: > > > > > > > > a) Attempt to delete as much as pycompat.py as possible (leaving > only the > > > > pieces needed to abstract over differences in Python 3.5-3.x). > > > > b) Leave the ~complete API provided by pycompat.py and delete > pycompat > > > > usage within the repo as much as possible. > > > > c) Leave the ~complete API provided by pycompat.py and still use > pycompat > > > > heavily within the repo. > > > Personally, I'd prefer to start with (c) and gradually go to (b). > > Care to elaborate? :) > > We can start just nuking the non-py3 case in pycompat and then slowly > inline it in the rest of the tree. Ideally using a tool for the > mechnical part of it. > I think we're in general agreement here. I already have some patches authored to nuke the Python 2 code paths in pycompat.py as well as to start undoing some undesired patterns, such as pycompat.iteritems(x) -> .iteritems(x). I'll try to get them up on Phabricator tonight. FWIW Augie seems inclined to write the ceremonial patch to setup.py. Hopefully that will appear in <24 hours. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel