streamclone: avoid some obscure error in a corner case stable
authorValentin Gatien-Baron <vgatien-baron@janestreet.com>
Thu, 24 Mar 2022 12:27:21 -0400
branchstable
changeset 48821 d9ed7c5e915d
parent 48820 d4b66dc500c5
child 48822 d4752aeb20f1
streamclone: avoid some obscure error in a corner case I don't really know how, but I ran into this error: $ hg clone --stream ssh://user@dummy/empty-repo local-empty-repo streaming all changes abort: unable to apply stream clone: unsupported format: [255] I think you need an empty list of requirements for this to happen, which is weird, but an obscure error like this is not exactly helpful either. Since this is the result of an encoding bug anyway, just fix it. Differential Revision: https://phab.mercurial-scm.org/D12402
mercurial/bundle2.py
tests/test-clone-stream.t
--- a/mercurial/bundle2.py	Tue Mar 29 18:15:49 2022 +0900
+++ b/mercurial/bundle2.py	Thu Mar 24 12:27:21 2022 -0400
@@ -2528,7 +2528,8 @@
 @parthandler(b'stream2', (b'requirements', b'filecount', b'bytecount'))
 def handlestreamv2bundle(op, part):
 
-    requirements = urlreq.unquote(part.params[b'requirements']).split(b',')
+    requirements = urlreq.unquote(part.params[b'requirements'])
+    requirements = requirements.split(b',') if requirements else []
     filecount = int(part.params[b'filecount'])
     bytecount = int(part.params[b'bytecount'])
 
--- a/tests/test-clone-stream.t	Tue Mar 29 18:15:49 2022 +0900
+++ b/tests/test-clone-stream.t	Thu Mar 24 12:27:21 2022 -0400
@@ -817,3 +817,9 @@
   $ killdaemons.py
 
 #endif
+
+Cloning a repo with no requirements doesn't give some obscure error
+
+  $ mkdir -p empty-repo/.hg
+  $ hg clone -q --stream ssh://user@dummy/empty-repo empty-repo2
+  $ hg --cwd empty-repo2 verify -q