[PATCH 1 of 4 STABLE] hg: copy [hostsecurity] options to remote ui instances (issue5305)

Gregory Szorc gregory.szorc at gmail.com
Wed Jul 20 00:31:53 EDT 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1468983454 25200
#      Tue Jul 19 19:57:34 2016 -0700
# Branch stable
# Node ID 3b67fc038e07238b23843f2bbbb609b5c4ee9e53
# Parent  334632380e22e4aa960068fc7e173bbe8a13d983
hg: copy [hostsecurity] options to remote ui instances (issue5305)

TIL that ui instances for remote/peer repos don't automagically inherit
config options from .hg/hgrc files.

This patch makes remote ui instances inherit options from the
[hostsecurity] section. We were already inheriting options
from [hostfingerprints] and [auth]. So adding [hostsecurity] to the
list seems appropriate.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -918,17 +918,17 @@ def remoteui(src, opts):
             dst.setconfig("ui", o, v, 'copied')
 
     # copy bundle-specific options
     r = src.config('bundle', 'mainreporoot')
     if r:
         dst.setconfig('bundle', 'mainreporoot', r, 'copied')
 
     # copy selected local settings to the remote ui
-    for sect in ('auth', 'hostfingerprints', 'http_proxy'):
+    for sect in ('auth', 'hostfingerprints', 'hostsecurity', 'http_proxy'):
         for key, val in src.configitems(sect):
             dst.setconfig(sect, key, val, 'copied')
     v = src.config('web', 'cacerts')
     if v:
         dst.setconfig('web', 'cacerts', util.expandpath(v), 'copied')
 
     return dst
 
diff --git a/tests/test-https.t b/tests/test-https.t
--- a/tests/test-https.t
+++ b/tests/test-https.t
@@ -496,16 +496,27 @@ The per-host config option overrides the
 The per-host config option by itself works
 
   $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
   > --config hostsecurity.localhost:minimumprotocol=tls1.2
   (could not negotiate a common protocol; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error)
   abort: error: *unsupported protocol* (glob)
   [255]
 
+.hg/hgrc file [hostsecurity] settings are applied to remote ui instances (issue5305)
+
+  $ cat >> copy-pull/.hg/hgrc << EOF
+  > [hostsecurity]
+  > localhost:minimumprotocol=tls1.2
+  > EOF
+  $ P="$CERTSDIR" hg -R copy-pull id https://localhost:$HGPORT/
+  (could not negotiate a common protocol; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error)
+  abort: error: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:590)
+  [255]
+
   $ killdaemons.py hg0.pid
   $ killdaemons.py hg1.pid
   $ killdaemons.py hg2.pid
 #endif
 
 Prepare for connecting through proxy
 
   $ hg serve -R test -p $HGPORT -d --pid-file=hg0.pid --certificate=$PRIV


More information about the Mercurial-devel mailing list