Patchwork D2216: httppeer: remove httpspeer

login
register
mail settings
Submitter phabricator
Date Feb. 13, 2018, 3:48 a.m.
Message ID <differential-rev-PHID-DREV-bmu5akiftqd56zghxhmc-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27796/
State Superseded
Headers show

Comments

phabricator - Feb. 13, 2018, 3:48 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  All it did was verify at construction time that Mercurial supports
  TLS. instance() is what's used to construct peer instances. So
  we can just inline this check into that function and do away with
  the type variant.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 13, 2018, 8:59 a.m.
lothiraldan accepted this revision.
lothiraldan added a comment.


  Could an extension import the `httpspeer` class or is it too low-level?

REPOSITORY
  rHG Mercurial

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

To: indygreg, #hg-reviewers, lothiraldan
Cc: lothiraldan, mercurial-devel
phabricator - Feb. 13, 2018, 5:08 p.m.
indygreg added a comment.


  In https://phab.mercurial-scm.org/D2216#36814, @lothiraldan wrote:
  
  > Could an extension import the `httpspeer` class or is it too low-level?
  
  
  In theory, sure. But these classes are instantiated via `httppeer.instance()`. If anything, this change makes things friendlier for extensions because there is one less class to wrap and the remaining class doesn't inherit from a class that may be wrapped.

REPOSITORY
  rHG Mercurial

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

To: indygreg, #hg-reviewers, lothiraldan
Cc: lothiraldan, mercurial-devel

Patch

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -480,22 +480,15 @@ 
     def _abort(self, exception):
         raise exception
 
-class httpspeer(httppeer):
-    def __init__(self, ui, path):
-        if not url.has_https:
-            raise error.Abort(_('Python support for SSL and HTTPS '
-                               'is not installed'))
-        httppeer.__init__(self, ui, path)
-
 def instance(ui, path, create):
     if create:
         raise error.Abort(_('cannot create new http repository'))
     try:
-        if path.startswith('https:'):
-            inst = httpspeer(ui, path)
-        else:
-            inst = httppeer(ui, path)
+        if path.startswith('https:') and not url.has_https:
+            raise error.Abort(_('Python support for SSL and HTTPS '
+                                'is not installed'))
 
+        inst = httppeer(ui, path)
         inst._fetchcaps()
 
         return inst