##// END OF EJS Templates
httppeer: remove support for connecting to <0.9.1 servers (BC)...
httppeer: remove support for connecting to <0.9.1 servers (BC) Previously, HTTP wire protocol clients would attempt a "capabilities" wire protocol command. If that failed, they would fall back to issuing a "between" command. The "capabilities" command was added in Mercurial 0.9.1 (released July 2006). The "between" command has been present for as long as the wire protocol has existed. So if the "between" command failed, it was safe to assume that the remote could not speak any version of the Mercurial wire protocol. The "between" fallback was added in 395a84f78736 in 2011. Before that changeset, Mercurial would *always* issue the "between" command and would issue "capabilities" if capabilities were requested. At that time, many connections would issue "capabilities" eventually, so it was decided to issue "capabilities" by default and fall back to "between" if that failed. This saved a round trip when connecting to modern servers while still preserving compatibility with legacy servers. Fast forward ~7 years. Mercurial servers supporting "capabilities" have been around for over a decade. If modern clients are connecting to <0.9.1 servers, they are getting a bad experience. They may even be getting bad data (an old server is vulnerable to numerous security issues and could have been p0wned, leading to a Mercurial repository serving backdoors or other badness). In addition, the fallback can harm experience for modern servers. If a client experiences an intermittent HTTP request failure (due to bad network, etc) and falls back to a "between" that works, it would assume an empty capability set and would attempt to communicate with the repository using a very ancient wire protocol. Auditing HTTP logs for hg.mozilla.org, I did find a handful of requests for the null range of the "between" command. However, requests can be days apart. And when I do see requests, they come in batches. Those batches seem to correlate to spikes of HTTP 500 or other server/network events. So I think these requests are fallbacks from failed "capabilities" requests and not from old clients. If you need even more evidence to discontinue support, apparently we have no test coverage for communicating with servers not supporting "capabilities." I know this because all tests pass with the "between" fallback removed. Finally, server-side support for <0.9.1 pushing (the "addchangegroup" wire protocol command along with locking-related commands) was dropped from the HTTP client in fda0867cfe03 in 2017 and the SSH client in 9f6e0e7ef828 in 2015. I think this all adds up to enough justification for removing client support for communicating with servers not supporting "capabilities." So this commit removes that fallback. Differential Revision: https://phab.mercurial-scm.org/D2001

File last commit:

r34646:75979c8d default
r35902:197d10e1 default
Show More
rcutil.py
98 lines | 3.1 KiB | text/x-python | PythonLexer
Jun Wu
rcutil: move scmutil.*rcpath to rcutil (API)...
r31679 # rcutil.py - utilities about config paths, special config sections etc.
#
# Copyright Mercurial Contributors
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
import os
from . import (
encoding,
pycompat,
util,
)
Jun Wu
codemod: use pycompat.iswindows...
r34646 if pycompat.iswindows:
Jun Wu
rcutil: move scmutil.*rcpath to rcutil (API)...
r31679 from . import scmwindows as scmplatform
else:
from . import scmposix as scmplatform
Yuya Nishihara
pager: use less as a fallback on Unix...
r32078 fallbackpager = scmplatform.fallbackpager
Jun Wu
rcutil: move scmutil.*rcpath to rcutil (API)...
r31679 systemrcpath = scmplatform.systemrcpath
userrcpath = scmplatform.userrcpath
Jun Wu
rcutil: extract rc directory listing logic...
r31681 def _expandrcpath(path):
'''path could be a file or a directory. return a list of file paths'''
p = util.expandpath(path)
if os.path.isdir(p):
join = os.path.join
Yuya Nishihara
osutil: proxy through util (and platform) modules (API)...
r32203 return [join(p, f) for f, k in util.listdir(p) if f.endswith('.rc')]
Jun Wu
rcutil: extract rc directory listing logic...
r31681 return [p]
Jun Wu
rcutil: add a method to convert environment variables to config items...
r31684 def envrcitems(env=None):
'''Return [(section, name, value, source)] config items.
The config items are extracted from environment variables specified by env,
used to override systemrc, but not userrc.
If env is not provided, encoding.environ will be used.
'''
if env is None:
env = encoding.environ
checklist = [
('EDITOR', 'ui', 'editor'),
('VISUAL', 'ui', 'editor'),
('PAGER', 'pager', 'pager'),
]
result = []
for envname, section, configname in checklist:
if envname not in env:
continue
result.append((section, configname, env[envname], '$%s' % envname))
return result
Jun Wu
rcutil: split osrcpath to return default.d paths (API)...
r31680 def defaultrcpath():
'''return rc paths in default.d'''
Jun Wu
rcutil: move scmutil.*rcpath to rcutil (API)...
r31679 path = []
defaultpath = os.path.join(util.datapath, 'default.d')
if os.path.isdir(defaultpath):
Jun Wu
rcutil: extract rc directory listing logic...
r31681 path = _expandrcpath(defaultpath)
Jun Wu
rcutil: move scmutil.*rcpath to rcutil (API)...
r31679 return path
Jun Wu
rcutil: rename rcpath to rccomponents (API)
r31682 def rccomponents():
Jun Wu
rcutil: let rccomponents return different types of configs (API)...
r31683 '''return an ordered [(type, obj)] about where to load configs.
respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is
used. if $HGRCPATH is not set, the platform default will be used.
if a directory is provided, *.rc files under it will be used.
type could be either 'path' or 'items', if type is 'path', obj is a string,
and is the config file path. if type is 'items', obj is a list of (section,
name, value, source) that should fill the config directly.
'''
Jun Wu
rcutil: let environ override system configs (BC)...
r31685 envrc = ('items', envrcitems())
Jun Wu
rcutil: unindent a block...
r31693 if 'HGRCPATH' in encoding.environ:
# assume HGRCPATH is all about user configs so environments can be
# overridden.
_rccomponents = [envrc]
for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep):
if not p:
continue
_rccomponents.extend(('path', p) for p in _expandrcpath(p))
else:
Jun Wu
rcutil: extract duplicated logic to a lambda...
r31694 normpaths = lambda paths: [('path', os.path.normpath(p)) for p in paths]
_rccomponents = normpaths(defaultrcpath() + systemrcpath())
Jun Wu
rcutil: unindent a block...
r31693 _rccomponents.append(envrc)
Jun Wu
rcutil: extract duplicated logic to a lambda...
r31694 _rccomponents.extend(normpaths(userrcpath()))
Jun Wu
rcutil: rename rcpath to rccomponents (API)
r31682 return _rccomponents
Jun Wu
pager: set some environment variables if they're not set...
r31954
def defaultpagerenv():
'''return a dict of default environment variables and their values,
intended to be set before starting a pager.
'''
return {'LESS': 'FRX', 'LV': '-c'}