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

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Tue Feb 6 08:24:16 EST 2018


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

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)



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


More information about the Mercurial-devel mailing list