diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml --- a/contrib/heptapod-ci.yml +++ b/contrib/heptapod-ci.yml @@ -1,6 +1,5 @@ stages: - tests - - phabricator image: registry.heptapod.net/mercurial/ci-images/mercurial-core:$HG_CI_IMAGE_TAG @@ -45,24 +44,6 @@ rust-cargo-test: variables: PYTHON: python3 -phabricator-refresh: - stage: phabricator - except: - refs: - - merge_requests - variables: - - $PHABRICATOR_TOKEN == "NO-PHAB" - variables: - DEFAULT_COMMENT: ":white_check_mark: refresh by Heptapod after a successful CI run (:octopus: :green_heart:)" - STABLE_COMMENT: ":white_check_mark: refresh by Heptapod after a successful CI run (:octopus: :green_heart:)\n⚠ This patch is intended for stable ⚠\n{image https://media.giphy.com/media/nYI8SmmChYXK0/source.gif}" - script: - - | - if [ `hg branch` == "stable" ]; then - ./contrib/phab-refresh-stack.sh --comment "$STABLE_COMMENT"; - else - ./contrib/phab-refresh-stack.sh --comment "$DEFAULT_COMMENT"; - fi - test-c: <<: *runtests variables: diff --git a/contrib/packaging/docker/rhel8 b/contrib/packaging/docker/rhel8 --- a/contrib/packaging/docker/rhel8 +++ b/contrib/packaging/docker/rhel8 @@ -16,3 +16,6 @@ RUN yum install -y createrepo # For rust extensions RUN yum install -y cargo + +# avoid incorrect docker image permissions on /tmp preventing writes by non-root users +RUN chmod 1777 /tmp diff --git a/hgdemandimport/__init__.py b/hgdemandimport/__init__.py --- a/hgdemandimport/__init__.py +++ b/hgdemandimport/__init__.py @@ -62,6 +62,9 @@ IGNORES = { if _pypy: # _ctypes.pointer is shadowed by "from ... import pointer" (PyPy 5) IGNORES.add('_ctypes.pointer') + # pure Python module on PyPy, must be loaded to raise ModuleNotFoundError + # on non-Windows platforms + IGNORES.add('msvcrt') demandimport.init(IGNORES) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1338,10 +1338,12 @@ def followlines(repo, subset, x): @predicate(b'nodefromfile(path)') def nodefromfile(repo, subset, x): - """ - An alias for ``::.`` (ancestors of the working directory's first parent). - If file pattern is specified, the histories of files matching given - pattern in the revision given by startrev are followed, including copies. + """Read a list of nodes from the file at `path`. + + This applies `id(LINE)` to each line of the file. + + This is useful when the amount of nodes you need to specify gets too large + for the command line. """ path = getstring(x, _(b"nodefromfile require a file path")) listed_rev = set() diff --git a/mercurial/url.py b/mercurial/url.py --- a/mercurial/url.py +++ b/mercurial/url.py @@ -12,7 +12,6 @@ import base64 import socket from .i18n import _ -from .pycompat import getattr from . import ( encoding, error, @@ -198,15 +197,6 @@ class httpconnection(keepalive.HTTPConne # must be able to send big bundle as stream. send = _gen_sendfile(keepalive.HTTPConnection.send) - def getresponse(self): - proxyres = getattr(self, 'proxyres', None) - if proxyres: - if proxyres.will_close: - self.close() - self.proxyres = None - return proxyres - return keepalive.HTTPConnection.getresponse(self) - # Large parts of this function have their origin from before Python 2.6 # and could potentially be removed. @@ -255,77 +245,15 @@ def _generic_proxytunnel(self): break # skip lines that are all whitespace list(iter(lambda: res.fp.readline().strip(), b'')) - res.status = status - res.reason = reason.strip() - if res.status == 200: + if status == 200: # skip lines until we find a blank line list(iter(res.fp.readline, b'\r\n')) - return True - - if version == b'HTTP/1.0': - res.version = 10 - elif version.startswith(b'HTTP/1.'): - res.version = 11 - elif version == b'HTTP/0.9': - res.version = 9 else: - raise httplib.UnknownProtocol(version) - - if res.version == 9: - res.length = None - res.chunked = 0 - res.will_close = 1 - res.msg = httplib.HTTPMessage(stringio()) - return False - - res.msg = httplib.HTTPMessage(res.fp) - res.msg.fp = None - - # are we using the chunked-style of transfer encoding? - trenc = res.msg.getheader(b'transfer-encoding') - if trenc and trenc.lower() == b"chunked": - res.chunked = 1 - res.chunk_left = None - else: - res.chunked = 0 - - # will the connection close at the end of the response? - res.will_close = res._check_close() - - # do we have a Content-Length? - # NOTE: RFC 2616, section 4.4, #3 says we ignore this if - # transfer-encoding is "chunked" - length = res.msg.getheader(b'content-length') - if length and not res.chunked: - try: - res.length = int(length) - except ValueError: - res.length = None - else: - if res.length < 0: # ignore nonsensical negative lengths - res.length = None - else: - res.length = None - - # does the body have a fixed length? (of zero) - if ( - status == httplib.NO_CONTENT - or status == httplib.NOT_MODIFIED - or 100 <= status < 200 - or res._method == b'HEAD' # 1xx codes - ): - res.length = 0 - - # if the connection remains open, and we aren't using chunked, and - # a content-length was not provided, then assume that the connection - # WILL close. - if not res.will_close and not res.chunked and res.length is None: - res.will_close = 1 - - self.proxyres = res - - return False + self.close() + raise socket.error( + "Tunnel connection failed: %d %s" % (status, reason.strip()) + ) class httphandler(keepalive.HTTPHandler): diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml --- a/rust/hg-core/Cargo.toml +++ b/rust/hg-core/Cargo.toml @@ -15,7 +15,7 @@ byteorder = "1.4.3" derive_more = "0.99.17" hashbrown = { version = "0.9.1", features = ["rayon"] } home = "0.5.3" -im-rc = "15.0.0" +im-rc = "15.0" itertools = "0.10.3" lazy_static = "1.4.0" libc = "0.2" diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -1121,7 +1121,7 @@ def has_emacs(): @check('black', 'the black formatter for python (>= 20.8b1)') def has_black(): blackcmd = 'black --version' - version_regex = b'black, version ([0-9a-b.]+)' + version_regex = b'black, (?:version )?([0-9a-b.]+)' version = matchoutput(blackcmd, version_regex) sv = distutils.version.StrictVersion return version and sv(_bytes2sys(version.group(1))) >= sv('20.8b1') diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t --- a/tests/test-http-proxy.t +++ b/tests/test-http-proxy.t @@ -104,6 +104,13 @@ do not use the proxy if it is in the no new changesets 83180e7845de updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + +proxy can't connect to server + + $ http_proxy=http://localhost:$HGPORT1/ hg --config http_proxy.always=True clone http://localhost:$HGPORT2/ h + abort: HTTP Error 404: Connection refused + [100] + $ cat proxy.log * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob) @@ -120,3 +127,5 @@ do not use the proxy if it is in the no * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob) $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob) + * - - [*] code 404, message Connection refused (glob) + $LOCALIP - - [$LOGDATE$] "GET http://localhost:$HGPORT2/?cmd=capabilities HTTP/1.1" 404 - (glob) diff --git a/tests/test-https.t b/tests/test-https.t --- a/tests/test-https.t +++ b/tests/test-https.t @@ -491,6 +491,13 @@ Test https with cert problems through pr abort: error: *certificate verify failed* (glob) [100] +Test when proxy can't connect to server + + $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure https://localhost:0/ + pulling from https://localhost:0/ + abort: error: Tunnel connection failed: 404 Connection refused + [100] + $ killdaemons.py hg0.pid diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py --- a/tests/tinyproxy.py +++ b/tests/tinyproxy.py @@ -73,12 +73,8 @@ class ProxyHandler(httpserver.basehttpre print("\t" "connect to %s:%d" % host_port) try: soc.connect(host_port) - except socket.error as arg: - try: - msg = arg[1] - except (IndexError, TypeError): - msg = arg - self.send_error(404, msg) + except socket.error as e: + self.send_error(404, e.strerror) return 0 return 1