changeset 50990:758e40b9a8af stable

httppeer: fix static-http: scheme autodetection (issue6833) Since statichttprepo.make_peer() assumes path is a urlutil.path object (by accessing path.loc), we no longer can just provide a bytestring there. See also 5f71fff8dc74 and cfe8d88a453e.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 05 Oct 2023 14:47:42 -0300
parents eccf7dc7c91e
children 051de900b240
files mercurial/httppeer.py tests/test-static-http.t
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Thu Sep 14 10:52:09 2023 +0100
+++ b/mercurial/httppeer.py	Thu Oct 05 14:47:42 2023 -0300
@@ -663,7 +663,8 @@
         return inst
     except error.RepoError as httpexception:
         try:
-            r = statichttprepo.make_peer(ui, b"static-" + path.loc, create)
+            path = path.copy(new_raw_location=b"static-" + path.rawloc)
+            r = statichttprepo.make_peer(ui, path, create)
             ui.note(_(b'(falling back to static-http)\n'))
             return r
         except error.RepoError:
--- a/tests/test-static-http.t	Thu Sep 14 10:52:09 2023 +0100
+++ b/tests/test-static-http.t	Thu Oct 05 14:47:42 2023 -0300
@@ -148,9 +148,17 @@
   $ hg paths
   default = static-http://localhost:$HGPORT/remotempty
 
+test autodetecting static-http: scheme (issue6833)
+
+  $ cd ..
+  $ hg init actually-static
+  $ hg clone http://localhost:$HGPORT/actually-static local4
+  no changes found
+  updating to branch default
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 test with non-repo
 
-  $ cd ..
   $ mkdir notarepo
   $ hg clone static-http://localhost:$HGPORT/notarepo local3
   abort: 'http://localhost:$HGPORT/notarepo' does not appear to be an hg repository
@@ -225,6 +233,15 @@
   /.hg/store/data/~2ehgsub.i (py37 !)
   /.hg/store/data/~2ehgsubstate.i (py37 !)
   /.hg/store/requires
+  /actually-static/.hg/bookmarks
+  /actually-static/.hg/bookmarks.current
+  /actually-static/.hg/dirstate
+  /actually-static/.hg/requires
+  /actually-static/.hg/store/00changelog.i
+  /actually-static/.hg/store/00manifest.i
+  /actually-static/.hg/store/requires
+  /actually-static/?cmd=capabilities
+  /actually-static?cmd=capabilities
   /notarepo/.hg/00changelog.i
   /notarepo/.hg/requires
   /remote-with-names/.hg/bookmarks