##// END OF EJS Templates
hidden: add support for --remote-hidden to HTTP peer...
Manuel Jacob -
r51313:315f5376 default
parent child Browse files
Show More
@@ -108,7 +108,14 b' class _multifile:'
108
108
109
109
110 def makev1commandrequest(
110 def makev1commandrequest(
111 ui, requestbuilder, caps, capablefn, repobaseurl, cmd, args
111 ui,
112 requestbuilder,
113 caps,
114 capablefn,
115 repobaseurl,
116 cmd,
117 args,
118 remotehidden=False,
112 ):
119 ):
113 """Make an HTTP request to run a command for a version 1 client.
120 """Make an HTTP request to run a command for a version 1 client.
114
121
@@ -127,6 +134,8 b' def makev1commandrequest('
127
134
128 ui.debug(b"sending %s command\n" % cmd)
135 ui.debug(b"sending %s command\n" % cmd)
129 q = [(b'cmd', cmd)]
136 q = [(b'cmd', cmd)]
137 if remotehidden:
138 q.append(('access-hidden', '1'))
130 headersize = 0
139 headersize = 0
131 # Important: don't use self.capable() here or else you end up
140 # Important: don't use self.capable() here or else you end up
132 # with infinite recursion when trying to look up capabilities
141 # with infinite recursion when trying to look up capabilities
@@ -385,18 +394,12 b' class httppeer(wireprotov1peer.wirepeer)'
385 self, ui, path, url, opener, requestbuilder, caps, remotehidden=False
394 self, ui, path, url, opener, requestbuilder, caps, remotehidden=False
386 ):
395 ):
387 super().__init__(ui, path=path, remotehidden=remotehidden)
396 super().__init__(ui, path=path, remotehidden=remotehidden)
388 if remotehidden:
389 msg = _(
390 b"ignoring `--remote-hidden` request\n"
391 b"(access to hidden changeset for http peers not "
392 b"supported yet)\n"
393 )
394 ui.warn(msg)
395 self._url = url
397 self._url = url
396 self._caps = caps
398 self._caps = caps
397 self.limitedarguments = caps is not None and b'httppostargs' not in caps
399 self.limitedarguments = caps is not None and b'httppostargs' not in caps
398 self._urlopener = opener
400 self._urlopener = opener
399 self._requestbuilder = requestbuilder
401 self._requestbuilder = requestbuilder
402 self._remotehidden = remotehidden
400
403
401 def __del__(self):
404 def __del__(self):
402 for h in self._urlopener.handlers:
405 for h in self._urlopener.handlers:
@@ -451,6 +454,7 b' class httppeer(wireprotov1peer.wirepeer)'
451 self._url,
454 self._url,
452 cmd,
455 cmd,
453 args,
456 args,
457 self._remotehidden,
454 )
458 )
455
459
456 resp = sendrequest(self.ui, self._urlopener, req)
460 resp = sendrequest(self.ui, self._urlopener, req)
@@ -211,6 +211,100 b' Hidden changeset are still hidden despit'
211 revision: 2
211 revision: 2
212 revision: 0
212 revision: 0
213
213
214 Test --remote-hidden for http peer
215 ----------------------------------
216
217 $ hg clone --pull http://localhost:$HGPORT client-http
218 requesting all changes
219 adding changesets
220 adding manifests
221 adding file changes
222 added 2 changesets with 2 changes to 1 files
223 2 new obsolescence markers
224 new changesets 5f354f46e585:c33affeb3f6b (1 drafts)
225 updating to branch default
226 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
227 $ hg -R client-http log -G --hidden -v
228 @ 1:c33affeb3f6b c_Amend_New [draft]
229 |
230 o 0:5f354f46e585 c_Public [public]
231
232
233 pulling an hidden changeset should fail:
234
235 $ hg -R client-http pull -r be215fbb8c50
236 pulling from http://localhost:$HGPORT/
237 abort: filtered revision 'be215fbb8c50' (not in 'served' subset)
238 [255]
239
240 pulling an hidden changeset with --remote-hidden should succeed:
241
242 $ hg -R client-http pull --remote-hidden -r be215fbb8c50
243 pulling from http://localhost:$HGPORT/
244 searching for changes
245 adding changesets
246 adding manifests
247 adding file changes
248 added 1 changesets with 1 changes to 1 files (+1 heads)
249 (1 other changesets obsolete on arrival)
250 (run 'hg heads' to see heads)
251 $ hg -R client-http log -G --hidden -v
252 x 2:be215fbb8c50 c_Amend_Old [draft]
253 |
254 | @ 1:c33affeb3f6b c_Amend_New [draft]
255 |/
256 o 0:5f354f46e585 c_Public [public]
257
258
259 Pulling a secret changeset is still forbidden:
260
261 secret visible:
262
263 $ hg -R client-http pull --remote-hidden -r 8d28cbe335f3
264 pulling from http://localhost:$HGPORT/
265 abort: filtered revision '8d28cbe335f3' (not in 'served.hidden' subset)
266 [255]
267
268 secret hidden:
269
270 $ hg -R client-http pull --remote-hidden -r 1c6afd79eb66
271 pulling from http://localhost:$HGPORT/
272 abort: filtered revision '1c6afd79eb66' (not in 'served.hidden' subset)
273 [255]
274
275 Same check on a server that do not allow hidden access:
276 ```````````````````````````````````````````````````````
277
278 $ hg clone --pull http://localhost:$HGPORT1 client-http2
279 requesting all changes
280 adding changesets
281 adding manifests
282 adding file changes
283 added 2 changesets with 2 changes to 1 files
284 2 new obsolescence markers
285 new changesets 5f354f46e585:c33affeb3f6b (1 drafts)
286 updating to branch default
287 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 $ hg -R client-http2 log -G --hidden -v
289 @ 1:c33affeb3f6b c_Amend_New [draft]
290 |
291 o 0:5f354f46e585 c_Public [public]
292
293
294 pulling an hidden changeset should fail:
295
296 $ hg -R client-http2 pull -r be215fbb8c50
297 pulling from http://localhost:$HGPORT1/
298 abort: filtered revision 'be215fbb8c50' (not in 'served' subset)
299 [255]
300
301 pulling an hidden changeset with --remote-hidden should fail too:
302
303 $ hg -R client-http2 pull --remote-hidden -r be215fbb8c50
304 pulling from http://localhost:$HGPORT1/
305 abort: filtered revision 'be215fbb8c50' (not in 'served' subset)
306 [255]
307
214 =============
308 =============
215 Final cleanup
309 Final cleanup
216 =============
310 =============
General Comments 0
You need to be logged in to leave comments. Login now