Patchwork D2027: sshpeer: move URL validation out of sshpeer.__init__

login
register
mail settings
Submitter phabricator
Date Feb. 6, 2018, 1:24 p.m.
Message ID <0cfd8c63b340340f9a2988ef44612483@localhost.localdomain>
Download mbox | patch
Permalink /patch/27368/
State Not Applicable
Headers show

Comments

phabricator - Feb. 6, 2018, 1:24 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb202d360d2a4: sshpeer: move URL validation out of sshpeer.__init__ (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2027?vs=5185&id=5244

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -121,13 +121,6 @@ 
         self._pipeo = self._pipei = self._pipee = None
 
         u = util.url(path, parsequery=False, parsefragment=False)
-        if u.scheme != 'ssh' or not u.host or u.path is None:
-            self._abort(error.RepoError(_("couldn't parse location %s") % path))
-
-        util.checksafessh(path)
-
-        if u.passwd is not None:
-            self._abort(error.RepoError(_("password in URL not supported")))
 
         self._user = u.user
         self._host = u.host
@@ -371,4 +364,17 @@ 
         self._readerr()
 
 def instance(ui, path, create):
+    """Create an SSH peer.
+
+    The returned object conforms to the ``wireproto.wirepeer`` interface.
+    """
+    u = util.url(path, parsequery=False, parsefragment=False)
+    if u.scheme != 'ssh' or not u.host or u.path is None:
+        raise error.RepoError(_("couldn't parse location %s") % path)
+
+    util.checksafessh(path)
+
+    if u.passwd is not None:
+        raise error.RepoError(_('password in URL not supported'))
+
     return sshpeer(ui, path, create=create)