Patchwork [05,of,11] ui: add an instance flag to hold --insecure bit

login
register
mail settings
Submitter Gregory Szorc
Date May 5, 2016, 7:53 a.m.
Message ID <328a6fef953a7f6de589.1462434802@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/14897/
State Accepted
Headers show

Comments

Gregory Szorc - May 5, 2016, 7:53 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1462433618 25200
#      Thu May 05 00:33:38 2016 -0700
# Node ID 328a6fef953a7f6de589b6132c7927676415386e
# Parent  6ed24e176bfd6cd4590a3c3dfadefdf5f7dd747a
ui: add an instance flag to hold --insecure bit

Currently, when --insecure is used we set web.cacerts=! and
socket validation takes this value into account. web.cacerts=!
is not documented AFAICT and is purely an internal implementation
detail.

Let's be more explicit about what is going on by introducing a
dedicated variable outside of the config values to track that
--insecure is used.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -102,29 +102,32 @@  class ui(object):
         self.quiet = self.verbose = self.debugflag = self.tracebackflag = False
         self._reportuntrusted = True
         self._ocfg = config.config() # overlay
         self._tcfg = config.config() # trusted
         self._ucfg = config.config() # untrusted
         self._trustusers = set()
         self._trustgroups = set()
         self.callhooks = True
+        # Insecure server connections requested.
+        self.insecureconnections = False
 
         if src:
             self.fout = src.fout
             self.ferr = src.ferr
             self.fin = src.fin
 
             self._tcfg = src._tcfg.copy()
             self._ucfg = src._ucfg.copy()
             self._ocfg = src._ocfg.copy()
             self._trustusers = src._trustusers.copy()
             self._trustgroups = src._trustgroups.copy()
             self.environ = src.environ
             self.callhooks = src.callhooks
+            self.insecureconnections = src.insecureconnections
             self.fixconfig()
         else:
             self.fout = sys.stdout
             self.ferr = sys.stderr
             self.fin = sys.stdin
 
             # shared read-only environment
             self.environ = os.environ