Submitter | Gregory Szorc |
---|---|
Date | Nov. 29, 2016, 6:58 a.m. |
Message ID | <e32ff1ce869243618aaa.1480402699@ubuntu-vm-main> |
Download | mbox | patch |
Permalink | /patch/17776/ |
State | Accepted |
Headers | show |
Comments
On Mon, Nov 28, 2016 at 10:58:19PM -0800, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # Date 1480394802 28800 > # Mon Nov 28 20:46:42 2016 -0800 > # Node ID e32ff1ce869243618aaab30bb6fba2b13be536ff > # Parent 05d19f908c3abf62e2ed6d453a8cd52bbc727408 > wireproto: only advertise HTTP-specific capabilities to HTTP peers (BC) I've taken these two, still looking at the rest. > > Previously, the capabilities list was protocol agnostic and we > advertised the same capabilities list to all clients, regardless of > transport protocol. > > A few capabilities are specific to HTTP. I see no good reason why we > should advertise them to SSH clients. So this patch limits their > advertisement to HTTP clients. > > This patch is BC, but SSH clients shouldn't be using the removed > capabilities so there should be no impact. > > diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py > --- a/mercurial/wireproto.py > +++ b/mercurial/wireproto.py > @@ -716,10 +716,13 @@ def _capabilities(repo, proto): > capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) > caps.append('bundle2=' + urlreq.quote(capsblob)) > caps.append('unbundle=%s' % ','.join(bundle2.bundlepriority)) > - caps.append( > - 'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024)) > - if repo.ui.configbool('experimental', 'httppostargs', False): > - caps.append('httppostargs') > + > + if proto.name == 'http': > + caps.append('httpheader=%d' % > + repo.ui.configint('server', 'maxhttpheaderlen', 1024)) > + if repo.ui.configbool('experimental', 'httppostargs', False): > + caps.append('httppostargs') > + > return caps > > # If you are writing an extension and consider wrapping this function. Wrap > diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t > --- a/tests/test-ssh-bundle1.t > +++ b/tests/test-ssh-bundle1.t > @@ -464,8 +464,8 @@ debug output > running python ".*/dummyssh" user@dummy ('|")hg -R remote serve --stdio('|") (re) > sending hello command > sending between command > - remote: 371 > - remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 > + remote: 355 > + remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN > remote: 1 > preparing listkeys for "bookmarks" > sending listkeys command > diff --git a/tests/test-ssh.t b/tests/test-ssh.t > --- a/tests/test-ssh.t > +++ b/tests/test-ssh.t > @@ -467,8 +467,8 @@ debug output > running python ".*/dummyssh" user@dummy ('|")hg -R remote serve --stdio('|") (re) > sending hello command > sending between command > - remote: 371 > - remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 > + remote: 355 > + remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN > remote: 1 > query 1; heads > sending batch command
Patch
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -716,10 +716,13 @@ def _capabilities(repo, proto): capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) caps.append('bundle2=' + urlreq.quote(capsblob)) caps.append('unbundle=%s' % ','.join(bundle2.bundlepriority)) - caps.append( - 'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024)) - if repo.ui.configbool('experimental', 'httppostargs', False): - caps.append('httppostargs') + + if proto.name == 'http': + caps.append('httpheader=%d' % + repo.ui.configint('server', 'maxhttpheaderlen', 1024)) + if repo.ui.configbool('experimental', 'httppostargs', False): + caps.append('httppostargs') + return caps # If you are writing an extension and consider wrapping this function. Wrap diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t --- a/tests/test-ssh-bundle1.t +++ b/tests/test-ssh-bundle1.t @@ -464,8 +464,8 @@ debug output running python ".*/dummyssh" user@dummy ('|")hg -R remote serve --stdio('|") (re) sending hello command sending between command - remote: 371 - remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 + remote: 355 + remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN remote: 1 preparing listkeys for "bookmarks" sending listkeys command diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -467,8 +467,8 @@ debug output running python ".*/dummyssh" user@dummy ('|")hg -R remote serve --stdio('|") (re) sending hello command sending between command - remote: 371 - remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 + remote: 355 + remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN remote: 1 query 1; heads sending batch command