D12630: automation: transition to Windows Server 2022

2022-06-07 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Let's keep our Windows build environment modern by upgrading to the
  latest OS.
  
  As part of the upgrade, we pick up a migration to EC2Launch Version 2.
  This has a different config mechanism. So we need to port how we manage
  the administrator password.
  
  As part of migrating to the new YAML/JSON config file mechanism, we move
  the code to the powershell script that is run when the instance first
  launches. This ensures that the config is retained during the reboot we
  perform as part of building the Windows AMI.
  
  The motivation for this is I'm currently unable to build the Windows
  2019 AMI due to an issue installing OpenSSH. This _just works_ on
  Windows Server 2022. I have no clue what the root cause is. I think
  it might have something to do with Microsoft not publishing the files
  in the right location.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12630

AFFECTED FILES
  contrib/automation/hgautomation/aws.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/aws.py 
b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -59,7 +59,7 @@
 UBUNTU_ACCOUNT_ID = '099720109477'
 
 
-WINDOWS_BASE_IMAGE_NAME = 'Windows_Server-2019-English-Full-Base-*'
+WINDOWS_BASE_IMAGE_NAME = 'Windows_Server-2022-English-Full-Base-*'
 
 
 KEY_PAIRS = {
@@ -174,6 +174,23 @@
 net user Administrator "%s"
 wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE
 
+# And set it via EC2Launch so it persists across reboots.
+$config = & $env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe get-agent-config 
--format json | ConvertFrom-Json
+$config | ConvertTo-Json -Depth 6 | Out-File -encoding UTF8 
$env:ProgramData/Amazon/EC2Launch/config/agent-config.yml
+$setAdminAccount = @"
+{
+  "task": "setAdminAccount",
+  "inputs": {
+"password": {
+  "type": "static",
+  "data": "%s"
+}
+  }
+}
+"@
+$config.config | %%{if($_.stage -eq 'preReady'){$_.tasks += (ConvertFrom-Json 
-InputObject $setAdminAccount)}}
+$config | ConvertTo-Json -Depth 6 | Out-File -encoding UTF8 
$env:ProgramData/Amazon/EC2Launch/config/agent-config.yml
+
 # First, make sure WinRM can't be connected to
 netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" 
new enable=yes action=block
 
@@ -752,7 +769,7 @@
 )
 
 if bootstrap:
-config['UserData'] = WINDOWS_USER_DATA % password
+config['UserData'] = WINDOWS_USER_DATA % (password, password)
 
 with temporary_ec2_instances(c.ec2resource, config) as instances:
 wait_for_ip_addresses(instances)
@@ -1173,28 +1190,16 @@
 with INSTALL_WINDOWS_DEPENDENCIES.open('r', encoding='utf-8') as fh:
 commands.extend(l.rstrip() for l in fh)
 
-# Schedule run of EC2Launch on next boot. This ensures that UserData
-# is executed.
-# We disable setComputerName because it forces a reboot.
-# We set an explicit admin password because this causes UserData to run
-# as Administrator instead of System.
-commands.extend(
-[
-r'''Set-Content -Path 
C:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json '''
-r'''-Value '{"setComputerName": false, "setWallpaper": true, 
"addDnsSuffixList": true, '''
-r'''"extendBootVolumeSize": true, "handleUserData": true, '''
-r'''"adminPasswordType": "Specify", "adminPassword": "%s"}' '''
-% c.automation.default_password(),
-
r'C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 '
-r'–Schedule',
-]
-)
-
 # Disable Windows Defender when bootstrapping because it just slows
 # things down.
 commands.insert(0, 'Set-MpPreference -DisableRealtimeMonitoring $true')
 commands.append('Set-MpPreference -DisableRealtimeMonitoring $false')
 
+# Trigger shutdown to prepare for imaging.
+commands.append(
+'Stop-Computer -ComputerName localhost',
+)
+
 # Compute a deterministic fingerprint to determine whether image needs
 # to be regenerated.
 fingerprint = resolve_fingerprint(



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


D12629: automation: refresh requirements

2022-06-07 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I'm hitting errors installing the old version of cffi due to an
  apparent issue where older versions of cffi aren't compatible with
  the modern Clang I'm using. So let's upgrade packages to unbreak
  things and to keep things modern.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12629

AFFECTED FILES
  contrib/automation/requirements.txt

CHANGE DETAILS

diff --git a/contrib/automation/requirements.txt 
b/contrib/automation/requirements.txt
--- a/contrib/automation/requirements.txt
+++ b/contrib/automation/requirements.txt
@@ -1,193 +1,267 @@
 #
-# 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/requirements.txt 
contrib/automation/requirements.txt.in
 #
-asn1crypto==1.0.1 \
-
--hash=sha256:0b199f211ae690df3db4fd6c1c4ff976497fb1da689193e368eedbadc53d9292 \
-
--hash=sha256:bca90060bd995c3f62c4433168eab407e44bdbdb567b3f3a396a676c1a4c4a3f \
-# via cryptography
-bcrypt==3.1.7 \
-
--hash=sha256:0258f143f3de96b7c14f762c770f5fc56ccd72f8a1857a451c1cd9a655d9ac89 \
-
--hash=sha256:0b0069c752ec14172c5f78208f1863d7ad6755a6fae6fe76ec2c80d13be41e42 \
-
--hash=sha256:19a4b72a6ae5bb467fea018b825f0a7d917789bcfe893e53f15c92805d187294 \
-
--hash=sha256:5432dd7b34107ae8ed6c10a71b4397f1c853bd39a4d6ffa7e35f40584cffd161 \
-
--hash=sha256:69361315039878c0680be456640f8705d76cb4a3a3fe1e057e0f261b74be4b31 \
-
--hash=sha256:6fe49a60b25b584e2f4ef175b29d3a83ba63b3a4df1b4c0605b826668d1b6be5 \
-
--hash=sha256:74a015102e877d0ccd02cdeaa18b32aa7273746914a6c5d0456dd442cb65b99c \
-
--hash=sha256:763669a367869786bb4c8fcf731f4175775a5b43f070f50f46f0b59da45375d0 \
-
--hash=sha256:8b10acde4e1919d6015e1df86d4c217d3b5b01bb7744c36113ea43d529e1c3de \
-
--hash=sha256:9fe92406c857409b70a38729dbdf6578caf9228de0aef5bc44f859ffe971a39e \
-
--hash=sha256:a190f2a5dbbdbff4b74e3103cef44344bc30e61255beb27310e2aec407766052 \
-
--hash=sha256:a595c12c618119255c90deb4b046e1ca3bcfad64667c43d1166f2b04bc72db09 \
-
--hash=sha256:c9457fa5c121e94a58d6505cadca8bed1c6b83b3204928a866ca2e599105 \
-
--hash=sha256:cb93f6b2ab0f6853550b74e051d297c27a638719753eb9ff66d1e4072be67133 \
-
--hash=sha256:d7bdc26475679dd073ba0ed2766445bb5b20ca4793ca0db32b399dccc6bc84b7 \
-
--hash=sha256:ff032765bb8716d9387fd5376d987a937254b0619eff0972779515b5c98820bc \
+bcrypt==3.2.2 \
+
--hash=sha256:2b02d6bfc6336d1094276f3f588aa1225a598e27f8e3388f4db9948cb707b521 \
+
--hash=sha256:433c410c2177057705da2a9f2cd01dd157493b2a7ac14c8593a16b3dab6b6bfb \
+
--hash=sha256:4e029cef560967fb0cf4a802bcf4d562d3d6b4b1bf81de5ec1abbe0f1adb027e \
+
--hash=sha256:61bae49580dce88095d669226d5076d0b9d927754cedbdf76c6c9f5099ad6f26 \
+
--hash=sha256:6d2cb9d969bfca5bc08e45864137276e4c3d3d7de2b162171def3d188bf9d34a \
+
--hash=sha256:7180d98a96f00b1050e93f5b0f556e658605dd9f524d0b0e68ae7944673f525e \
+
--hash=sha256:7d9ba2e41e330d2af4af6b1b6ec9e6128e91343d0b4afb9282e54e5508f31baa \
+
--hash=sha256:7ff2069240c6bbe49109fe84ca80508773a904f5a8cb960e02a977f7f519b129 \
+
--hash=sha256:88273d806ab3a50d06bc6a2fc7c87d737dd669b76ad955f449c43095389bc8fb \
+
--hash=sha256:a2c46100e315c3a5b90fdc53e429c006c5f962529bc27e1dfd656292c20ccc40 \
+
--hash=sha256:cd43303d6b8a165c29ec6756afd169faba9396a9472cdff753fe9f19b96ce2fa
 # via paramiko
-bleach==3.1.0 \
-
--hash=sha256:213336e49e102af26d9cde77dd2d0397afabc5a6bf2fed985dc35b5d1e285a16 \
-
--hash=sha256:3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa \
+bleach==5.0.0 \
+
--hash=sha256:08a1fe86d253b5c88c92cc3d810fd8048a16d15762e1e5b74d502256e5926aa1 \
+
--hash=sha256:c6d6cc054bdc9c83b48b8083e236e5f00f238428666d2ce2e083eaa5fd568565
 # via readme-renderer
-boto3==1.9.243 \
-
--hash=sha256:404acbecef8f4912f18312fcfaffe7eba7f10b3b7adf7853bdba59cdf2275ebb \
-
--hash=sha256:c6e5a7e4548ce7586c354ff633f2a66ba3c471d15a8ae6a30f873122ab04e1cf
-botocore==1.12.243 \
-
--hash=sha256:397585a7881230274afb8d1877ef69a661b0a311745cd324f14a052fb2a2863a \
-
--hash=sha256:4496f8da89cb496462a831897ad248e13e431d9fa7e41e06d426fd6658ab6e59 \
-# via boto3, s3transfer
-certifi==2021.5.30 \
-
--hash=sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee \
-
--hash=sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8 \
+boto3==1.22.7 \
+
--hash=sha256:4dc0df36c3465ff0d586017da68b0152123695f38f30ad98fed7185e59298d2c \
+
--hash=sha256:de4fa49ca1cbc93313144e93e6d0997cbb61c8cca91f3418b4e3646dc215f441
+# via -r contrib/automation/requirements.txt.in
+botocore==1.25.7 \
+
--hash=sha256:190361776d96323ff401b976175f76172acf7ebbe3efbb19c4c6f9800a9ad6b6 \
+

D12368: mercurial: use io.BytesIO instead of util.stringio

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `util.stringio` is an alias to `io.BytesIO`. Let's just use `io.BytesIO`
  directly.
  
  I'm doing this because I noticed pytype was confused about types due to
  the indirection.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12368

AFFECTED FILES
  mercurial/archival.py
  mercurial/cmdutil.py
  mercurial/crecord.py
  mercurial/patch.py
  mercurial/profiling.py
  mercurial/pure/mpatch.py
  mercurial/pure/parsers.py
  mercurial/url.py
  mercurial/wireprotoserver.py

CHANGE DETAILS

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -6,6 +6,7 @@
 
 
 import contextlib
+import io
 import struct
 import threading
 
@@ -24,8 +25,6 @@
 stringutil,
 )
 
-stringio = util.stringio
-
 urlerr = util.urlerr
 urlreq = util.urlreq
 
@@ -117,7 +116,7 @@
 oldout = self._ui.fout
 olderr = self._ui.ferr
 
-out = util.stringio()
+out = io.BytesIO()
 
 try:
 self._ui.fout = out
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -9,6 +9,7 @@
 
 
 import base64
+import io
 import socket
 
 from .i18n import _
@@ -29,7 +30,6 @@
 )
 
 httplib = util.httplib
-stringio = util.stringio
 urlerr = util.urlerr
 urlreq = util.urlreq
 
@@ -276,7 +276,7 @@
 res.length = None
 res.chunked = 0
 res.will_close = 1
-res.msg = httplib.HTTPMessage(stringio())
+res.msg = httplib.HTTPMessage(io.BytesIO())
 return False
 
 res.msg = httplib.HTTPMessage(res.fp)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -25,8 +25,6 @@
 from ..revlogutils import nodemap as nodemaputil
 from ..revlogutils import constants as revlog_constants
 
-stringio = io.BytesIO
-
 
 _pack = struct.pack
 _unpack = struct.unpack
@@ -955,7 +953,7 @@
 
 
 def pack_dirstate(dmap, copymap, pl):
-cs = stringio()
+cs = io.BytesIO()
 write = cs.write
 write(b"".join(pl))
 for f, e in dmap.items():
diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
--- a/mercurial/pure/mpatch.py
+++ b/mercurial/pure/mpatch.py
@@ -10,9 +10,6 @@
 import struct
 
 
-stringio = io.BytesIO
-
-
 class mpatchError(Exception):
 """error raised when a delta cannot be decoded"""
 
@@ -71,7 +68,7 @@
 if not tl:
 return a
 
-m = stringio()
+m = io.BytesIO()
 
 # load our original text
 m.write(a)
diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -7,6 +7,7 @@
 
 
 import contextlib
+import io
 
 from .i18n import _
 from .pycompat import (
@@ -225,7 +226,7 @@
 
 try:
 if self._output == b'blackbox':
-self._fp = util.stringio()
+self._fp = io.BytesIO()
 elif self._output:
 path = util.expandpath(self._output)
 self._fp = open(path, b'wb')
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -11,6 +11,7 @@
 import contextlib
 import copy
 import errno
+import io
 import os
 import re
 import shutil
@@ -45,8 +46,6 @@
 stringutil,
 )
 
-stringio = util.stringio
-
 gitre = re.compile(br'diff --git a/(.*) b/(.*)')
 tabsplitter = re.compile(br'(\t+|[^\t]+)')
 wordsplitter = re.compile(
@@ -74,7 +73,7 @@
 return len(l) == 2 and b' ' not in l[0]
 
 def chunk(lines):
-return stringio(b''.join(lines))
+return io.BytesIO(b''.join(lines))
 
 def hgsplit(stream, cur):
 inheader = True
@@ -107,7 +106,7 @@
 
 def mimesplit(stream, cur):
 def msgfp(m):
-fp = stringio()
+fp = io.BytesIO()
 # pytype: disable=wrong-arg-types
 g = mail.Generator(fp, mangle_from_=False)
 # pytype: enable=wrong-arg-types
@@ -290,7 +289,7 @@
 
 ui.debug(b'found patch at byte %d\n' % m.start(0))
 diffs_seen += 1
-cfp = stringio()
+cfp = io.BytesIO()
 for line in payload[: m.start(0)].splitlines():
 if line.startswith(b'# HG changeset patch') and not hgpatch:
 ui.debug(b'patch generated by hg export\n')
@@ -599,7 +598,7 @@
 self.created = 0
 self.maxsize = maxsize
 if self.maxsize is None:
-self.maxsize = 4 * (2 ** 20)
+self.maxsize = 4 * (2**20)
 self.size = 0
 self.data = {}
 
@@ -1258,7 +1257,7 @@
 continue
 # Remove comment lines
 patchfp = open(patchfn, 'rb')
-ncpatchfp = stringio()
+ 

D12367: hgext: use io.BytesIO instead of util.stringio

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added subscribers: mercurial-patches, Kwan.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  util.stringio is an alias to io.BytesIO. Let's just use io.BytesIO
  directly.
  
  I'm doing this because I noticed that in some cases pytype wasn't able
  to infer the proper type of `util.stringio`. Removing the indirection
  will enable type checking to work better.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12367

AFFECTED FILES
  hgext/absorb.py
  hgext/convert/cvs.py
  hgext/convert/hg.py
  hgext/convert/subversion.py
  hgext/infinitepush/bundleparts.py
  hgext/patchbomb.py
  hgext/phabricator.py

CHANGE DETAILS

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -660,7 +660,7 @@
 
 def getdiff(basectx, ctx, diffopts):
 """plain-text diff without header (user, commit message, etc)"""
-output = util.stringio()
+output = io.BytesIO()
 for chunk, _label in patch.diffui(
 ctx.repo(), basectx.p1().node(), ctx.node(), None, opts=diffopts
 ):
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -77,6 +77,7 @@
 import email.mime.multipart as emimemultipart
 import email.utils as eutil
 import errno
+import io
 import os
 import socket
 
@@ -104,8 +105,6 @@
 urlutil,
 )
 
-stringio = util.stringio
-
 cmdtable = {}
 command = registrar.command(cmdtable)
 
@@ -228,7 +227,7 @@
 tmpl = ui.config(b'patchbomb', b'flagtemplate')
 if not tmpl:
 return b' '.join(flags)
-out = util.stringio()
+out = io.BytesIO()
 spec = formatter.literal_templatespec(templater.unquotestring(tmpl))
 with formatter.templateformatter(ui, out, b'patchbombflag', {}, spec) as 
fm:
 fm.startitem()
@@ -360,7 +359,7 @@
 for r in revs:
 if r == prev and (repo[None].files() or repo[None].deleted()):
 ui.warn(_(b'warning: working directory has uncommitted changes\n'))
-output = stringio()
+output = io.BytesIO()
 cmdutil.exportfile(
 repo, [r], output, opts=patch.difffeatureopts(ui, opts, git=True)
 )
@@ -995,7 +994,7 @@
 if not mbox:
 # Exim does not remove the Bcc field
 del m['Bcc']
-fp = stringio()
+fp = io.BytesIO()
 generator = mail.Generator(fp, mangle_from_=False)
 generator.flatten(m, False)
 alldests = to + bcc + cc
diff --git a/hgext/infinitepush/bundleparts.py 
b/hgext/infinitepush/bundleparts.py
--- a/hgext/infinitepush/bundleparts.py
+++ b/hgext/infinitepush/bundleparts.py
@@ -3,6 +3,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import io
 
 from mercurial.i18n import _
 from mercurial.node import hex
@@ -114,7 +115,7 @@
 self.params = part.params
 self.mandatorykeys = part.mandatorykeys
 # copy the buffer
-self._io = util.stringio(part.read())
+self._io = io.BytesIO(part.read())
 
 def consume(self):
 return
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -3,6 +3,7 @@
 # Copyright(C) 2007 Daniel Holth et al
 
 import codecs
+import io
 import locale
 import os
 import pickle
@@ -26,7 +27,6 @@
 
 from . import common
 
-stringio = util.stringio
 propertycache = util.propertycache
 urlerr = util.urlerr
 urlreq = util.urlreq
@@ -1267,12 +1267,12 @@
 if self.module != new_module:
 self.module = new_module
 self.reparent(self.module)
-io = stringio()
-info = svn.ra.get_file(self.ra, file, revnum, io)
-data = io.getvalue()
+bio = io.BytesIO()
+info = svn.ra.get_file(self.ra, file, revnum, bio)
+data = bio.getvalue()
 # ra.get_file() seems to keep a reference on the input buffer
 # preventing collection. Release it explicitly.
-io.close()
+bio.close()
 if isinstance(info, list):
 info = info[-1]
 mode = (b"svn:executable" in info) and b'x' or b''
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -17,6 +17,7 @@
 #   the converted revision to have a different identity than the
 #   source.
 
+import io
 import os
 import re
 import time
@@ -43,8 +44,6 @@
 )
 from mercurial.utils import dateutil
 
-stringio = util.stringio
-
 from . import common
 
 mapfile = common.mapfile
@@ -149,7 +148,7 @@
 self.before()
 
 def _rewritetags(self, source, revmap, data):
-fp = stringio()
+fp = io.BytesIO()
 for line in data.splitlines():
 s = line.split(b' ', 

D12369: run-tests: require Python 3.6

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We recently dropped support for Python 3.5 in `setup.py`. Let's update
  `run-tests.py` to reflect the new reality.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12369

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
@@ -72,9 +72,9 @@
 import uuid
 import xml.dom.minidom as minidom
 
-if sys.version_info < (3, 5, 0):
+if sys.version_info < (3, 6, 0):
 print(
-'%s is only supported on Python 3.5+, not %s'
+'%s is only supported on Python 3.6+, not %s'
 % (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))
 )
 sys.exit(70)  # EX_SOFTWARE from `man 3 sysexit`



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


D12366: pycompat: add return type annotations

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Now that we're using Python 3.6+, we can start using inline type
  annotations.
  
  I figured a good a place as any to start would be pycompat. So this
  commit defines type annotations throughout the file.
  
  Because we can't use deferred annotations parsing (since this feature
  requires Python 3.7), complex types relying on symbols from the `typing`
  module use quoted expressions. This achieves some of the benefit of
  deferred parsing without compromising the ability for type checkers to
  infer things.
  
  When annotating `open()` as part of this change, pytype started
  complaining about a type mismatch in `profiling.py`. This turned out
  to be a false positive. So the error was suppressed.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12366

AFFECTED FILES
  mercurial/profiling.py
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -36,6 +36,16 @@
 
 if not globals():  # hide this from non-pytype users
 import typing
+from typing import (
+Any,
+AnyStr,
+Dict,
+IO,
+Iterator,
+List,
+NoReturn,
+Tuple,
+)
 
 TYPE_CHECKING = typing.TYPE_CHECKING
 
@@ -112,15 +122,15 @@
 sysexecutable = os.fsencode(sysexecutable)
 
 
-def maplist(*args):
+def maplist(*args) -> 'List[Any]':
 return list(map(*args))
 
 
-def rangelist(*args):
+def rangelist(*args) -> 'List[int]':
 return list(range(*args))
 
 
-def ziplist(*args):
+def ziplist(*args) -> 'List[Any]':
 return list(zip(*args))
 
 
@@ -226,20 +236,20 @@
 s = str(s).encode('ascii')
 return bytes.__new__(cls, s)
 
-def __getitem__(self, key):
+def __getitem__(self, key) -> bytes:
 s = bytes.__getitem__(self, key)
 if not isinstance(s, bytes):
 s = bytechr(s)
 return s
 
-def __iter__(self):
+def __iter__(self) -> 'Iterator[bytes]':
 return iterbytestr(bytes.__iter__(self))
 
-def __repr__(self):
+def __repr__(self) -> str:
 return bytes.__repr__(self)[1:]  # drop b''
 
 
-def iterbytestr(s):
+def iterbytestr(s) -> 'Iterator[bytes]':
 """Iterate bytes as if it were a str object of Python 2"""
 return map(bytechr, s)
 
@@ -251,7 +261,7 @@
 return s
 
 
-def sysbytes(s):
+def sysbytes(s) -> bytes:
 """Convert an internal str (e.g. keyword, __doc__) back to bytes
 
 This never raises UnicodeEncodeError, but only ASCII characters
@@ -262,7 +272,7 @@
 return s.encode('utf-8')
 
 
-def sysstr(s):
+def sysstr(s) -> str:
 """Return a keyword str to be passed to Python functions such as
 getattr() and str.encode()
 
@@ -275,26 +285,26 @@
 return s.decode('latin-1')
 
 
-def strurl(url):
+def strurl(url) -> str:
 """Converts a bytes url back to str"""
 if isinstance(url, bytes):
 return url.decode('ascii')
 return url
 
 
-def bytesurl(url):
+def bytesurl(url) -> bytes:
 """Converts a str url to bytes by encoding in ascii"""
 if isinstance(url, str):
 return url.encode('ascii')
 return url
 
 
-def raisewithtb(exc, tb):
+def raisewithtb(exc, tb) -> 'NoReturn':
 """Raise exception with the given traceback"""
 raise exc.with_traceback(tb)
 
 
-def getdoc(obj):
+def getdoc(obj) -> bytes:
 """Get docstring as bytes; may be None so gettext() won't confuse it
 with _('')"""
 doc = getattr(obj, '__doc__', None)
@@ -320,14 +330,16 @@
 unicode = str
 
 
-def open(name, mode=b'r', buffering=-1, encoding=None):
+def open(name, mode=b'r', buffering=-1, encoding=None) -> 'IO[AnyStr]':
 return builtins.open(name, sysstr(mode), buffering, encoding)
 
 
 safehasattr = _wrapattrfunc(builtins.hasattr)
 
 
-def _getoptbwrapper(orig, args, shortlist, namelist):
+def _getoptbwrapper(
+orig, args, shortlist, namelist
+) -> 'Tuple[List[Tuple[bytes, bytes]], List[bytes]]':
 """
 Takes bytes arguments, converts them to unicode, pass them to
 getopt.getopt(), convert the returned values back to bytes and then
@@ -343,7 +355,7 @@
 return opts, args
 
 
-def strkwargs(dic):
+def strkwargs(dic) -> 'Dict[str, Any]':
 """
 Converts the keys of a python dictonary to str i.e. unicodes so that
 they can be passed as keyword arguments as dictionaries with bytes keys
@@ -353,7 +365,7 @@
 return dic
 
 
-def byteskwargs(dic):
+def byteskwargs(dic) -> 'Dict[bytes, Any]':
 """
 Converts keys of python dictionaries to bytes as they were converted to
 str to pass that dictonary as a keyword argument on Python 3.
@@ -363,7 +375,7 @@
 
 
 # TODO: handle shlex.shlex().
-def shlexsplit(s, comments=False, posix=True):
+def shlexsplit(s, comments=False, posix=True) -> 'List[bytes]':
 

D12365: import-checker: allow symbol imports from typing module

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As we add typing annotations, we'll want to use a lot of symbols from
  the `typing` module. Typing `typing` all the time will be annoying. Let's
  allow symbol imports from this module.
  
  While I was here, I changed some comments from "whitelist" to "allow list"
  as the former is non-inclusive terminology.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12365

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
@@ -19,7 +19,7 @@
 
 import testparseutil
 
-# Whitelist of modules that symbols can be directly imported from.
+# Allow list of modules that symbols can be directly imported from.
 allowsymbolimports = (
 '__future__',
 'breezy',
@@ -46,9 +46,10 @@
 'mercurial.thirdparty.attr',
 'mercurial.thirdparty.zope',
 'mercurial.thirdparty.zope.interface',
+'typing',
 )
 
-# Whitelist of symbols that can be directly imported.
+# Allow list of symbols that can be directly imported.
 directsymbols = ('demandimport',)
 
 # Modules that must be aliased because they are commonly confused with



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


D12364: pycompat: remove json.loads polyfill for Python 3.5

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We no longer support Python 3.5 so this can be deleted.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12364

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
@@ -376,47 +376,7 @@
 iteritems = lambda x: x.items()
 itervalues = lambda x: x.values()
 
-# Python 3.5's json.load and json.loads require str. We polyfill its
-# code for detecting encoding from bytes.
-if sys.version_info[0:2] < (3, 6):
-
-def _detect_encoding(b):
-bstartswith = b.startswith
-if bstartswith((codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE)):
-return 'utf-32'
-if bstartswith((codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE)):
-return 'utf-16'
-if bstartswith(codecs.BOM_UTF8):
-return 'utf-8-sig'
-
-if len(b) >= 4:
-if not b[0]:
-# 00 00 -- -- - utf-32-be
-# 00 XX -- -- - utf-16-be
-return 'utf-16-be' if b[1] else 'utf-32-be'
-if not b[1]:
-# XX 00 00 00 - utf-32-le
-# XX 00 00 XX - utf-16-le
-# XX 00 XX -- - utf-16-le
-return 'utf-16-le' if b[2] or b[3] else 'utf-32-le'
-elif len(b) == 2:
-if not b[0]:
-# 00 XX - utf-16-be
-return 'utf-16-be'
-if not b[1]:
-# XX 00 - utf-16-le
-return 'utf-16-le'
-# default
-return 'utf-8'
-
-def json_loads(s, *args, **kwargs):
-if isinstance(s, (bytes, bytearray)):
-s = s.decode(_detect_encoding(s), 'surrogatepass')
-
-return json.loads(s, *args, **kwargs)
-
-else:
-json_loads = json.loads
+json_loads = json.loads
 
 isjython = sysplatform.startswith(b'java')
 



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


D12363: pycompat: remove check for Python >= 3.6

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We dropped support for Python 3.5 so this is always true.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12363

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
@@ -86,7 +86,7 @@
 return _rapply(f, xs)
 
 
-if os.name == r'nt' and sys.version_info >= (3, 6):
+if os.name == r'nt':
 # MBCS (or ANSI) filesystem encoding must be used as before.
 # Otherwise non-ASCII filenames in existing repositories would be
 # corrupted.
@@ -415,7 +415,6 @@
 
 return json.loads(s, *args, **kwargs)
 
-
 else:
 json_loads = json.loads
 



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


D12362: hgdemandimport: delete check for Python 3.5

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We dropped support for Python 3.5. So we no longer need to do this.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12362

AFFECTED FILES
  hgdemandimport/demandimportpy3.py

CHANGE DETAILS

diff --git a/hgdemandimport/demandimportpy3.py 
b/hgdemandimport/demandimportpy3.py
--- a/hgdemandimport/demandimportpy3.py
+++ b/hgdemandimport/demandimportpy3.py
@@ -33,12 +33,6 @@
 
 _deactivated = False
 
-# Python 3.5's LazyLoader doesn't work for some reason.
-# https://bugs.python.org/issue26186 is a known issue with extension
-# importing. But it appears to not have a meaningful effect with
-# Mercurial.
-_supported = sys.version_info[0:2] >= (3, 6)
-
 
 class _lazyloaderex(importlib.util.LazyLoader):
 """This is a LazyLoader except it also follows the _deactivated global and
@@ -144,9 +138,6 @@
 
 
 def enable():
-if not _supported:
-return
-
 new_finders = []
 for finder in sys.meta_path:
 new_finders.append(



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


D12361: hg: always import hgdemandimport

2022-03-09 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The deleted if condition is always true now that we dropped Python 2
  and 3.5.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12361

AFFECTED FILES
  hg

CHANGE DETAILS

diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -43,10 +43,9 @@
 with tracing.log('hg script'):
 # enable importing on demand to reduce startup time
 try:
-if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
-import hgdemandimport
+import hgdemandimport
 
-hgdemandimport.enable()
+hgdemandimport.enable()
 except ImportError:
 sys.stderr.write(
 "abort: couldn't find mercurial libraries in [%s]\n"



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


D12341: py3: replace pycompat.itervalues(x) with x.values()

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: martinvonz.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  pycompat.itervalues(x) just calls x.values(). So this is equivalent.
  
  The rewrite was perfomed via an automated search and replace.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12341

AFFECTED FILES
  contrib/synthrepo.py
  hgext/journal.py
  hgext/rebase.py
  hgext/remotefilelog/connectionpool.py
  hgext/remotefilelog/debugcommands.py
  hgext/remotefilelog/repack.py
  hgext/transplant.py
  mercurial/branchmap.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/mergestate.py
  mercurial/patch.py
  mercurial/statprof.py
  mercurial/ui.py
  tests/test-pathencode.py

CHANGE DETAILS

diff --git a/tests/test-pathencode.py b/tests/test-pathencode.py
--- a/tests/test-pathencode.py
+++ b/tests/test-pathencode.py
@@ -66,7 +66,7 @@
 counts[c] += 1
 for c in '\r/\n':
 counts.pop(c, None)
-t = sum(pycompat.itervalues(counts)) / 100.0
+t = sum(counts.values()) / 100.0
 fp.write('probtable = (')
 for i, (k, v) in enumerate(
 sorted(counts.items(), key=lambda x: x[1], reverse=True)
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -2117,9 +2117,7 @@
 """
 if not self._loggers:
 return
-activeloggers = [
-l for l in pycompat.itervalues(self._loggers) if l.tracked(event)
-]
+activeloggers = [l for l in self._loggers.values() if l.tracked(event)]
 if not activeloggers:
 return
 msg = msgfmt % msgargs
diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -474,7 +474,7 @@
 if i == 0:
 sitestat.addself()
 
-return [s for s in pycompat.itervalues(stats)]
+return [s for s in stats.values()]
 
 
 class DisplayFormats:
@@ -745,9 +745,7 @@
 def _write(node, depth, multiple_siblings):
 site = node.site
 visiblechildren = [
-c
-for c in pycompat.itervalues(node.children)
-if c.count >= (limit * root.count)
+c for c in node.children.values() if c.count >= (limit * 
root.count)
 ]
 if site:
 indent = depth * 2 - 1
@@ -783,9 +781,7 @@
 )
 
 finalstring = liststring + codestring
-childrensamples = sum(
-[c.count for c in pycompat.itervalues(node.children)]
-)
+childrensamples = sum([c.count for c in node.children.values()])
 # Make frames that performed more than 10% of the operation red
 if node.count - childrensamples > (0.1 * root.count):
 finalstring = b'\033[91m' + finalstring + b'\033[0m'
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1342,11 +1342,7 @@
 fixoffset += chunk.removed - chunk.added
 return (
 sum(
-[
-h
-for h in pycompat.itervalues(applied)
-if h[0].special() or len(h) > 1
-],
+[h for h in applied.values() if h[0].special() or len(h) > 1],
 [],
 ),
 {},
diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -13,7 +13,6 @@
 from . import (
 error,
 filemerge,
-pycompat,
 util,
 )
 from .utils import hashutil
@@ -467,7 +466,7 @@
 """return counts for updated, merged and removed files in this
 session"""
 updated, merged, removed = 0, 0, 0
-for r, action in pycompat.itervalues(self._results):
+for r, action in self._results.values():
 if r is None:
 updated += 1
 elif r == 0:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2139,7 +2139,7 @@
 nodetagscache = {}
 for t, n in self._tagscache.tags.items():
 nodetagscache.setdefault(n, []).append(t)
-for tags in pycompat.itervalues(nodetagscache):
+for tags in nodetagscache.values():
 tags.sort()
 self._tagscache.nodetagscache = nodetagscache
 return self._tagscache.nodetagscache.get(node, [])
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -854,7 +854,7 @@
 checks = {p: [] for p in phases.allphases}
 checks[phases.public].extend(pushop.remotephases.publicheads)
 checks[phases.draft].extend(pushop.remotephases.draftroots)
-if any(pycompat.itervalues(checks)):
+if any(checks.values()):

D12352: py3: use class X: instead of class X(object):

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added subscribers: mercurial-patches, Kwan.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The inheritance from object is implied in Python 3. So this should
  be equivalent.
  
  This change was generated via an automated search and replace. So there
  may have been some accidental changes.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12352

AFFECTED FILES
  contrib/check-code.py
  contrib/fuzz/mpatch_corpus.py
  contrib/hgclient.py
  contrib/perf.py
  contrib/testparseutil.py
  doc/hgmanpage.py
  hgdemandimport/demandimportpy2.py
  hgdemandimport/demandimportpy3.py
  hgext/absorb.py
  hgext/blackbox.py
  hgext/bugzilla.py
  hgext/convert/common.py
  hgext/convert/convcmd.py
  hgext/convert/cvsps.py
  hgext/convert/filemap.py
  hgext/convert/git.py
  hgext/convert/gnuarch.py
  hgext/convert/subversion.py
  hgext/convert/transport.py
  hgext/eol.py
  hgext/extdiff.py
  hgext/fastannotate/context.py
  hgext/fastannotate/formatter.py
  hgext/fastannotate/revmap.py
  hgext/fastannotate/support.py
  hgext/fix.py
  hgext/fsmonitor/__init__.py
  hgext/fsmonitor/pywatchman/__init__.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/manifest.py
  hgext/githelp.py
  hgext/gpg.py
  hgext/histedit.py
  hgext/infinitepush/__init__.py
  hgext/infinitepush/bundleparts.py
  hgext/infinitepush/indexapi.py
  hgext/infinitepush/store.py
  hgext/journal.py
  hgext/keyword.py
  hgext/largefiles/basestore.py
  hgext/largefiles/lfutil.py
  hgext/largefiles/overrides.py
  hgext/lfs/blobstore.py
  hgext/logtoprocess.py
  hgext/mq.py
  hgext/notify.py
  hgext/phabricator.py
  hgext/rebase.py
  hgext/releasenotes.py
  hgext/remotefilelog/basepack.py
  hgext/remotefilelog/basestore.py
  hgext/remotefilelog/connectionpool.py
  hgext/remotefilelog/contentstore.py
  hgext/remotefilelog/debugcommands.py
  hgext/remotefilelog/fileserverclient.py
  hgext/remotefilelog/metadatastore.py
  hgext/remotefilelog/remotefilelog.py
  hgext/remotefilelog/remotefilelogserver.py
  hgext/remotefilelog/repack.py
  hgext/remotenames.py
  hgext/schemes.py
  hgext/sqlitestore.py
  hgext/transplant.py
  hgext/zeroconf/Zeroconf.py
  hgext/zeroconf/__init__.py
  i18n/polib.py
  mercurial/ancestor.py
  mercurial/archival.py
  mercurial/bookmarks.py
  mercurial/branchmap.py
  mercurial/bundle2.py
  mercurial/bundlecaches.py
  mercurial/bundlerepo.py
  mercurial/cffi/osutil.py
  mercurial/changegroup.py
  mercurial/changelog.py
  mercurial/chgserver.py
  mercurial/cmdutil.py
  mercurial/commandserver.py
  mercurial/config.py
  mercurial/configitems.py
  mercurial/context.py
  mercurial/copies.py
  mercurial/crecord.py
  mercurial/dagop.py
  mercurial/dirstate.py
  mercurial/dirstatemap.py
  mercurial/dirstateutils/docket.py
  mercurial/dirstateutils/v2.py
  mercurial/discovery.py
  mercurial/dispatch.py
  mercurial/encoding.py
  mercurial/error.py
  mercurial/exchange.py
  mercurial/extensions.py
  mercurial/exthelper.py
  mercurial/fancyopts.py
  mercurial/filelog.py
  mercurial/filemerge.py
  mercurial/fileset.py
  mercurial/formatter.py
  mercurial/graphmod.py
  mercurial/grep.py
  mercurial/hg.py
  mercurial/hgweb/__init__.py
  mercurial/hgweb/common.py
  mercurial/hgweb/hgweb_mod.py
  mercurial/hgweb/hgwebdir_mod.py
  mercurial/hgweb/request.py
  mercurial/hgweb/server.py
  mercurial/hgweb/webcommands.py
  mercurial/hgweb/webutil.py
  mercurial/hgweb/wsgiheaders.py
  mercurial/httpconnection.py
  mercurial/httppeer.py
  mercurial/interfaces/repository.py
  mercurial/interfaces/util.py
  mercurial/keepalive.py
  mercurial/linelog.py
  mercurial/localrepo.py
  mercurial/lock.py
  mercurial/logcmdutil.py
  mercurial/loggingutil.py
  mercurial/lsprof.py
  mercurial/lsprofcalltree.py
  mercurial/manifest.py
  mercurial/match.py
  mercurial/mdiff.py
  mercurial/merge.py
  mercurial/mergestate.py
  mercurial/metadata.py
  mercurial/namespaces.py
  mercurial/node.py
  mercurial/obsolete.py
  mercurial/obsutil.py
  mercurial/parser.py
  mercurial/patch.py
  mercurial/pathutil.py
  mercurial/phases.py
  mercurial/posix.py
  mercurial/profiling.py
  mercurial/progress.py
  mercurial/pure/osutil.py
  mercurial/pure/parsers.py
  mercurial/pvec.py
  mercurial/pycompat.py
  mercurial/registrar.py
  mercurial/repair.py
  mercurial/repocache.py
  mercurial/repoview.py
  mercurial/revlog.py
  mercurial/revlogutils/__init__.py
  mercurial/revlogutils/deltas.py
  mercurial/revlogutils/docket.py
  mercurial/revlogutils/nodemap.py
  mercurial/revlogutils/randomaccessfile.py
  mercurial/scmutil.py
  mercurial/setdiscovery.py
  mercurial/shelve.py
  mercurial/simplemerge.py
  mercurial/smartset.py
  mercurial/sshpeer.py
  mercurial/state.py
  mercurial/statichttprepo.py
  

D12353: demandimport: delete demandimportpy2 module

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12353

AFFECTED FILES
  hgdemandimport/__init__.py
  hgdemandimport/demandimportpy2.py
  tests/test-check-py3-compat.t

CHANGE DETAILS

diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -4,7 +4,6 @@
   $ cd "$TESTDIR"/..
 
   $ testrepohg files 'set:(**.py) - grep(pygments)' \
-  > -X hgdemandimport/demandimportpy2.py \
   > -X hgext/fsmonitor/pywatchman \
   > -X mercurial/cffi \
   > -X mercurial/thirdparty \
diff --git a/hgdemandimport/demandimportpy2.py 
b/hgdemandimport/demandimportpy2.py
deleted file mode 100644
--- a/hgdemandimport/demandimportpy2.py
+++ /dev/null
@@ -1,325 +0,0 @@
-# demandimport.py - global demand-loading of modules for Mercurial
-#
-# Copyright 2006, 2007 Olivia Mackall 
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-'''
-demandimport - automatic demandloading of modules
-
-To enable this module, do:
-
-  import demandimport; demandimport.enable()
-
-Imports of the following forms will be demand-loaded:
-
-  import a, b.c
-  import a.b as c
-  from a import b,c # a will be loaded immediately
-
-These imports will not be delayed:
-
-  from a import *
-  b = __import__(a)
-'''
-
-
-import __builtin__ as builtins
-import contextlib
-import sys
-
-from . import tracing
-
-contextmanager = contextlib.contextmanager
-
-_origimport = __import__
-
-nothing = object()
-
-
-def _hgextimport(importfunc, name, globals, *args, **kwargs):
-try:
-return importfunc(name, globals, *args, **kwargs)
-except ImportError:
-if not globals:
-raise
-# extensions are loaded with "hgext_" prefix
-hgextname = 'hgext_%s' % name
-nameroot = hgextname.split('.', 1)[0]
-contextroot = globals.get('__name__', '').split('.', 1)[0]
-if nameroot != contextroot:
-raise
-# retry to import with "hgext_" prefix
-return importfunc(hgextname, globals, *args, **kwargs)
-
-
-class _demandmod:
-"""module demand-loader and proxy
-
-Specify 1 as 'level' argument at construction, to import module
-relatively.
-"""
-
-def __init__(self, name, globals, locals, level):
-if '.' in name:
-head, rest = name.split('.', 1)
-after = [rest]
-else:
-head = name
-after = []
-object.__setattr__(
-self, "_data", (head, globals, locals, after, level, set())
-)
-object.__setattr__(self, "_module", None)
-
-def _extend(self, name):
-"""add to the list of submodules to load"""
-self._data[3].append(name)
-
-def _addref(self, name):
-"""Record that the named module ``name`` imports this module.
-
-References to this proxy class having the name of this module will be
-replaced at module load time. We assume the symbol inside the importing
-module is identical to the "head" name of this module. We don't
-actually know if "as X" syntax is being used to change the symbol name
-because this information isn't exposed to __import__.
-"""
-self._data[5].add(name)
-
-def _load(self):
-if not self._module:
-with tracing.log('demandimport %s', self._data[0]):
-head, globals, locals, after, level, modrefs = self._data
-mod = _hgextimport(
-_origimport, head, globals, locals, None, level
-)
-if mod is self:
-# In this case, _hgextimport() above should imply
-# _demandimport(). Otherwise, _hgextimport() never
-# returns _demandmod. This isn't intentional behavior,
-# in fact. (see also issue5304 for detail)
-#
-# If self._module is already bound at this point, self
-# should be already _load()-ed while _hgextimport().
-# Otherwise, there is no way to import actual module
-# as expected, because (re-)invoking _hgextimport()
-# should cause same result.
-# This is reason why _load() returns without any more
-# setup but assumes self to be already bound.
-mod = self._module
-assert mod and mod is not self, "%s, %s" % (self, mod)
-return
-
-# load submodules
-def subload(mod, p):
-h, t = p, None
-if '.' in p:
-

D12347: py3: stop using util.iterfile()

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The Python 3 implementation is a no-op. So this is equivalent.
  
  We still keep util.iterfile() around for backwards API compatibility to
  help the Python 3 migration. It can be deleted in a future release.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12347

AFFECTED FILES
  hgext/convert/common.py
  hgext/convert/convcmd.py
  mercurial/match.py
  mercurial/patch.py
  mercurial/store.py

CHANGE DETAILS

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -661,7 +661,7 @@
 """make sure there is no empty string in entries"""
 if b'' in self.entries:
 fp.seek(0)
-for n, line in enumerate(util.iterfile(fp)):
+for n, line in enumerate(fp):
 if not line.rstrip(b'\n'):
 t = _(b'invalid entry in fncache, line %d') % (n + 1)
 if warn:
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1259,7 +1259,7 @@
 # Remove comment lines
 patchfp = open(patchfn, 'rb')
 ncpatchfp = stringio()
-for line in util.iterfile(patchfp):
+for line in patchfp:
 line = util.fromnativeeol(line)
 if not line.startswith(b'#'):
 ncpatchfp.write(line)
@@ -2343,7 +2343,7 @@
 ui.debug(b'Using external patch tool: %s\n' % cmd)
 fp = procutil.popen(cmd, b'rb')
 try:
-for line in util.iterfile(fp):
+for line in fp:
 line = line.rstrip()
 ui.note(line + b'\n')
 if line.startswith(b'patching file '):
diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -1611,7 +1611,7 @@
 patterns = []
 
 fp = open(filepath, b'rb')
-for lineno, line in enumerate(util.iterfile(fp), start=1):
+for lineno, line in enumerate(fp, start=1):
 if b"#" in line:
 global _commentre
 if not _commentre:
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -242,7 +242,7 @@
 m = {}
 try:
 fp = open(path, b'rb')
-for i, line in enumerate(util.iterfile(fp)):
+for i, line in enumerate(fp):
 line = line.splitlines()[0].rstrip()
 if not line:
 # Ignore blank lines
diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -552,7 +552,7 @@
 if err.errno != errno.ENOENT:
 raise
 return
-for i, line in enumerate(util.iterfile(fp)):
+for i, line in enumerate(fp):
 line = line.splitlines()[0].rstrip()
 if not line:
 # Ignore blank lines



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


D12351: check-code: remove ban on old-style classes

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In Python 3, `class foo:` is equivalent to `class foo(object):`. So
  we can allow the former form now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12351

AFFECTED FILES
  contrib/check-code.py
  tests/test-contrib-check-code.t

CHANGE DETAILS

diff --git a/tests/test-contrib-check-code.t b/tests/test-contrib-check-code.t
--- a/tests/test-contrib-check-code.t
+++ b/tests/test-contrib-check-code.t
@@ -51,12 +51,6 @@
   ./quote.py:5:
> '"""', 42+1, """and
missing whitespace in expression
-  ./classstyle.py:4:
-   > class oldstyle_class:
-   old-style class, use class foo(object)
-  ./classstyle.py:7:
-   > class empty():
-   class foo() creates old style object, use class foo(object)
   [1]
   $ cat > python3-compat.py << NO_CHECK_EOF
   > foo <> bar
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -343,16 +343,6 @@
 "linebreak after :",
 ),
 (
-r'class\s[^( \n]+:',
-"old-style class, use class foo(object)",
-r'#.*old-style',
-),
-(
-r'class\s[^( \n]+\(\):',
-"class foo() creates old style object, use class foo(object)",
-r'#.*old-style',
-),
-(
 r'\b(%s)\('
 % '|'.join(k for k in keyword.kwlist if k not in ('print', 
'exec')),
 "Python keyword is not a function",



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


D12350: tests: remove Python 2 support code

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12350

AFFECTED FILES
  tests/test-mq-missingfiles.t
  tests/test-mq-qimport.t
  tests/test-notify.t

CHANGE DETAILS

diff --git a/tests/test-notify.t b/tests/test-notify.t
--- a/tests/test-notify.t
+++ b/tests/test-notify.t
@@ -2,14 +2,13 @@
   > import io
   > import re
   > import sys
-  > if sys.version_info[0] >= 3:
-  > sys.stdout = io.TextIOWrapper(
-  > sys.stdout.buffer,
-  > sys.stdout.encoding,
-  > sys.stdout.errors,
-  > newline="\n",
-  > line_buffering=sys.stdout.line_buffering,
-  > )
+  > sys.stdout = io.TextIOWrapper(
+  > sys.stdout.buffer,
+  > sys.stdout.encoding,
+  > sys.stdout.errors,
+  > newline="\n",
+  > line_buffering=sys.stdout.line_buffering,
+  > )
   > print(re.sub("\n[ \t]", " ", sys.stdin.read()), end="")
   > EOF
 
diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t
--- a/tests/test-mq-qimport.t
+++ b/tests/test-mq-qimport.t
@@ -1,9 +1,6 @@
   $ cat > writelines.py < import sys
-  > if sys.version_info[0] >= 3:
-  > encode = lambda x: 
x.encode('utf-8').decode('unicode_escape').encode('utf-8')
-  > else:
-  > encode = lambda x: x.decode('string_escape')
+  > encode = lambda x: 
x.encode('utf-8').decode('unicode_escape').encode('utf-8')
   > path = sys.argv[1]
   > args = sys.argv[2:]
   > assert (len(args) % 2) == 0
diff --git a/tests/test-mq-missingfiles.t b/tests/test-mq-missingfiles.t
--- a/tests/test-mq-missingfiles.t
+++ b/tests/test-mq-missingfiles.t
@@ -5,10 +5,7 @@
 
   $ cat > writelines.py < import sys
-  > if sys.version_info[0] >= 3:
-  > encode = lambda x: 
x.encode('utf-8').decode('unicode_escape').encode('utf-8')
-  > else:
-  > encode = lambda x: x.decode('string_escape')
+  > encode = lambda x: 
x.encode('utf-8').decode('unicode_escape').encode('utf-8')
   > path = sys.argv[1]
   > args = sys.argv[2:]
   > assert (len(args) % 2) == 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


D12340: py3: use str instead of pycompat.unicode

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added subscribers: mercurial-patches, Kwan.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  pycompat.unicode is an alias to str.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12340

AFFECTED FILES
  hgext/convert/common.py
  hgext/convert/convcmd.py
  hgext/convert/darcs.py
  hgext/lfs/blobstore.py
  hgext/phabricator.py
  hgext/win32mbcs.py
  mercurial/hgweb/__init__.py
  mercurial/i18n.py
  mercurial/scmutil.py
  mercurial/templatefilters.py

CHANGE DETAILS

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -372,9 +372,7 @@
 """Any text. Returns the input text rendered as a sequence of
 XML entities.
 """
-text = pycompat.unicode(
-text, pycompat.sysstr(encoding.encoding), r'replace'
-)
+text = str(text, pycompat.sysstr(encoding.encoding), r'replace')
 return 

D12349: tests: remove Python < 3 check

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We require Python 3 now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12349

AFFECTED FILES
  tests/testlib/sigpipe-remote.py

CHANGE DETAILS

diff --git a/tests/testlib/sigpipe-remote.py b/tests/testlib/sigpipe-remote.py
--- a/tests/testlib/sigpipe-remote.py
+++ b/tests/testlib/sigpipe-remote.py
@@ -6,14 +6,6 @@
 import sys
 import time
 
-# we cannot use mercurial.testing as long as python2 is not dropped as the test
-# will only install the mercurial module for python2 in python2 run
-if sys.version_info[0] < 3:
-ver = '.'.join(str(x) for x in sys.version_info)
-exe = sys.executable
-print('SIGPIPE-HELPER: script should run with Python 3', file=sys.stderr)
-print('SIGPIPE-HELPER:   %s is running %s' % (exe, ver), file=sys.stderr)
-sys.exit(255)
 
 if isinstance(sys.stdout.buffer, io.BufferedWriter):
 print('SIGPIPE-HELPER: script need unbuffered output', file=sys.stderr)



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


D12348: cborutil: remove Python 2 definition of _elementtointeger()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12348

AFFECTED FILES
  mercurial/utils/cborutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/cborutil.py b/mercurial/utils/cborutil.py
--- a/mercurial/utils/cborutil.py
+++ b/mercurial/utils/cborutil.py
@@ -7,7 +7,6 @@
 
 
 import struct
-import sys
 
 
 # Very short very of RFC 7049...
@@ -246,16 +245,8 @@
 """Represents an error decoding CBOR."""
 
 
-if sys.version_info.major >= 3:
-
-def _elementtointeger(b, i):
-return b[i]
-
-
-else:
-
-def _elementtointeger(b, i):
-return ord(b[i])
+def _elementtointeger(b, i):
+return b[i]
 
 
 STRUCT_BIG_UBYTE = struct.Struct('>B')



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


D12346: util: remove iterfile() variant for buggy EINTR handling

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The workaround for Python 2 is no longer needed. So we can delete some
  code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12346

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -25,7 +25,6 @@
 import locale
 import mmap
 import os
-import platform as pyplatform
 import re as remod
 import shutil
 import stat
@@ -2905,50 +2904,10 @@
 fromnativeeol = pycompat.identity
 nativeeolwriter = pycompat.identity
 
-if pyplatform.python_implementation() == b'CPython' and sys.version_info < (
-3,
-0,
-):
-# There is an issue in CPython that some IO methods do not handle EINTR
-# correctly. The following table shows what CPython version (and functions)
-# are affected (buggy: has the EINTR bug, okay: otherwise):
-#
-#| < 2.7.4 | 2.7.4 to 2.7.12 | >= 3.0
-#   --
-#fp.__iter__ | buggy   | buggy   | okay
-#fp.read*| buggy   | okay [1]| okay
-#
-# [1]: fixed by changeset 67dc99a989cd in the cpython hg repo.
-#
-# Here we workaround the EINTR issue for fileobj.__iter__. Other methods
-# like "read*" work fine, as we do not support Python < 2.7.4.
-#
-# Although we can workaround the EINTR issue for fp.__iter__, it is slower:
-# "for x in fp" is 4x faster than "for x in iter(fp.readline, '')" in
-# CPython 2, because CPython 2 maintains an internal readahead buffer for
-# fp.__iter__ but not other fp.read* methods.
-#
-# On modern systems like Linux, the "read" syscall cannot be interrupted
-# when reading "fast" files like on-disk files. So the EINTR issue only
-# affects things like pipes, sockets, ttys etc. We treat "normal" (S_ISREG)
-# files approximately as "fast" files and use the fast (unsafe) code path,
-# to minimize the performance impact.
-
-def iterfile(fp):
-fastpath = True
-if type(fp) is file:
-fastpath = stat.S_ISREG(os.fstat(fp.fileno()).st_mode)
-if fastpath:
-return fp
-else:
-# fp.readline deals with EINTR correctly, use it as a workaround.
-return iter(fp.readline, b'')
-
-
-else:
-# PyPy and CPython 3 do not have the EINTR issue thus no workaround needed.
-def iterfile(fp):
-return fp
+
+# TODO delete since workaround variant for Python 2 no longer needed.
+def iterfile(fp):
+return fp
 
 
 def iterlines(iterator):



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


D12345: statprof: remove superfluous sys.version_info check

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Always true since we require Python 3 now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12345

AFFECTED FILES
  mercurial/statprof.py

CHANGE DETAILS

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -607,9 +607,7 @@
 # only show line numbers for significant locations (>1% time spent)
 if stat.selfpercent() > 1:
 source = stat.site.getsource(25)
-if sys.version_info.major >= 3 and not isinstance(
-source, bytes
-):
+if not isinstance(source, bytes):
 source = pycompat.bytestr(source)
 
 stattuple = (



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


D12342: url: remove Python 2.7 support code

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12342

AFFECTED FILES
  mercurial/url.py

CHANGE DETAILS

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -10,7 +10,6 @@
 
 import base64
 import socket
-import sys
 
 from .i18n import _
 from .pycompat import getattr
@@ -343,16 +342,6 @@
 keepalive.HTTPConnection.__init__(self, *args, **kwargs)
 self._create_connection = createconn
 
-if sys.version_info < (2, 7, 7):
-# copied from 2.7.14, since old implementations directly call
-# socket.create_connection()
-def connect(self):
-self.sock = self._create_connection(
-(self.host, self.port), self.timeout, self.source_address
-)
-if self._tunnel_host:
-self._tunnel()
-
 
 class logginghttphandler(httphandler):
 """HTTP handler that logs socket I/O."""



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


D12344: policy: remove Python 2.7 compatibility code

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12344

AFFECTED FILES
  mercurial/policy.py

CHANGE DETAILS

diff --git a/mercurial/policy.py b/mercurial/policy.py
--- a/mercurial/policy.py
+++ b/mercurial/policy.py
@@ -53,11 +53,8 @@
 policy = b'cffi'
 
 # Environment variable can always force settings.
-if sys.version_info[0] >= 3:
-if 'HGMODULEPOLICY' in os.environ:
-policy = os.environ['HGMODULEPOLICY'].encode('utf-8')
-else:
-policy = os.environ.get('HGMODULEPOLICY', policy)
+if 'HGMODULEPOLICY' in os.environ:
+policy = os.environ['HGMODULEPOLICY'].encode('utf-8')
 
 
 def _importfrom(pkgname, modname):



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


D12343: lsprof: remove some Python 2.7 compatibility code

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12343

AFFECTED FILES
  mercurial/lsprof.py

CHANGE DETAILS

diff --git a/mercurial/lsprof.py b/mercurial/lsprof.py
--- a/mercurial/lsprof.py
+++ b/mercurial/lsprof.py
@@ -117,9 +117,7 @@
 
 def label(code):
 if isinstance(code, str):
-if sys.version_info.major >= 3:
-code = code.encode('latin-1')
-return code
+return code.encode('latin-1')
 try:
 mname = _fn2mod[code.co_filename]
 except KeyError:
@@ -136,7 +134,4 @@
 
 res = '%s:%d(%s)' % (mname, code.co_firstlineno, code.co_name)
 
-if sys.version_info.major >= 3:
-res = res.encode('latin-1')
-
-return res
+return res.encode('latin-1')



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


D12338: py3: use int instead of pycompat.long

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  pycompat.long is aliased to int. So this should have no change in
  functionality.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12338

AFFECTED FILES
  hgext/convert/monotone.py
  hgext/remotefilelog/shallowutil.py
  mercurial/formatter.py
  mercurial/templatefilters.py
  mercurial/utils/cborutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/cborutil.py b/mercurial/utils/cborutil.py
--- a/mercurial/utils/cborutil.py
+++ b/mercurial/utils/cborutil.py
@@ -9,7 +9,6 @@
 import struct
 import sys
 
-from .. import pycompat
 
 # Very short very of RFC 7049...
 #
@@ -207,7 +206,7 @@
 STREAM_ENCODERS = {
 bytes: streamencodebytestring,
 int: streamencodeint,
-pycompat.long: streamencodeint,
+int: streamencodeint,
 list: streamencodearray,
 tuple: streamencodearray,
 dict: streamencodemap,
diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -334,7 +334,7 @@
 return b'false'
 elif obj is True:
 return b'true'
-elif isinstance(obj, (int, pycompat.long, float)):
+elif isinstance(obj, (int, int, float)):
 return pycompat.bytestr(obj)
 elif isinstance(obj, bytes):
 return b'"%s"' % encoding.jsonescape(obj, paranoid=paranoid)
diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -141,7 +141,7 @@
 Returns False if the object is unsupported or must be pre-processed by
 formatdate(), formatdict(), or formatlist().
 """
-return isinstance(obj, (type(None), bool, int, pycompat.long, float, 
bytes))
+return isinstance(obj, (type(None), bool, int, int, float, bytes))
 
 
 class _nullconverter(object):
diff --git a/hgext/remotefilelog/shallowutil.py 
b/hgext/remotefilelog/shallowutil.py
--- a/hgext/remotefilelog/shallowutil.py
+++ b/hgext/remotefilelog/shallowutil.py
@@ -175,8 +175,8 @@
 
 
 _metaitemtypes = {
-constants.METAKEYFLAG: (int, pycompat.long),
-constants.METAKEYSIZE: (int, pycompat.long),
+constants.METAKEYFLAG: (int, int),
+constants.METAKEYSIZE: (int, int),
 }
 
 
diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -150,7 +150,7 @@
 raise error.Abort(_(b'bad mtn packet - no end of packet size'))
 lengthstr += read
 try:
-length = pycompat.long(lengthstr[:-1])
+length = int(lengthstr[:-1])
 except TypeError:
 raise error.Abort(
 _(b'bad mtn packet - bad packet size %s') % lengthstr



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


D12339: ui: use input() directly

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  pycompat.rawinput() is an alias to input()

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12339

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1725,7 +1725,7 @@
 if usereadline:
 self.flush()
 prompt = encoding.strfromlocal(prompt)
-line = encoding.strtolocal(pycompat.rawinput(prompt))
+line = encoding.strtolocal(input(prompt))
 # When stdin is in binary mode on Windows, it can cause
 # raw_input() to emit an extra trailing carriage return
 if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'):



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


D12337: worker: silence type error when calling pickle

2022-03-03 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  pytype is complaining that the argument to `pickle.load()` is not an
  `IO`. pytype isn't wrong: `_blockingreader` doesn't implement
  `io.RawIOBase`, only `read()` and `readline()`. But it appears this is
  enough for pickle. So we silence the false positive.
  
  This fixes a regression introduced by D12304 
 /
  cc0e059d2af8 
: 
worker: remove Python 2 support code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12337

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -279,7 +279,11 @@
 while openpipes > 0:
 for key, events in selector.select():
 try:
+# The pytype error likely goes away on a modern version of
+# pytype having a modern typeshed snapshot.
+# pytype: disable=wrong-arg-types
 res = pickle.load(_blockingreader(key.fileobj))
+# pytype: enable=wrong-arg-types
 if hasretval and res[0]:
 retval.update(res[1])
 else:



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


D12333: revlog: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12333

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -437,9 +437,7 @@
 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor
 
 # revlog v0 doesn't have flag processors
-for flag, processor in pycompat.iteritems(
-opts.get(b'flagprocessors', {})
-):
+for flag, processor in opts.get(b'flagprocessors', {}).items():
 flagutil.insertflagprocessor(flag, processor, self._flagprocessors)
 
 if self._chunkcachesize <= 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


D12335: templatekw: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12335

AFFECTED FILES
  mercurial/templatekw.py

CHANGE DETAILS

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -685,7 +685,7 @@
 d = {b'name': k}
 if len(ps) == 1:
 d[b'url'] = ps[0].rawloc
-sub_opts = pycompat.iteritems(ps[0].suboptions)
+sub_opts = ps[0].suboptions.items()
 sub_opts = util.sortdict(sorted(sub_opts))
 d.update(sub_opts)
 path_dict = util.sortdict()



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


D12336: verify: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12336

AFFECTED FILES
  mercurial/verify.py

CHANGE DETAILS

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -574,7 +574,7 @@
 
 # cross-check
 if f in filenodes:
-fns = [(v, k) for k, v in pycompat.iteritems(filenodes[f])]
+fns = [(v, k) for k, v in filenodes[f].items()]
 for lr, node in sorted(fns):
 msg = _(b"manifest refers to unknown revision %s")
 self._err(lr, msg % short(node), f)



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


D12332: merge: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12332

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
@@ -625,9 +625,7 @@
 args, msg = self._actionmapping[a][f]
 yield f, args, msg
 else:
-for f, (args, msg) in pycompat.iteritems(
-self._actionmapping[a]
-):
+for f, (args, msg) in self._actionmapping[a].items():
 yield f, args, msg
 
 def len(self, actions=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


D12334: templatefuncs: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12334

AFFECTED FILES
  mercurial/templatefuncs.py

CHANGE DETAILS

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -88,7 +88,7 @@
 
 data.update(
 (k, evalfuncarg(context, mapping, v))
-for k, v in pycompat.iteritems(args[b'kwargs'])
+for k, v in args[b'kwargs'].items()
 )
 return templateutil.hybriddict(data)
 



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


D12330: localrepo: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12330

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2127,7 +2127,7 @@
 '''return a list of tags ordered by revision'''
 if not self._tagscache.tagslist:
 l = []
-for t, n in pycompat.iteritems(self.tags()):
+for t, n in self.tags().items():
 l.append((self.changelog.rev(n), t, n))
 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
 



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


D12326: debugcommands: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12326

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2384,7 +2384,7 @@
 fm_files.end()
 
 fm_extras = fm.nested(b'extras')
-for f, d in sorted(pycompat.iteritems(ms.allextras())):
+for f, d in sorted(ms.allextras().items()):
 if f in ms:
 # If file is in mergestate, we have already processed it's extras
 continue
@@ -2888,7 +2888,7 @@
 ui.status(pycompat.bytestr(r) + b'\n')
 return not r
 else:
-for k, v in sorted(pycompat.iteritems(target.listkeys(namespace))):
+for k, v in sorted(target.listkeys(namespace).items()):
 ui.write(
 b"%s\t%s\n"
 % (stringutil.escapestr(k), stringutil.escapestr(v))



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


D12331: manifest: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12331

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -826,9 +826,7 @@
 def _loadalllazy(self):
 selfdirs = self._dirs
 subpath = self._subpath
-for d, (node, readsubtree, docopy) in pycompat.iteritems(
-self._lazydirs
-):
+for d, (node, readsubtree, docopy) in self._lazydirs.items():
 if docopy:
 selfdirs[d] = readsubtree(subpath(d), node).copy()
 else:
@@ -2245,7 +2243,7 @@
 m0 = self._manifestlog.get(self._dir, store.node(r0)).read()
 m1 = self.read()
 md = treemanifest(self._manifestlog.nodeconstants, dir=self._dir)
-for f, ((n0, fl0), (n1, fl1)) in pycompat.iteritems(m0.diff(m1)):
+for f, ((n0, fl0), (n1, fl1)) in m0.diff(m1).items():
 if n1:
 md[f] = n1
 if fl1:



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


D12328: help: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12328

AFFECTED FILES
  mercurial/help.py

CHANGE DETAILS

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -297,8 +297,8 @@
 continue
 results[b'commands'].append((cmdname, summary))
 for name, docs in itertools.chain(
-pycompat.iteritems(extensions.enabled(False)),
-pycompat.iteritems(extensions.disabled()),
+extensions.enabled(False).items(),
+extensions.disabled().items(),
 ):
 if not docs:
 continue
@@ -311,7 +311,7 @@
 except ImportError:
 # debug message would be printed in extensions.load()
 continue
-for cmd, entry in pycompat.iteritems(getattr(mod, 'cmdtable', {})):
+for cmd, entry in getattr(mod, 'cmdtable', {}).items():
 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
 cmdname = cmdutil.parsealiases(cmd)[0]
 func = entry[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


D12329: keepalive: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12329

AFFECTED FILES
  mercurial/keepalive.py

CHANGE DETAILS

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -193,7 +193,7 @@
 
 def close_all(self):
 """close all open connections"""
-for host, conns in pycompat.iteritems(self._cm.get_all()):
+for host, conns in self._cm.get_all().items():
 for h in conns:
 self._cm.remove(h)
 h.close()



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


D12327: dirstate: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12327

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1308,9 +1308,9 @@
 # - match.traversedir does something, because match.traversedir should
 #   be called for every dir in the working dir
 full = listclean or match.traversedir is not None
-for fn, st in pycompat.iteritems(
-self.walk(match, subrepos, listunknown, listignored, full=full)
-):
+for fn, st in self.walk(
+match, subrepos, listunknown, listignored, full=full
+).items():
 if not dcontains(fn):
 if (listignored or mexact(fn)) and dirignore(fn):
 if listignored:



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


D12324: commands: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12324

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3910,9 +3910,7 @@
 hexremoterev = hex(remoterev)
 bms = [
 bm
-for bm, bmr in pycompat.iteritems(
-peer.listkeys(b'bookmarks')
-)
+for bm, bmr in peer.listkeys(b'bookmarks').items()
 if bmr == hexremoterev
 ]
 



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


D12325: config: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12325

AFFECTED FILES
  mercurial/config.py

CHANGE DETAILS

diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -14,7 +14,6 @@
 from . import (
 encoding,
 error,
-pycompat,
 util,
 )
 
@@ -110,7 +109,7 @@
 return sorted(self._data.keys())
 
 def items(self, section):
-items = pycompat.iteritems(self._data.get(section, {}))
+items = self._data.get(section, {}).items()
 return [(k, v[0]) for (k, v) in items]
 
 def set(self, section, item, value, source=b""):



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


D12323: remotefilelog: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12323

AFFECTED FILES
  hgext/remotefilelog/shallowutil.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowutil.py 
b/hgext/remotefilelog/shallowutil.py
--- a/hgext/remotefilelog/shallowutil.py
+++ b/hgext/remotefilelog/shallowutil.py
@@ -159,7 +159,7 @@
 length limit is exceeded
 """
 metabuf = b''
-for k, v in sorted(pycompat.iteritems((metadict or {}))):
+for k, v in sorted((metadict or {}).items()):
 if len(k) != 1:
 raise error.ProgrammingError(b'packmeta: illegal key: %s' % k)
 if len(v) > 0xFFFE:
@@ -187,7 +187,7 @@
 and METAKEYFLAG will be dropped if its value is 0.
 """
 newmeta = {}
-for k, v in pycompat.iteritems(metadict or {}):
+for k, v in (metadict or {}).items():
 expectedtype = _metaitemtypes.get(k, (bytes,))
 if not isinstance(v, expectedtype):
 raise error.ProgrammingError(b'packmeta: wrong type of key %s' % k)



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


D12320: infinitepush: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12320

AFFECTED FILES
  hgext/infinitepush/__init__.py

CHANGE DETAILS

diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py
--- a/hgext/infinitepush/__init__.py
+++ b/hgext/infinitepush/__init__.py
@@ -405,7 +405,7 @@
 
 def wireprotolistkeyspatterns(repo, proto, namespace, patterns):
 patterns = wireprototypes.decodelist(patterns)
-d = pycompat.iteritems(repo.listkeys(encoding.tolocal(namespace), 
patterns))
+d = repo.listkeys(encoding.tolocal(namespace), patterns).items()
 return pushkey.encodekeys(d)
 
 



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


D12322: lfs: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12322

AFFECTED FILES
  hgext/lfs/__init__.py
  hgext/lfs/pointer.py

CHANGE DETAILS

diff --git a/hgext/lfs/pointer.py b/hgext/lfs/pointer.py
--- a/hgext/lfs/pointer.py
+++ b/hgext/lfs/pointer.py
@@ -40,7 +40,7 @@
 
 def serialize(self):
 sortkeyfunc = lambda x: (x[0] != b'version', x)
-items = sorted(pycompat.iteritems(self.validate()), key=sortkeyfunc)
+items = sorted(self.validate().items(), key=sortkeyfunc)
 return b''.join(b'%s %s\n' % (k, v) for k, v in items)
 
 def oid(self):
diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -399,7 +399,7 @@
 def pointer(v):
 # In the file spec, version is first and the other keys are sorted.
 sortkeyfunc = lambda x: (x[0] != b'version', x)
-items = sorted(pycompat.iteritems(pointers[v]), key=sortkeyfunc)
+items = sorted(pointers[v].items(), key=sortkeyfunc)
 return util.sortdict(items)
 
 makemap = lambda v: {



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


D12321: largefiles: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12321

AFFECTED FILES
  hgext/largefiles/remotestore.py

CHANGE DETAILS

diff --git a/hgext/largefiles/remotestore.py b/hgext/largefiles/remotestore.py
--- a/hgext/largefiles/remotestore.py
+++ b/hgext/largefiles/remotestore.py
@@ -10,7 +10,6 @@
 
 from mercurial import (
 error,
-pycompat,
 util,
 )
 
@@ -52,9 +51,8 @@
 def exists(self, hashes):
 return {
 h: s == 0
-for (h, s) in pycompat.iteritems(
-self._stat(hashes)
-)  # dict-from-generator
+for (h, s) in self._stat(hashes).items()
+# dict-from-generator
 }
 
 def sendfile(self, filename, hash):



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


D12319: convert: remove pycompat.iteritems()

2022-03-03 Thread indygreg (Gregory Szorc)
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/D12319

AFFECTED FILES
  hgext/convert/cvs.py
  hgext/convert/hg.py

CHANGE DETAILS

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -39,7 +39,6 @@
 merge as mergemod,
 mergestate,
 phases,
-pycompat,
 util,
 )
 from mercurial.utils import dateutil
@@ -423,7 +422,7 @@
 tagparent = tagparent or self.repo.nullid
 
 oldlines = set()
-for branch, heads in pycompat.iteritems(self.repo.branchmap()):
+for branch, heads in self.repo.branchmap().items():
 for h in heads:
 if b'.hgtags' in self.repo[h]:
 oldlines.update(
diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py
--- a/hgext/convert/cvs.py
+++ b/hgext/convert/cvs.py
@@ -18,7 +18,6 @@
 from mercurial import (
 encoding,
 error,
-pycompat,
 util,
 )
 from mercurial.utils import (
@@ -316,7 +315,7 @@
 if full:
 raise error.Abort(_(b"convert from cvs does not support --full"))
 self._parse()
-return sorted(pycompat.iteritems(self.files[rev])), {}, set()
+return sorted(self.files[rev].items()), {}, set()
 
 def getcommit(self, rev):
 self._parse()



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


D12315: setup: drop support for Python 3.5

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We talked about this on the mailing list [1] and there seemed to be
  agreement that Python 3.5 is effectively dead and no longer worth
  supporting.
  
  So this commit changes our minimum version requirement to 3.6.2.
  
  [1] 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2022-February/147885.html

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12315

AFFECTED FILES
  setup.py

CHANGE DETAILS

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -5,17 +5,11 @@
 # 'python setup.py --help' for more options
 import os
 
-# Mercurial will never work on Python 3 before 3.5 due to a lack
-# of % formatting on bytestrings, and can't work on 3.6.0 or 3.6.1
-# due to a bug in % formatting in bytestrings.
-# We cannot support Python 3.5.0, 3.5.1, 3.5.2 because of bug in
-# codecs.escape_encode() where it raises SystemError on empty bytestring
-# bug link: https://bugs.python.org/issue25270
+# Mercurial can't work on 3.6.0 or 3.6.1 due to a bug in % formatting
+# in bytestrings.
 supportedpy = ','.join(
 [
-'>=3.5.3',
-'!=3.6.0',
-'!=3.6.1',
+'>=3.6.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


D12314: stringutil: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12314

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -964,6 +964,4 @@
 def evalpythonliteral(s):
 """Evaluate a string containing a Python literal expression"""
 # We could backport our tokenizer hack to rewrite '' to u'' if we want
-if pycompat.ispy3:
-return ast.literal_eval(s.decode('latin1'))
-return ast.literal_eval(s)
+return ast.literal_eval(s.decode('latin1'))



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


D12313: procutil: delete Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This entailed deleting a function for Python 2 support and renaming the
  Python 3 function to match the exported symbol name.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12313

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -80,7 +80,7 @@
 
 
 def make_line_buffered(stream):
-if pycompat.ispy3 and not isinstance(stream, io.BufferedIOBase):
+if not isinstance(stream, io.BufferedIOBase):
 # On Python 3, buffered streams can be expected to subclass
 # BufferedIOBase. This is definitively the case for the streams
 # initialized by the interpreter. For unbuffered streams, we don't need
@@ -121,7 +121,6 @@
 
 
 def _make_write_all(stream):
-assert pycompat.ispy3
 if isinstance(stream, WriteAllWrapper):
 return stream
 if isinstance(stream, io.BufferedIOBase):
@@ -133,52 +132,32 @@
 return WriteAllWrapper(stream)
 
 
-if pycompat.ispy3:
-# Python 3 implements its own I/O streams. Unlike stdio of C library,
-# sys.stdin/stdout/stderr may be None if underlying fd is closed.
-
-# TODO: .buffer might not exist if std streams were replaced; we'll need
-# a silly wrapper to make a bytes stream backed by a unicode one.
+# Python 3 implements its own I/O streams. Unlike stdio of C library,
+# sys.stdin/stdout/stderr may be None if underlying fd is closed.
 
-if sys.stdin is None:
-stdin = BadFile()
-else:
-stdin = sys.stdin.buffer
-if sys.stdout is None:
-stdout = BadFile()
-else:
-stdout = _make_write_all(sys.stdout.buffer)
-if sys.stderr is None:
-stderr = BadFile()
-else:
-stderr = _make_write_all(sys.stderr.buffer)
+# TODO: .buffer might not exist if std streams were replaced; we'll need
+# a silly wrapper to make a bytes stream backed by a unicode one.
 
-if pycompat.iswindows:
-# Work around Windows bugs.
-stdout = platform.winstdout(stdout)  # pytype: disable=module-attr
-stderr = platform.winstdout(stderr)  # pytype: disable=module-attr
-if isatty(stdout):
-# The standard library doesn't offer line-buffered binary streams.
-stdout = make_line_buffered(stdout)
+if sys.stdin is None:
+stdin = BadFile()
+else:
+stdin = sys.stdin.buffer
+if sys.stdout is None:
+stdout = BadFile()
 else:
-# Python 2 uses the I/O streams provided by the C library.
-stdin = sys.stdin
-stdout = sys.stdout
-stderr = sys.stderr
-if pycompat.iswindows:
-# Work around Windows bugs.
-stdout = platform.winstdout(stdout)  # pytype: disable=module-attr
-stderr = platform.winstdout(stderr)  # pytype: disable=module-attr
-if isatty(stdout):
-if pycompat.iswindows:
-# The Windows C runtime library doesn't support line buffering.
-stdout = make_line_buffered(stdout)
-else:
-# glibc determines buffering on first write to stdout - if we
-# replace a TTY destined stdout with a pipe destined stdout (e.g.
-# pager), we want line buffering.
-stdout = os.fdopen(stdout.fileno(), 'wb', 1)
+stdout = _make_write_all(sys.stdout.buffer)
+if sys.stderr is None:
+stderr = BadFile()
+else:
+stderr = _make_write_all(sys.stderr.buffer)
 
+if pycompat.iswindows:
+# Work around Windows bugs.
+stdout = platform.winstdout(stdout)  # pytype: disable=module-attr
+stderr = platform.winstdout(stderr)  # pytype: disable=module-attr
+if isatty(stdout):
+# The standard library doesn't offer line-buffered binary streams.
+stdout = make_line_buffered(stdout)
 
 findexe = platform.findexe
 _gethgcmd = platform.gethgcmd
@@ -703,7 +682,7 @@
 
 else:
 
-def runbgcommandpy3(
+def runbgcommand(
 cmd,
 env,
 shell=False,
@@ -786,128 +765,3 @@
 returncode = p.wait
 if record_wait is not None:
 record_wait(returncode)
-
-def runbgcommandpy2(
-cmd,
-env,
-shell=False,
-stdout=None,
-stderr=None,
-ensurestart=True,
-record_wait=None,
-stdin_bytes=None,
-):
-"""Spawn a command without waiting for it to finish.
-
-
-When `record_wait` is not None, the spawned process will not be fully
-detached and the `record_wait` argument will be called with a the
-`Subprocess.wait` function for the spawned process.  This is mostly
-useful for developers that need to make sure the spawned process
-finished before a certain point. (eg: writing test)"""
-if pycompat.isdarwin:
-# avoid crash in 

D12312: revlogutils: unconditionally pass version to random seed

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12312

AFFECTED FILES
  mercurial/revlogutils/docket.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/docket.py b/mercurial/revlogutils/docket.py
--- a/mercurial/revlogutils/docket.py
+++ b/mercurial/revlogutils/docket.py
@@ -25,7 +25,6 @@
 encoding,
 error,
 node,
-pycompat,
 util,
 )
 
@@ -65,10 +64,7 @@
 low_part = (int_seed & low_mask) << 28
 int_seed = high_part + low_part + i
 r = random.Random()
-if pycompat.ispy3:
-r.seed(int_seed, version=1)
-else:
-r.seed(int_seed)
+r.seed(int_seed, version=1)
 # once we drop python 3.8 support we can simply use r.randbytes
 raw = r.getrandbits(id_size * 4)
 assert id_size == 8



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


D12311: revlogutils: remove Python 2 variant for iter_seed

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12311

AFFECTED FILES
  mercurial/revlogutils/docket.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/docket.py b/mercurial/revlogutils/docket.py
--- a/mercurial/revlogutils/docket.py
+++ b/mercurial/revlogutils/docket.py
@@ -56,12 +56,7 @@
 if inst.errno != errno.ENOENT:
 raise
 seed = b'04'  # chosen by a fair dice roll. garanteed to be random
-if pycompat.ispy3:
-iter_seed = iter(seed)
-else:
-# pytype: disable=wrong-arg-types
-iter_seed = (ord(c) for c in seed)
-# pytype: enable=wrong-arg-types
+iter_seed = iter(seed)
 # some basic circular sum hashing on 64 bits
 int_seed = 0
 low_mask = int('1' * 35, 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


D12310: charencode: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12310

AFFECTED FILES
  mercurial/pure/charencode.py

CHANGE DETAILS

diff --git a/mercurial/pure/charencode.py b/mercurial/pure/charencode.py
--- a/mercurial/pure/charencode.py
+++ b/mercurial/pure/charencode.py
@@ -67,10 +67,7 @@
 raise ValueError
 
 
-if pycompat.ispy3:
-_utf8strict = r'surrogatepass'
-else:
-_utf8strict = r'strict'
+_utf8strict = r'surrogatepass'
 
 
 def jsonescapeu8fallback(u8chars, paranoid):



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


D12309: hgweb: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12309

AFFECTED FILES
  mercurial/hgweb/server.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -185,18 +185,11 @@
 env['REMOTE_ADDR'] = self.client_address[0]
 env['QUERY_STRING'] = query or ''
 
-if pycompat.ispy3:
-if self.headers.get_content_type() is None:
-env['CONTENT_TYPE'] = self.headers.get_default_type()
-else:
-env['CONTENT_TYPE'] = self.headers.get_content_type()
-length = self.headers.get('content-length')
+if self.headers.get_content_type() is None:
+env['CONTENT_TYPE'] = self.headers.get_default_type()
 else:
-if self.headers.typeheader is None:
-env['CONTENT_TYPE'] = self.headers.type
-else:
-env['CONTENT_TYPE'] = self.headers.typeheader
-length = self.headers.getheader('content-length')
+env['CONTENT_TYPE'] = self.headers.get_content_type()
+length = self.headers.get('content-length')
 if length:
 env['CONTENT_LENGTH'] = length
 for header in [



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


D12300: util: remove superfluous ispy3 test

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12300

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -188,7 +188,7 @@
 warnings.filterwarnings('default', '', DeprecationWarning, 'mercurial')
 warnings.filterwarnings('default', '', DeprecationWarning, 'hgext')
 warnings.filterwarnings('default', '', DeprecationWarning, 'hgext3rd')
-if _dowarn and pycompat.ispy3:
+if _dowarn:
 # silence warning emitted by passing user string to re.sub()
 warnings.filterwarnings(
 'ignore', 'bad escape', DeprecationWarning, 'mercurial'



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


D12307: hgweb: simplify uenv assignment

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We don't need the Python 3 conditional. We can call items() directly
  since we're on Python 3 now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12307

AFFECTED FILES
  mercurial/hgweb/hgwebdir_mod.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -460,12 +460,9 @@
 if real:
 # Re-parse the WSGI environment to take into account our
 # repository path component.
-uenv = req.rawenv
-if pycompat.ispy3:
-uenv = {
-k.decode('latin1'): v
-for k, v in pycompat.iteritems(uenv)
-}
+uenv = {
+k.decode('latin1'): v for k, v in req.rawenv.items()
+}
 req = requestmod.parserequestfromenv(
 uenv,
 reponame=virtualrepo,



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


D12308: hgweb: remove Python 3 conditional

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We probably have a better tobytes() implementation somewhere in pycompat.
  But I don't want to bloat scope of this commit.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12308

AFFECTED FILES
  mercurial/hgweb/request.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py
--- a/mercurial/hgweb/request.py
+++ b/mercurial/hgweb/request.py
@@ -164,20 +164,18 @@
 # (bytes on Python 2 and str on Python 3). The code points for the Unicode
 # strings on Python 3 must be between \0-\000FF. We deal with bytes
 # in Mercurial, so mass convert string keys and values to bytes.
-if pycompat.ispy3:
+def tobytes(s):
+if not isinstance(s, str):
+return s
+if pycompat.iswindows:
+# This is what mercurial.encoding does for os.environ on
+# Windows.
+return encoding.strtolocal(s)
+else:
+# This is what is documented to be used for os.environ on Unix.
+return pycompat.fsencode(s)
 
-def tobytes(s):
-if not isinstance(s, str):
-return s
-if pycompat.iswindows:
-# This is what mercurial.encoding does for os.environ on
-# Windows.
-return encoding.strtolocal(s)
-else:
-# This is what is documented to be used for os.environ on Unix.
-return pycompat.fsencode(s)
-
-env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)}
+env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)}
 
 # Some hosting solutions are emulating hgwebdir, and dispatching directly
 # to an hgweb instance using this environment variable.  This was always



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


D12306: chgserver: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The logic here is more complicated than most Python 2/3 support code.
  But the rewritten logic should be identical.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12306

AFFECTED FILES
  mercurial/chgserver.py

CHANGE DETAILS

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -439,16 +439,13 @@
 ui = self.ui
 for (ch, fp, fd), (cn, fn, mode) in zip(self._oldios, _iochannels):
 newfp = getattr(ui, fn)
-# On Python 2, newfp and fp may be separate file objects associated
-# with the same fd, so we must close newfp while it's associated
-# with the client. Otherwise the new associated fd would be closed
-# when newfp gets deleted. On Python 3, newfp is just a wrapper
-# around fp even if newfp is not fp, so deleting newfp is safe.
-if not (pycompat.ispy3 or newfp is fp):
+# On Python 3, newfp is just a wrapper around fp even if newfp is
+# not fp, so deleting newfp is safe.
+if newfp is not fp:
 newfp.close()
 # restore original fd: fp is open again
 try:
-if (pycompat.ispy3 or newfp is fp) and 'w' in mode:
+if newfp is fp and 'w' in mode:
 # Discard buffered data which couldn't be flushed because
 # of EPIPE. The data should belong to the current session
 # and should never persist.



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


D12305: chgserver: remove Python 2 branch

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12305

AFFECTED FILES
  mercurial/chgserver.py

CHANGE DETAILS

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -408,22 +408,13 @@
 # be unbuffered no matter if it is a tty or not.
 if fn == b'ferr':
 newfp = fp
-elif pycompat.ispy3:
+else:
 # On Python 3, the standard library doesn't offer line-buffered
 # binary streams, so wrap/unwrap it.
 if fp.isatty():
 newfp = procutil.make_line_buffered(fp)
 else:
 newfp = procutil.unwrap_line_buffered(fp)
-else:
-# Python 2 uses the I/O streams provided by the C library, so
-# make it line-buffered explicitly. Otherwise the default would
-# be decided on first write(), where fout could be a pager.
-if fp.isatty():
-bufsize = 1  # line buffered
-else:
-bufsize = -1  # system default
-newfp = os.fdopen(fp.fileno(), mode, bufsize)
 if newfp is not fp:
 setattr(ui, fn, newfp)
 setattr(self, cn, newfp)



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


D12303: wireprotoframing: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12303

AFFECTED FILES
  mercurial/wireprotoframing.py

CHANGE DETAILS

diff --git a/mercurial/wireprotoframing.py b/mercurial/wireprotoframing.py
--- a/mercurial/wireprotoframing.py
+++ b/mercurial/wireprotoframing.py
@@ -761,11 +761,6 @@
 self._decompressor = zlib.decompressobj()
 
 def decode(self, data):
-# Python 2's zlib module doesn't use the buffer protocol and can't
-# handle all bytes-like types.
-if not pycompat.ispy3 and isinstance(data, bytearray):
-data = bytes(data)
-
 return self._decompressor.decompress(data)
 
 



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


D12304: worker: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12304

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -64,50 +64,39 @@
 return min(max(countcpus(), 4), 32)
 
 
-if pycompat.ispy3:
+def ismainthread():
+return threading.current_thread() == threading.main_thread()
 
-def ismainthread():
-return threading.current_thread() == threading.main_thread()
-
-class _blockingreader(object):
-def __init__(self, wrapped):
-self._wrapped = wrapped
 
-# Do NOT implement readinto() by making it delegate to
-# _wrapped.readinto(), since that is unbuffered. The unpickler is fine
-# with just read() and readline(), so we don't need to implement it.
+class _blockingreader(object):
+def __init__(self, wrapped):
+self._wrapped = wrapped
 
-def readline(self):
-return self._wrapped.readline()
+# Do NOT implement readinto() by making it delegate to
+# _wrapped.readinto(), since that is unbuffered. The unpickler is fine
+# with just read() and readline(), so we don't need to implement it.
 
-# issue multiple reads until size is fulfilled
-def read(self, size=-1):
-if size < 0:
-return self._wrapped.readall()
+def readline(self):
+return self._wrapped.readline()
 
-buf = bytearray(size)
-view = memoryview(buf)
-pos = 0
+# issue multiple reads until size is fulfilled
+def read(self, size=-1):
+if size < 0:
+return self._wrapped.readall()
 
-while pos < size:
-ret = self._wrapped.readinto(view[pos:])
-if not ret:
-break
-pos += ret
+buf = bytearray(size)
+view = memoryview(buf)
+pos = 0
 
-del view
-del buf[pos:]
-return bytes(buf)
-
-else:
+while pos < size:
+ret = self._wrapped.readinto(view[pos:])
+if not ret:
+break
+pos += ret
 
-def ismainthread():
-# pytype: disable=module-attr
-return isinstance(threading.current_thread(), threading._MainThread)
-# pytype: enable=module-attr
-
-def _blockingreader(wrapped):
-return wrapped
+del view
+del buf[pos:]
+return bytes(buf)
 
 
 if pycompat.isposix or pycompat.iswindows:



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


D12302: windows: remove write throttling support

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This mode would only be active on Python 2, which is no longer supported.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12302

AFFECTED FILES
  mercurial/windows.py

CHANGE DETAILS

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -225,7 +225,6 @@
 
 def __init__(self, fp):
 self.fp = fp
-self.throttle = not pycompat.ispy3 and _isatty(fp)
 
 def __getattr__(self, key):
 return getattr(self.fp, key)
@@ -238,17 +237,7 @@
 
 def write(self, s):
 try:
-if not self.throttle:
-return self.fp.write(s)
-# This is workaround for "Not enough space" error on
-# writing large size of data to console.
-limit = 16000
-l = len(s)
-start = 0
-while start < l:
-end = start + limit
-self.fp.write(s[start:end])
-start = end
+return self.fp.write(s)
 except IOError as inst:
 if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst):
 raise



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


D12301: windows: remove conditional for Python 3

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12301

AFFECTED FILES
  mercurial/windows.py

CHANGE DETAILS

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -162,8 +162,7 @@
 
 # PyFile_FromFd() ignores the name, and seems to report fp.name as the
 # underlying file descriptor.
-if pycompat.ispy3:
-fp = fdproxy(name, fp)
+fp = fdproxy(name, fp)
 
 # The position when opening in append mode is implementation defined, 
so
 # make it consistent with other platforms, which position at EOF.



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


D12298: keepalive: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12298

AFFECTED FILES
  mercurial/keepalive.py

CHANGE DETAILS

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -398,12 +398,8 @@
 # modification from socket.py
 
 def __init__(self, sock, debuglevel=0, strict=0, method=None):
-extrakw = {}
-if not pycompat.ispy3:
-extrakw['strict'] = True
-extrakw['buffering'] = True
 httplib.HTTPResponse.__init__(
-self, sock, debuglevel=debuglevel, method=method, **extrakw
+self, sock, debuglevel=debuglevel, method=method
 )
 self.fileno = sock.fileno
 self.code = 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


D12297: extensions: remove superfluous pycompat.ispy3 check

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is always True now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12297

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -875,7 +875,7 @@
 a = node.args[0]
 if isinstance(a, ast.Str):
 name = pycompat.sysbytes(a.s)
-elif pycompat.ispy3 and isinstance(a, ast.Bytes):
+elif isinstance(a, ast.Bytes):
 name = a.s
 else:
 continue



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


D12294: dispatch: remove Python 2 function variants

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12294

AFFECTED FILES
  mercurial/dispatch.py

CHANGE DETAILS

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -149,92 +149,76 @@
 sys.exit(status & 255)
 
 
-if pycompat.ispy3:
-
-def initstdio():
-# stdio streams on Python 3 are io.TextIOWrapper instances proxying 
another
-# buffer. These streams will normalize \n to \r\n by default. 
Mercurial's
-# preferred mechanism for writing output (ui.write()) uses 
io.BufferedWriter
-# instances, which write to the underlying stdio file descriptor in 
binary
-# mode. ui.write() uses \n for line endings and no line ending 
normalization
-# is attempted through this interface. This "just works," even if the 
system
-# preferred line ending is not \n.
-#
-# But some parts of Mercurial (e.g. hooks) can still send data to 
sys.stdout
-# and sys.stderr. They will inherit the line ending normalization 
settings,
-# potentially causing e.g. \r\n to be emitted. Since emitting \n should
-# "just work," here we change the sys.* streams to disable line ending
-# normalization, ensuring compatibility with our ui type.
+def initstdio():
+# stdio streams on Python 3 are io.TextIOWrapper instances proxying another
+# buffer. These streams will normalize \n to \r\n by default. Mercurial's
+# preferred mechanism for writing output (ui.write()) uses 
io.BufferedWriter
+# instances, which write to the underlying stdio file descriptor in binary
+# mode. ui.write() uses \n for line endings and no line ending 
normalization
+# is attempted through this interface. This "just works," even if the 
system
+# preferred line ending is not \n.
+#
+# But some parts of Mercurial (e.g. hooks) can still send data to 
sys.stdout
+# and sys.stderr. They will inherit the line ending normalization settings,
+# potentially causing e.g. \r\n to be emitted. Since emitting \n should
+# "just work," here we change the sys.* streams to disable line ending
+# normalization, ensuring compatibility with our ui type.
 
-if sys.stdout is not None:
-# write_through is new in Python 3.7.
-kwargs = {
-"newline": "\n",
-"line_buffering": sys.stdout.line_buffering,
-}
-if util.safehasattr(sys.stdout, "write_through"):
-# pytype: disable=attribute-error
-kwargs["write_through"] = sys.stdout.write_through
-# pytype: enable=attribute-error
-sys.stdout = io.TextIOWrapper(
-sys.stdout.buffer,
-sys.stdout.encoding,
-sys.stdout.errors,
-**kwargs
-)
+if sys.stdout is not None:
+# write_through is new in Python 3.7.
+kwargs = {
+"newline": "\n",
+"line_buffering": sys.stdout.line_buffering,
+}
+if util.safehasattr(sys.stdout, "write_through"):
+# pytype: disable=attribute-error
+kwargs["write_through"] = sys.stdout.write_through
+# pytype: enable=attribute-error
+sys.stdout = io.TextIOWrapper(
+sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, **kwargs
+)
 
-if sys.stderr is not None:
-kwargs = {
-"newline": "\n",
-"line_buffering": sys.stderr.line_buffering,
-}
-if util.safehasattr(sys.stderr, "write_through"):
-# pytype: disable=attribute-error
-kwargs["write_through"] = sys.stderr.write_through
-# pytype: enable=attribute-error
-sys.stderr = io.TextIOWrapper(
-sys.stderr.buffer,
-sys.stderr.encoding,
-sys.stderr.errors,
-**kwargs
-)
+if sys.stderr is not None:
+kwargs = {
+"newline": "\n",
+"line_buffering": sys.stderr.line_buffering,
+}
+if util.safehasattr(sys.stderr, "write_through"):
+# pytype: disable=attribute-error
+kwargs["write_through"] = sys.stderr.write_through
+# pytype: enable=attribute-error
+sys.stderr = io.TextIOWrapper(
+sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, **kwargs
+)
 
-if sys.stdin is not None:
-# No write_through on read-only stream.
-sys.stdin = io.TextIOWrapper(
-sys.stdin.buffer,
-sys.stdin.encoding,
-sys.stdin.errors,
-# None is universal newlines mode.
-  

D12299: urllibcompat: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We had to move the `import` statements to appease the import checker.
  
  This whole module could probably be deleted as its point in life is to
  pave over Python 2/3 differences. But that's for a different commit.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12299

AFFECTED FILES
  mercurial/urllibcompat.py

CHANGE DETAILS

diff --git a/mercurial/urllibcompat.py b/mercurial/urllibcompat.py
--- a/mercurial/urllibcompat.py
+++ b/mercurial/urllibcompat.py
@@ -5,6 +5,12 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import http.server
+import urllib.error
+import urllib.parse
+import urllib.request
+import urllib.response
+
 from .pycompat import getattr
 from . import pycompat
 
@@ -39,198 +45,109 @@
 urlreq = _pycompatstub()
 urlerr = _pycompatstub()
 
-if pycompat.ispy3:
-import urllib.parse
-
-urlreq._registeraliases(
-urllib.parse,
-(
-b"splitattr",
-b"splitpasswd",
-b"splitport",
-b"splituser",
-b"urlparse",
-b"urlunparse",
-),
-)
-urlreq._registeralias(urllib.parse, b"parse_qs", b"parseqs")
-urlreq._registeralias(urllib.parse, b"parse_qsl", b"parseqsl")
-urlreq._registeralias(urllib.parse, b"unquote_to_bytes", b"unquote")
-import urllib.request
-
-urlreq._registeraliases(
-urllib.request,
-(
-b"AbstractHTTPHandler",
-b"BaseHandler",
-b"build_opener",
-b"FileHandler",
-b"FTPHandler",
-b"ftpwrapper",
-b"HTTPHandler",
-b"HTTPSHandler",
-b"install_opener",
-b"pathname2url",
-b"HTTPBasicAuthHandler",
-b"HTTPDigestAuthHandler",
-b"HTTPPasswordMgrWithDefaultRealm",
-b"ProxyHandler",
-b"Request",
-b"url2pathname",
-b"urlopen",
-),
-)
-import urllib.response
+urlreq._registeraliases(
+urllib.parse,
+(
+b"splitattr",
+b"splitpasswd",
+b"splitport",
+b"splituser",
+b"urlparse",
+b"urlunparse",
+),
+)
+urlreq._registeralias(urllib.parse, b"parse_qs", b"parseqs")
+urlreq._registeralias(urllib.parse, b"parse_qsl", b"parseqsl")
+urlreq._registeralias(urllib.parse, b"unquote_to_bytes", b"unquote")
 
-urlreq._registeraliases(
-urllib.response,
-(
-b"addclosehook",
-b"addinfourl",
-),
-)
-import urllib.error
-
-urlerr._registeraliases(
-urllib.error,
-(
-b"HTTPError",
-b"URLError",
-),
-)
-import http.server
+urlreq._registeraliases(
+urllib.request,
+(
+b"AbstractHTTPHandler",
+b"BaseHandler",
+b"build_opener",
+b"FileHandler",
+b"FTPHandler",
+b"ftpwrapper",
+b"HTTPHandler",
+b"HTTPSHandler",
+b"install_opener",
+b"pathname2url",
+b"HTTPBasicAuthHandler",
+b"HTTPDigestAuthHandler",
+b"HTTPPasswordMgrWithDefaultRealm",
+b"ProxyHandler",
+b"Request",
+b"url2pathname",
+b"urlopen",
+),
+)
 
-httpserver._registeraliases(
-http.server,
-(
-b"HTTPServer",
-b"BaseHTTPRequestHandler",
-b"SimpleHTTPRequestHandler",
-b"CGIHTTPRequestHandler",
-),
-)
 
-# urllib.parse.quote() accepts both str and bytes, decodes bytes
-# (if necessary), and returns str. This is wonky. We provide a custom
-# implementation that only accepts bytes and emits bytes.
-def quote(s, safe='/'):
-# bytestr has an __iter__ that emits characters. quote_from_bytes()
-# does an iteration and expects ints. We coerce to bytes to appease it.
-if isinstance(s, pycompat.bytestr):
-s = bytes(s)
-s = urllib.parse.quote_from_bytes(s, safe=safe)
-return s.encode('ascii', 'strict')
-
-# urllib.parse.urlencode() returns str. We use this function to make
-# sure we return bytes.
-def urlencode(query, doseq=False):
-s = urllib.parse.urlencode(query, doseq=doseq)
-return s.encode('ascii')
-
-urlreq.quote = quote
-urlreq.urlencode = urlencode
-
-def getfullurl(req):
-return req.full_url
-
-def gethost(req):
-return req.host
+urlreq._registeraliases(
+urllib.response,
+(
+b"addclosehook",
+b"addinfourl",
+),
+)
 
-def getselector(req):
-return req.selector
-
-def getdata(req):
-return req.data
-
-def hasdata(req):
-return req.data is not None

D12296: archival: remove check for Python 2

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12296

AFFECTED FILES
  mercurial/archival.py

CHANGE DETAILS

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -305,9 +305,6 @@
 subrepos tells whether to include subrepos.
 """
 
-if kind == b'txz' and not pycompat.ispy3:
-raise error.Abort(_(b'xz compression is only available in Python 3'))
-
 if kind == b'files':
 if prefix:
 raise error.Abort(_(b'cannot give prefix when archiving to files'))



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


D12295: encoding: remove Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12295

AFFECTED FILES
  mercurial/encoding.py

CHANGE DETAILS

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -46,8 +46,7 @@
 
 _sysstr = pycompat.sysstr
 
-if pycompat.ispy3:
-unichr = chr
+unichr = chr
 
 # These unicode characters are ignored by HFS+ (Apple Technote 1150,
 # "Unicode Subtleties"), so we need to ignore them in some places for
@@ -78,10 +77,8 @@
 
 # encoding.environ is provided read-only, which may not be used to modify
 # the process environment
-_nativeenviron = not pycompat.ispy3 or os.supports_bytes_environ
-if not pycompat.ispy3:
-environ = os.environ  # re-exports
-elif _nativeenviron:
+_nativeenviron = os.supports_bytes_environ
+if _nativeenviron:
 environ = os.environb  # re-exports
 else:
 # preferred encoding isn't known yet; use utf-8 to avoid unicode error
@@ -98,7 +95,7 @@
 # cp65001 is a Windows variant of utf-8, which isn't supported on Python 2.
 # No idea if it should be rewritten to the canonical name 'utf-8' on Python 3.
 # https://bugs.python.org/issue13216
-if pycompat.iswindows and not pycompat.ispy3:
+if pycompat.iswindows:
 _encodingrewrites[b'cp65001'] = b'utf-8'
 
 try:
@@ -270,21 +267,9 @@
 # converter functions between native str and byte string. use these if the
 # character encoding is not aware (e.g. exception message) or is known to
 # be locale dependent (e.g. date formatting.)
-if pycompat.ispy3:
-strtolocal = unitolocal
-strfromlocal = unifromlocal
-strmethod = unimethod
-else:
-
-def strtolocal(s):
-# type: (str) -> bytes
-return s  # pytype: disable=bad-return-type
-
-def strfromlocal(s):
-# type: (bytes) -> str
-return s  # pytype: disable=bad-return-type
-
-strmethod = pycompat.identity
+strtolocal = unitolocal
+strfromlocal = unifromlocal
+strmethod = unimethod
 
 
 def lower(s):
@@ -344,7 +329,7 @@
 if not _nativeenviron:
 # now encoding and helper functions are available, recreate the environ
 # dict to be exported to other modules
-if pycompat.iswindows and pycompat.ispy3:
+if pycompat.iswindows:
 
 class WindowsEnviron(dict):
 """`os.environ` normalizes environment variables to uppercase on 
windows"""
@@ -360,36 +345,33 @@
 
 DRIVE_RE = re.compile(b'^[a-z]:')
 
-if pycompat.ispy3:
-# os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
-# returns bytes.
-if pycompat.iswindows:
-# Python 3 on Windows issues a DeprecationWarning about using the bytes
-# API when os.getcwdb() is called.
-#
-# Additionally, py3.8+ uppercases the drive letter when calling
-# os.path.realpath(), which is used on ``repo.root``.  Since those
-# strings are compared in various places as simple strings, also call
-# realpath here.  See https://bugs.python.org/issue40368
-#
-# However this is not reliable, so lets explicitly make this drive
-# letter upper case.
-#
-# note: we should consider dropping realpath here since it seems to
-# change the semantic of `getcwd`.
+# os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
+# returns bytes.
+if pycompat.iswindows:
+# Python 3 on Windows issues a DeprecationWarning about using the bytes
+# API when os.getcwdb() is called.
+#
+# Additionally, py3.8+ uppercases the drive letter when calling
+# os.path.realpath(), which is used on ``repo.root``.  Since those
+# strings are compared in various places as simple strings, also call
+# realpath here.  See https://bugs.python.org/issue40368
+#
+# However this is not reliable, so lets explicitly make this drive
+# letter upper case.
+#
+# note: we should consider dropping realpath here since it seems to
+# change the semantic of `getcwd`.
 
-def getcwd():
-cwd = os.getcwd()  # re-exports
-cwd = os.path.realpath(cwd)
-cwd = strtolocal(cwd)
-if DRIVE_RE.match(cwd):
-cwd = cwd[0:1].upper() + cwd[1:]
-return cwd
+def getcwd():
+cwd = os.getcwd()  # re-exports
+cwd = os.path.realpath(cwd)
+cwd = strtolocal(cwd)
+if DRIVE_RE.match(cwd):
+cwd = cwd[0:1].upper() + cwd[1:]
+return cwd
 
-else:
-getcwd = os.getcwdb  # re-exports
 else:
-getcwd = os.getcwd  # re-exports
+getcwd = os.getcwdb  # re-exports
 
 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide.
 _wide = _sysstr(
@@ -600,10 +582,7 @@
 
 # We need to decode/encode U+DCxx codes transparently since invalid UTF-8
 # bytes are mapped to that range.
-if 

D12291: formatter: remove conditional assert

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We always run on Python 3 now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12291

AFFECTED FILES
  mercurial/formatter.py

CHANGE DETAILS

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -558,8 +558,7 @@
 
 
 def literal_templatespec(tmpl):
-if pycompat.ispy3:
-assert not isinstance(tmpl, str), b'tmpl must not be a str'
+assert not isinstance(tmpl, str), b'tmpl must not be a str'
 return templatespec(b'', tmpl, 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


D12292: error: unconditionally define __str__

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We always run on Python 3 now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12292

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -68,14 +68,12 @@
 def __bytes__(self):
 return self.message
 
-if pycompat.ispy3:
-
-def __str__(self):
-# type: () -> str
-# the output would be unreadable if the message was translated,
-# but do not replace it with encoding.strfromlocal(), which
-# may raise another exception.
-return pycompat.sysstr(self.__bytes__())
+def __str__(self):
+# type: () -> str
+# the output would be unreadable if the message was translated,
+# but do not replace it with encoding.strfromlocal(), which
+# may raise another exception.
+return pycompat.sysstr(self.__bytes__())
 
 def format(self):
 # type: () -> bytes



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


D12293: config: remove conditional asserts

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We always run on Python 3 now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12293

AFFECTED FILES
  mercurial/config.py

CHANGE DETAILS

diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -114,16 +114,15 @@
 return [(k, v[0]) for (k, v) in items]
 
 def set(self, section, item, value, source=b""):
-if pycompat.ispy3:
-assert not isinstance(
-section, str
-), b'config section may not be unicode strings on Python 3'
-assert not isinstance(
-item, str
-), b'config item may not be unicode strings on Python 3'
-assert not isinstance(
-value, str
-), b'config values may not be unicode strings on Python 3'
+assert not isinstance(
+section, str
+), b'config section may not be unicode strings on Python 3'
+assert not isinstance(
+item, str
+), b'config item may not be unicode strings on Python 3'
+assert not isinstance(
+value, str
+), b'config values may not be unicode strings on Python 3'
 if section not in self:
 self._data[section] = util.cowsortdict()
 else:



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


D12287: match: delete Python 2 conditional code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12287

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -583,10 +583,7 @@
 if b'' in prefix_set:
 return True
 
-if pycompat.ispy3:
-sl = ord(b'/')
-else:
-sl = '/'
+sl = ord(b'/')
 
 # We already checked that path isn't in prefix_set exactly, so
 # `path[len(pf)] should never raise IndexError.



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


D12290: httppeer: inline simplified _reqdata()

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The function can be reduced to an attribute lookup on Python 3. So
  inline it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12290

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -231,15 +231,6 @@
 return req, cu, qs
 
 
-def _reqdata(req):
-"""Get request data, if any. If no data, returns None."""
-if pycompat.ispy3:
-return req.data
-if not req.has_data():
-return None
-return req.get_data()
-
-
 def sendrequest(ui, opener, req):
 """Send a prepared HTTP request.
 
@@ -274,7 +265,7 @@
 % b'  %d bytes of commands arguments in headers'
 % hgargssize
 )
-data = _reqdata(req)
+data = req.data
 if data is not None:
 length = getattr(data, 'length', None)
 if length is 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


D12289: url: remove passing of strict

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This was needed to support Python 2.7.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12289

AFFECTED FILES
  mercurial/url.py

CHANGE DETAILS

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -246,13 +246,9 @@
 
 # majority of the following code is duplicated from
 # httplib.HTTPConnection as there are no adequate places to
-# override functions to provide the needed functionality
-# strict was removed in Python 3.4.
-kwargs = {}
-if not pycompat.ispy3:
-kwargs[b'strict'] = self.strict
+# override functions to provide the needed functionality.
 
-res = self.response_class(self.sock, method=self._method, **kwargs)
+res = self.response_class(self.sock, method=self._method)
 
 while True:
 version, status, reason = res._read_status()



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


D12288: posix: delete Python 2 support code

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12288

AFFECTED FILES
  mercurial/posix.py

CHANGE DETAILS

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -59,20 +59,9 @@
 umask = os.umask(0)
 os.umask(umask)
 
-if not pycompat.ispy3:
-
-def posixfile(name, mode='r', buffering=-1):
-fp = open(name, mode=mode, buffering=buffering)
-# The position when opening in append mode is implementation defined, 
so
-# make it consistent by always seeking to the end.
-if 'a' in mode:
-fp.seek(0, os.SEEK_END)
-return fp
-
-else:
-# The underlying file object seeks as required in Python 3:
-# https://github.com/python/cpython/blob/v3.7.3/Modules/_io/fileio.c#L474
-posixfile = open
+# The underlying file object seeks as required in Python 3:
+# https://github.com/python/cpython/blob/v3.7.3/Modules/_io/fileio.c#L474
+posixfile = open
 
 
 def split(p):



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


D12286: mail: delete conditional code for Python 2

2022-03-02 Thread indygreg (Gregory Szorc)
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/D12286

AFFECTED FILES
  mercurial/mail.py

CHANGE DETAILS

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -467,42 +467,28 @@
 return mimetextqp(s, 'plain', cs)
 
 
-if pycompat.ispy3:
-
-Generator = email.generator.BytesGenerator
+Generator = email.generator.BytesGenerator
 
-def parse(fp):
-# type: (Any) -> email.message.Message
-ep = email.parser.Parser()
-# disable the "universal newlines" mode, which isn't binary safe.
-# I have no idea if ascii/surrogateescape is correct, but that's
-# what the standard Python email parser does.
-fp = io.TextIOWrapper(
-fp, encoding='ascii', errors='surrogateescape', newline=chr(10)
-)
-try:
-return ep.parse(fp)
-finally:
-fp.detach()
 
-def parsebytes(data):
-# type: (bytes) -> email.message.Message
-ep = email.parser.BytesParser()
-return ep.parsebytes(data)
-
-else:
-
-Generator = email.generator.Generator
+def parse(fp):
+# type: (Any) -> email.message.Message
+ep = email.parser.Parser()
+# disable the "universal newlines" mode, which isn't binary safe.
+# I have no idea if ascii/surrogateescape is correct, but that's
+# what the standard Python email parser does.
+fp = io.TextIOWrapper(
+fp, encoding='ascii', errors='surrogateescape', newline=chr(10)
+)
+try:
+return ep.parse(fp)
+finally:
+fp.detach()
 
-def parse(fp):
-# type: (Any) -> email.message.Message
-ep = email.parser.Parser()
-return ep.parse(fp)
 
-def parsebytes(data):
-# type: (str) -> email.message.Message
-ep = email.parser.Parser()
-return ep.parsestr(data)
+def parsebytes(data):
+# type: (bytes) -> email.message.Message
+ep = email.parser.BytesParser()
+return ep.parsebytes(data)
 
 
 def headdecode(s):



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


D12284: check-code: allow importing Python 3 modules

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Now that we no longer support Python 2, we should be able to import and
  use the Python 3 only modules in our code. So remove a lint banning this.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12284

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -430,24 +430,6 @@
 "module-level @cachefunc is risky, please avoid",
 ),
 (
-r'^import Queue',
-"don't use Queue, use pycompat.queue.Queue + "
-"pycompat.queue.Empty",
-),
-(
-r'^import cStringIO',
-"don't use cStringIO.StringIO, use util.stringio",
-),
-(r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"),
-(
-r'^import SocketServer',
-"don't use SockerServer, use util.socketserver",
-),
-(r'^import urlparse', "don't use urlparse, use util.urlreq"),
-(r'^import xmlrpclib', "don't use xmlrpclib, use util.xmlrpclib"),
-(r'^import httplib', "don't use httplib, use util.httplib"),
-(r'^import BaseHTTPServer', "use util.httpserver instead"),
-(
 r'^(from|import) mercurial\.(cext|pure|cffi)',
 "use mercurial.policy.importmod instead",
 ),



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


D12285: archival: remove GzipFileWithTime

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This was required for Python 2 support, which we no longer need to support.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12285

AFFECTED FILES
  mercurial/archival.py

CHANGE DETAILS

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -136,39 +136,6 @@
 """write archive to tar file or stream.  can write uncompressed,
 or compress with gzip or bzip2."""
 
-if pycompat.ispy3:
-GzipFileWithTime = gzip.GzipFile  # camelcase-required
-else:
-
-class GzipFileWithTime(gzip.GzipFile):
-def __init__(self, *args, **kw):
-timestamp = None
-if 'mtime' in kw:
-timestamp = kw.pop('mtime')
-if timestamp is None:
-self.timestamp = time.time()
-else:
-self.timestamp = timestamp
-gzip.GzipFile.__init__(self, *args, **kw)
-
-def _write_gzip_header(self):
-self.fileobj.write(b'\037\213')  # magic header
-self.fileobj.write(b'\010')  # compression method
-fname = self.name
-if fname and fname.endswith(b'.gz'):
-fname = fname[:-3]
-flags = 0
-if fname:
-flags = gzip.FNAME  # pytype: disable=module-attr
-self.fileobj.write(pycompat.bytechr(flags))
-gzip.write32u(  # pytype: disable=module-attr
-self.fileobj, int(self.timestamp)
-)
-self.fileobj.write(b'\002')
-self.fileobj.write(b'\377')
-if fname:
-self.fileobj.write(fname + b'\000')
-
 def __init__(self, dest, mtime, kind=b''):
 self.mtime = mtime
 self.fileobj = None
@@ -178,7 +145,7 @@
 mode = mode[0:1]
 if not fileobj:
 fileobj = open(name, mode + b'b')
-gzfileobj = self.GzipFileWithTime(
+gzfileobj = gzip.GzipFile(
 name,
 pycompat.sysstr(mode + b'b'),
 zlib.Z_BEST_COMPRESSION,



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


D12265: packaging: remove py2exe / Python 2.7 support

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This commit started by deleting references to py2exe (which is only used
  on Python 2). After pulling the thread, quite a lot of code was orphaned
  and was deleted.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12265

AFFECTED FILES
  contrib/packaging/hgpackaging/cli.py
  contrib/packaging/hgpackaging/downloads.py
  contrib/packaging/hgpackaging/inno.py
  contrib/packaging/hgpackaging/py2exe.py
  contrib/packaging/hgpackaging/util.py
  contrib/packaging/hgpackaging/wix.py
  contrib/packaging/requirements-windows-py2.txt
  tests/test-check-code.t

CHANGE DETAILS

diff --git a/tests/test-check-code.t b/tests/test-check-code.t
--- a/tests/test-check-code.t
+++ b/tests/test-check-code.t
@@ -27,7 +27,6 @@
   Skipping contrib/packaging/hgpackaging/cli.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/downloads.py it has no-che?k-code 
(glob)
   Skipping contrib/packaging/hgpackaging/inno.py it has no-che?k-code (glob)
-  Skipping contrib/packaging/hgpackaging/py2exe.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/pyoxidizer.py it has no-che?k-code 
(glob)
   Skipping contrib/packaging/hgpackaging/util.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/wix.py it has no-che?k-code (glob)
diff --git a/contrib/packaging/requirements-windows-py2.txt 
b/contrib/packaging/requirements-windows-py2.txt
deleted file mode 100644
--- a/contrib/packaging/requirements-windows-py2.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# This file is autogenerated by pip-compile
-# To update, run:
-#
-#pip-compile --generate-hashes 
--output-file=contrib/packaging/requirements-windows-py2.txt 
contrib/packaging/requirements-windows.txt.in
-#
-certifi==2021.5.30 \
-
--hash=sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee \
-
--hash=sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8 \
-# via dulwich
-configparser==4.0.2 \
-
--hash=sha256:254c1d9c79f60c45dfde850850883d5aaa7f19a23f13561243a050d5a7c3fe4c \
-
--hash=sha256:c7d282687a5308319bf3d2e7706e575c635b0a470342641c93bea0ea3b5331df \
-# via entrypoints
-docutils==0.16 \
-
--hash=sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af \
-
--hash=sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc \
-# via -r contrib/packaging/requirements-windows.txt.in
-dulwich==0.19.16 ; python_version <= "2.7" \
-
--hash=sha256:10699277c6268d0c16febe141a5b1c1a6e9744f3144c2d2de1706f4b1adafe63 \
-
--hash=sha256:267160904e9a1cb6c248c5efc53597a35d038ecc6f60bdc4546b3053bed11982 \
-
--hash=sha256:4e3aba5e4844e7c700721c1fc696987ea820ee3528a03604dc4e74eff4196826 \
-
--hash=sha256:60bb2c2c92f5025c1b53a556304008f0f624c98ae36f22d870e056b2d4236c11 \
-
--hash=sha256:dddae02d372fc3b5cfb0046d0f62246ef281fa0c088df7601ab5916607add94b \
-
--hash=sha256:f00d132082b8fcc2eb0d722abc773d4aeb5558c1475d7edd1f0f571146c29db9 \
-
--hash=sha256:f74561c448bfb6f04c07de731c1181ae4280017f759b0bb04fa5770aa84ca850 \
-# via -r contrib/packaging/requirements-windows.txt.in
-entrypoints==0.3 \
-
--hash=sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19 \
-
--hash=sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451 \
-# via keyring
-keyring==18.0.1 \
-
--hash=sha256:67d6cc0132bd77922725fae9f18366bb314fd8f95ff4d323a4df41890a96a838 \
-
--hash=sha256:7b29ebfcf8678c4da531b2478a912eea01e80007e5ddca9ee0c7038cb3489ec6 \
-# via -r contrib/packaging/requirements-windows.txt.in
-pygments==2.5.2 \
-
--hash=sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b \
-
--hash=sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe \
-# via -r contrib/packaging/requirements-windows.txt.in
-pywin32-ctypes==0.2.0 \
-
--hash=sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942 \
-
--hash=sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98 \
-# via -r contrib/packaging/requirements-windows.txt.in, keyring
-urllib3==1.25.11 \
-
--hash=sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2 \
-
--hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e \
-# via dulwich
-windows-curses==2.1.0 \
-
--hash=sha256:261fde5680d1ce4ce116908996b9a3cfb0ffb03ea68d42240f62b56a9fa6af2c \
-
--hash=sha256:66034dc9a705d87308cc9ea90836f4ee60008a1d5e2c1d34ace627f60268158b \
-
--hash=sha256:669caad3ae16faf2d201d7ab3b8af418a2fd074d8a39d60ca26f3acb34b6afe5 \
-
--hash=sha256:73bd3eebccfda55330783f165151de115bfa238d1332f0b2e224b550d6187840 \
-
--hash=sha256:89a6d973f88cfe49b41ea80164dcbec209d296e0cec34a02002578b0bf464a64 \
-

D12267: packaging: remove requirements constraints to support Python 2

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We just deleted support for Python 2 from the packaging code. We no longer
  need these package constraints in the requirements file to support Python 2.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12267

AFFECTED FILES
  contrib/packaging/requirements-windows.txt.in

CHANGE DETAILS

diff --git a/contrib/packaging/requirements-windows.txt.in 
b/contrib/packaging/requirements-windows.txt.in
--- a/contrib/packaging/requirements-windows.txt.in
+++ b/contrib/packaging/requirements-windows.txt.in
@@ -1,13 +1,11 @@
 docutils
-# Pinned to an old version because 0.20 drops Python 3 compatibility.
-dulwich < 0.20 ; python_version <= '2.7'
-dulwich ; python_version >= '3'
+dulwich
 
 # Needed by the release note tooling
 fuzzywuzzy
 
 keyring
-pygit2 ; python_version >= '3'
+pygit2
 pygments
 
 # Needed by the phabricator tests



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


D12262: automation: drop support for Python 2.7 in Linux environment

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We stop installing Python 2.7 via pyenv. We stop installing the system
  Python 2 packages. We delete support for running tests on Python 2.7.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12262

AFFECTED FILES
  contrib/automation/hgautomation/aws.py
  contrib/automation/hgautomation/cli.py
  contrib/automation/hgautomation/linux.py
  contrib/automation/linux-requirements-py2.txt

CHANGE DETAILS

diff --git a/contrib/automation/linux-requirements-py2.txt 
b/contrib/automation/linux-requirements-py2.txt
deleted file mode 100644
--- a/contrib/automation/linux-requirements-py2.txt
+++ /dev/null
@@ -1,129 +0,0 @@
-#
-# This file is autogenerated by pip-compile
-# To update, run:
-#
-#pip-compile --generate-hashes 
--output-file=contrib/automation/linux-requirements-py2.txt 
contrib/automation/linux-requirements.txt.in
-#
-astroid==1.6.6 \
-
--hash=sha256:87de48a92e29cedf7210ffa853d11441e7ad94cb47bacd91b023499b51cbc756 \
-
--hash=sha256:d25869fc7f44f1d9fb7d24fd7ea0639656f5355fc3089cd1f3d18c6ec6b124c7 \
-# via pylint
-backports.functools-lru-cache==1.6.1 \
-
--hash=sha256:0bada4c2f8a43d533e4ecb7a12214d9420e66eb206d54bf2d682581ca4b80848 \
-
--hash=sha256:8fde5f188da2d593bd5bc0be98d9abc46c95bb8a9dde93429570192ee6cc2d4a \
-# via astroid, isort, pylint
-bzr==2.7.0 ; python_version <= "2.7" and platform_python_implementation == 
"CPython" \
-
--hash=sha256:c9f6bbe0a50201dadc5fddadd94ba50174193c6cf6e39e16f6dd0ad98a1df338 \
-# via -r contrib/automation/linux-requirements.txt.in
-configparser==4.0.2 \
-
--hash=sha256:254c1d9c79f60c45dfde850850883d5aaa7f19a23f13561243a050d5a7c3fe4c \
-
--hash=sha256:c7d282687a5308319bf3d2e7706e575c635b0a470342641c93bea0ea3b5331df \
-# via pylint
-contextlib2==0.6.0.post1 \
-
--hash=sha256:01f490098c18b19d2bd5bb5dc445b2054d2fa97f09a4280ba2c5f3c394c8162e \
-
--hash=sha256:3355078a159fbb44ee60ea80abd0d87b80b78c248643b49aa6d94673b413609b \
-# via vcrpy
-docutils==0.16 \
-
--hash=sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af \
-
--hash=sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc \
-# via -r contrib/automation/linux-requirements.txt.in
-enum34==1.1.10 \
-
--hash=sha256:a98a201d6de3f2ab3db284e70a33b0f896fbf35f8086594e8c9e74b909058d53 \
-
--hash=sha256:c3858660960c984d6ab0ebad691265180da2b43f07e061c0f8dca9ef3cffd328 \
-
--hash=sha256:cce6a7477ed816bd2542d03d53db9f0db935dd013b70f336a95c73979289f248 \
-# via astroid
-funcsigs==1.0.2 \
-
--hash=sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca \
-
--hash=sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50 \
-# via mock
-futures==3.3.0 \
-
--hash=sha256:49b3f5b064b6e3afc3316421a3f25f66c137ae88f068abbf72830170033c5e16 \
-
--hash=sha256:7e033af76a5e35f58e56da7a91e687706faf4e7bdfb2cbc3f2cca6b9bcda9794 \
-# via isort
-fuzzywuzzy==0.18.0 \
-
--hash=sha256:45016e92264780e58972dca1b3d939ac864b78437422beecebb3095f8efd00e8 \
-
--hash=sha256:928244b28db720d1e0ee7587acf660ea49d7e4c632569cad4f1cd7e68a5f0993 \
-# via -r contrib/automation/linux-requirements.txt.in
-isort==4.3.21 \
-
--hash=sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1 \
-
--hash=sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd \
-# via pylint
-lazy-object-proxy==1.5.1 \
-
--hash=sha256:00b78a97a79d0dfefa584d44dd1aba9668d3de7ec82335ba0ff51d53ef107143 \
-
--hash=sha256:042b54fd71c2092e6d10e5e66fa60f65c5954f8145e809f5d9f394c9b13d32ee \
-
--hash=sha256:11f87dc06eb5f376cc6d5f0c19a1b4dca202035622777c4ce8e5b72c87b035d6 \
-
--hash=sha256:19ae6f6511a02008ef3554e158c41bb2a8e5c8455935b98d6da076d9f152fd7c \
-
--hash=sha256:22c1935c6f8e3d6ea2e169eb03928adbdb8a2251d2890f8689368d65e70aa176 \
-
--hash=sha256:30ef2068f4f94660144515380ef04b93d15add2214eab8be4cd46ebc900d681c \
-
--hash=sha256:33da47ba3a581860ddd3d38c950a5fe950ca389f7123edd0d6ab0bc473499fe7 \
-
--hash=sha256:3e8698dc384857413580012f4ca322d89e63ef20fc3d4635a5b606d6d4b61f6a \
-
--hash=sha256:4fdd7113fc5143c72dacf415079eec42fcbe69cc9d3d291b4ca742e3a9455807 \
-
--hash=sha256:63b6d9a5077d54db271fcc6772440f7380ec3fa559d0e2497dbfae2f47c2c814 \
-
--hash=sha256:8133b63b05f12751cddd8e3e7f02ba39dc7cfa7d2ba99d80d7436f0ba26d6b75 \
-
--hash=sha256:89b8e5780e49753e2b4cd5aab45d3df092ddcbba3de2c4d4492a029588fe1758 \
-
--hash=sha256:8d82e27cbbea6edb8821751806f39f5dcfd7b46a5e23d27b98d6d8c8ec751df8 \
-
--hash=sha256:92cedd6e26712505adb1c17fab64651a498cc0102a80ba562ff4a2451088f57a \
-
--hash=sha256:9723364577b79ad9958a68851fe2acb94da6fd25170c595516a8289e6a129043 \
-
--hash=sha256:c484020ad26973a14a7cb1e1d2e0bfe97cf6803273ae9bd154e0213cc74bad49 

D12264: automation: delete code related to Python 2.7 support

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The building of Inno and WiX installers took a python_version argument
  that allowed us to specify "2" or "3" for the major Python version. Since
  we no longer support Python 2, we can delete this argument and everything
  feeding into it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12264

AFFECTED FILES
  contrib/automation/hgautomation/cli.py
  contrib/automation/hgautomation/windows.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/windows.py 
b/contrib/automation/hgautomation/windows.py
--- a/contrib/automation/hgautomation/windows.py
+++ b/contrib/automation/hgautomation/windows.py
@@ -264,7 +264,6 @@
 
 def build_inno_installer(
 winrm_client,
-python_version: int,
 arch: str,
 dest_path: pathlib.Path,
 version=None,
@@ -274,10 +273,7 @@
 Using a WinRM client, remote commands are executed to build
 a Mercurial Inno Setup installer.
 """
-print(
-'building Inno Setup installer for Python %d %s'
-% (python_version, arch)
-)
+print('building Inno Setup installer for %s' % arch)
 
 # TODO fix this limitation in packaging code
 if not version:
@@ -319,7 +315,6 @@
 
 def build_wix_installer(
 winrm_client,
-python_version: int,
 arch: str,
 dest_path: pathlib.Path,
 version=None,
@@ -328,7 +323,7 @@
 
 Using a WinRM client, remote commands are executed to build a WiX 
installer.
 """
-print('Building WiX installer for Python %d %s' % (python_version, arch))
+print('Building WiX installer for %s' % arch)
 
 # TODO fix this limitation in packaging code
 if not version:
diff --git a/contrib/automation/hgautomation/cli.py 
b/contrib/automation/hgautomation/cli.py
--- a/contrib/automation/hgautomation/cli.py
+++ b/contrib/automation/hgautomation/cli.py
@@ -65,7 +65,6 @@
 def build_inno(
 hga: HGAutomation,
 aws_region,
-python_version,
 arch,
 revision,
 version,
@@ -80,21 +79,18 @@
 
 windows.synchronize_hg(SOURCE_ROOT, revision, instance)
 
-for py_version in python_version:
-for a in arch:
-windows.build_inno_installer(
-instance.winrm_client,
-py_version,
-a,
-DIST_PATH,
-version=version,
-)
+for a in arch:
+windows.build_inno_installer(
+instance.winrm_client,
+a,
+DIST_PATH,
+version=version,
+)
 
 
 def build_wix(
 hga: HGAutomation,
 aws_region,
-python_version,
 arch,
 revision,
 version,
@@ -109,15 +105,13 @@
 
 windows.synchronize_hg(SOURCE_ROOT, revision, instance)
 
-for py_version in python_version:
-for a in arch:
-windows.build_wix_installer(
-instance.winrm_client,
-py_version,
-a,
-DIST_PATH,
-version=version,
-)
+for a in arch:
+windows.build_wix_installer(
+instance.winrm_client,
+a,
+DIST_PATH,
+version=version,
+)
 
 
 def build_windows_wheel(
@@ -168,15 +162,14 @@
 dest_path=DIST_PATH,
 )
 
-for py_version in (2, 3):
-for arch in ('x86', 'x64'):
-windows.purge_hg(winrm_client)
-windows.build_inno_installer(
-winrm_client, py_version, arch, DIST_PATH, version=version
-)
-windows.build_wix_installer(
-winrm_client, py_version, arch, DIST_PATH, version=version
-)
+for arch in ('x86', 'x64'):
+windows.purge_hg(winrm_client)
+windows.build_inno_installer(
+winrm_client, arch, DIST_PATH, version=version
+)
+windows.build_wix_installer(
+winrm_client, arch, DIST_PATH, version=version
+)
 
 
 def terminate_ec2_instances(hga: HGAutomation, aws_region):
@@ -340,14 +333,6 @@
 help='Build Inno Setup installer(s)',
 )
 sp.add_argument(
-'--python-version',
-help='Which version of Python to target',
-choices={3},
-type=int,
-nargs='*',
-default=[3],
-)
-sp.add_argument(
 '--arch',
 help='Architecture to build for',
 choices={'x86', 'x64'},
@@ -402,14 +387,6 @@
 
 sp = subparsers.add_parser('build-wix', help='Build WiX installer(s)')
 sp.add_argument(
-'--python-version',
-help='Which version of Python to target',
-choices={3},
-

D12263: automation: drop support for Python 2.7 in Windows environment

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We stop installing Python 2.7 in the Windows environment.
  
  We remove support for building Python 2.7 wheels and installers.
  
  There is still some Python 2.7 support cleanup to perform in automation.
  But this removes the biggest remaining chunk of references to 2.7.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12263

AFFECTED FILES
  contrib/automation/hgautomation/cli.py
  contrib/automation/hgautomation/windows.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/windows.py 
b/contrib/automation/hgautomation/windows.py
--- a/contrib/automation/hgautomation/windows.py
+++ b/contrib/automation/hgautomation/windows.py
@@ -19,30 +19,6 @@
 from .winrm import run_powershell
 
 
-# PowerShell commands to activate a Visual Studio 2008 environment.
-# This is essentially a port of vcvarsall.bat to PowerShell.
-ACTIVATE_VC9_AMD64 = r'''
-Write-Output "activating Visual Studio 2008 environment for AMD64"
-$root = "$env:LOCALAPPDATA\Programs\Common\Microsoft\Visual C++ for Python\9.0"
-$Env:VCINSTALLDIR = "${root}\VC\"
-$Env:WindowsSdkDir = "${root}\WinSDK\"
-$Env:PATH = 
"${root}\VC\Bin\amd64;${root}\WinSDK\Bin\x64;${root}\WinSDK\Bin;$Env:PATH"
-$Env:INCLUDE = "${root}\VC\Include;${root}\WinSDK\Include;$Env:PATH"
-$Env:LIB = "${root}\VC\Lib\amd64;${root}\WinSDK\Lib\x64;$Env:LIB"
-$Env:LIBPATH = "${root}\VC\Lib\amd64;${root}\WinSDK\Lib\x64;$Env:LIBPATH"
-'''.lstrip()
-
-ACTIVATE_VC9_X86 = r'''
-Write-Output "activating Visual Studio 2008 environment for x86"
-$root = "$env:LOCALAPPDATA\Programs\Common\Microsoft\Visual C++ for Python\9.0"
-$Env:VCINSTALLDIR = "${root}\VC\"
-$Env:WindowsSdkDir = "${root}\WinSDK\"
-$Env:PATH = "${root}\VC\Bin;${root}\WinSDK\Bin;$Env:PATH"
-$Env:INCLUDE = "${root}\VC\Include;${root}\WinSDK\Include;$Env:INCLUDE"
-$Env:LIB = "${root}\VC\Lib;${root}\WinSDK\Lib;$Env:LIB"
-$Env:LIBPATH = "${root}\VC\lib;${root}\WinSDK\Lib;$Env:LIBPATH"
-'''.lstrip()
-
 HG_PURGE = r'''
 $Env:PATH = "C:\hgdev\venv-bootstrap\Scripts;$Env:PATH"
 Set-Location C:\hgdev\src
@@ -78,14 +54,6 @@
 }}
 '''
 
-BUILD_INNO_PYTHON2 = r'''
-Set-Location C:\hgdev\src
-$python = "C:\hgdev\python27-{arch}\python.exe"
-C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py inno --python 
$python {extra_args}
-if ($LASTEXITCODE -ne 0) {{
-throw "process exited non-0: $LASTEXITCODE"
-}}
-'''.lstrip()
 
 BUILD_WHEEL = r'''
 Set-Location C:\hgdev\src
@@ -105,14 +73,6 @@
 }}
 '''
 
-BUILD_WIX_PYTHON2 = r'''
-Set-Location C:\hgdev\src
-$python = "C:\hgdev\python27-{arch}\python.exe"
-C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py wix --python 
$python {extra_args}
-if ($LASTEXITCODE -ne 0) {{
-throw "process exited non-0: $LASTEXITCODE"
-}}
-'''
 
 RUN_TESTS = r'''
 C:\hgdev\MinGW\msys\1.0\bin\sh.exe --login -c "cd /c/hgdev/src/tests && 
/c/hgdev/{python_path}/python.exe run-tests.py {test_flags}"
@@ -121,8 +81,7 @@
 }}
 '''
 
-WHEEL_FILENAME_PYTHON27_X86 = 'mercurial-{version}-cp27-cp27m-win32.whl'
-WHEEL_FILENAME_PYTHON27_X64 = 'mercurial-{version}-cp27-cp27m-win_amd64.whl'
+
 WHEEL_FILENAME_PYTHON37_X86 = 'mercurial-{version}-cp37-cp37m-win32.whl'
 WHEEL_FILENAME_PYTHON37_X64 = 'mercurial-{version}-cp37-cp37m-win_amd64.whl'
 WHEEL_FILENAME_PYTHON38_X86 = 'mercurial-{version}-cp38-cp38-win32.whl'
@@ -132,13 +91,9 @@
 WHEEL_FILENAME_PYTHON310_X86 = 'mercurial-{version}-cp310-cp310-win32.whl'
 WHEEL_FILENAME_PYTHON310_X64 = 'mercurial-{version}-cp310-cp310-win_amd64.whl'
 
-EXE_FILENAME_PYTHON2_X86 = 'Mercurial-{version}-x86-python2.exe'
-EXE_FILENAME_PYTHON2_X64 = 'Mercurial-{version}-x64-python2.exe'
 EXE_FILENAME_PYTHON3_X86 = 'Mercurial-{version}-x86.exe'
 EXE_FILENAME_PYTHON3_X64 = 'Mercurial-{version}-x64.exe'
 
-MSI_FILENAME_PYTHON2_X86 = 'mercurial-{version}-x86-python2.msi'
-MSI_FILENAME_PYTHON2_X64 = 'mercurial-{version}-x64-python2.msi'
 MSI_FILENAME_PYTHON3_X86 = 'mercurial-{version}-x86.msi'
 MSI_FILENAME_PYTHON3_X64 = 'mercurial-{version}-x64.msi'
 
@@ -147,14 +102,6 @@
 X86_USER_AGENT_PATTERN = '.*Windows.*'
 X64_USER_AGENT_PATTERN = '.*Windows.*(WOW|x)64.*'
 
-EXE_PYTHON2_X86_DESCRIPTION = (
-'Mercurial {version} Inno Setup installer - x86 Windows (Python 2) '
-'- does not require admin rights'
-)
-EXE_PYTHON2_X64_DESCRIPTION = (
-'Mercurial {version} Inno Setup installer - x64 Windows (Python 2) '
-'- does not require admin rights'
-)
 # TODO remove Python version once Python 2 is dropped.
 EXE_PYTHON3_X86_DESCRIPTION = (
 'Mercurial {version} Inno Setup installer - x86 Windows (Python 3) '
@@ -164,14 +111,6 @@
 'Mercurial {version} Inno Setup installer - x64 Windows (Python 3) '
 '- does not require admin rights'
 )
-MSI_PYTHON2_X86_DESCRIPTION = (
-'Mercurial {version} MSI installer - x86 Windows (Python 2) '
-'- requires admin rights'
-)

D12260: automation: run hg with python3

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Python 2.7 support will go away soon. Let's use Python 3 as part of
  the automation.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12260

AFFECTED FILES
  contrib/automation/hgautomation/linux.py
  contrib/automation/hgautomation/windows.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/windows.py 
b/contrib/automation/hgautomation/windows.py
--- a/contrib/automation/hgautomation/windows.py
+++ b/contrib/automation/hgautomation/windows.py
@@ -261,7 +261,7 @@
 hg_bin = hg_repo / 'hg'
 
 res = subprocess.run(
-['python2.7', str(hg_bin), 'log', '-r', revision, '-T', '{node}'],
+['python3', str(hg_bin), 'log', '-r', revision, '-T', '{node}'],
 cwd=str(hg_repo),
 env=env,
 check=True,
@@ -271,7 +271,7 @@
 full_revision = res.stdout.decode('ascii')
 
 args = [
-'python2.7',
+'python3',
 hg_bin,
 '--config',
 'ui.ssh=ssh -F %s' % ssh_config,
diff --git a/contrib/automation/hgautomation/linux.py 
b/contrib/automation/hgautomation/linux.py
--- a/contrib/automation/hgautomation/linux.py
+++ b/contrib/automation/hgautomation/linux.py
@@ -532,7 +532,7 @@
 hg_bin = source_path / 'hg'
 
 res = subprocess.run(
-['python2.7', str(hg_bin), 'log', '-r', revision, '-T', '{node}'],
+['python3', str(hg_bin), 'log', '-r', revision, '-T', '{node}'],
 cwd=str(source_path),
 env=env,
 check=True,
@@ -542,7 +542,7 @@
 full_revision = res.stdout.decode('ascii')
 
 args = [
-'python2.7',
+'python3',
 str(hg_bin),
 '--config',
 'ui.ssh=ssh -F %s' % ssh_config,



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


D12261: automation: make system3 the default for run-tests-linux

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We'll soon drop support for Python 2.7. Let's use Python 3 by
  default.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12261

AFFECTED FILES
  contrib/automation/hgautomation/cli.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/cli.py 
b/contrib/automation/hgautomation/cli.py
--- a/contrib/automation/hgautomation/cli.py
+++ b/contrib/automation/hgautomation/cli.py
@@ -480,7 +480,7 @@
 'pypy3.5',
 'pypy3.6',
 },
-default='system2',
+default='system3',
 )
 sp.add_argument(
 'test_flags',



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


D12259: tests: move Python 3.5 check higher in file

2022-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Per code review comment on the changeset that introduced the Python 3.5+
  checks.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12259

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
@@ -72,6 +72,13 @@
 import uuid
 import xml.dom.minidom as minidom
 
+if sys.version_info < (3, 5, 0):
+print(
+'%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`
+
 WINDOWS = os.name == r'nt'
 shellquote = shlex.quote
 
@@ -143,12 +150,6 @@
 
 origenviron = os.environ.copy()
 
-if sys.version_info < (3, 5, 0):
-print(
-'%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`
 
 xrange = range  # we use xrange in one place, and we'd rather not use range
 



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


D12255: tests: remove from __future__ from inline Python in tests

2022-03-01 Thread indygreg (Gregory Szorc)
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 

D12258: py2: drop some more from __future__ statements

2022-03-01 Thread indygreg (Gregory Szorc)
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 

D12253: tests: remove output conditionalized on no-py3

2022-03-01 Thread indygreg (Gregory Szorc)
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 

D12249: py3: use pickle directly

2022-03-01 Thread indygreg (Gregory Szorc)
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 @@
 

D12257: tests: delete some no-py3 blocks

2022-03-01 Thread indygreg (Gregory Szorc)
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
   $ 

D12256: tests: remove __future__ import from test-debugcommands.t

2022-03-01 Thread indygreg (Gregory Szorc)
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


D12252: py3: use io.BytesIO directly

2022-03-01 Thread indygreg (Gregory Szorc)
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


D12254: py2: remove simple from __future__ statements

2022-03-01 Thread indygreg (Gregory Szorc)
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
  

D12248: thirdparty: delete concurrent.futures

2022-03-01 Thread indygreg (Gregory Szorc)
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 

D12250: pycompat: remove large Python 2 block

2022-03-01 Thread indygreg (Gregory Szorc)
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 

D12251: check-py3-compat: drop support for Python 2

2022-03-01 Thread indygreg (Gregory Szorc)
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


D12247: pycompat: remove first not ispy3 block

2022-03-01 Thread indygreg (Gregory Szorc)
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


D12246: import-checker: assume absolute and use modern import checker

2022-03-01 Thread indygreg (Gregory Szorc)
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


D12244: tests: remove last references to PYTHON3

2022-03-01 Thread indygreg (Gregory Szorc)
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


  1   2   3   4   5   6   7   8   9   10   >