##// END OF EJS Templates
pull: add --remote-hidden option and pass it through peer creation...
Manuel Jacob -
r51309:3a2df812 default
parent child Browse files
Show More
@@ -19,8 +19,8 b' def wraprepo(repo):'
19 dirstate = super(narrowrepository, self)._makedirstate()
19 dirstate = super(narrowrepository, self)._makedirstate()
20 return narrowdirstate.wrapdirstate(self, dirstate)
20 return narrowdirstate.wrapdirstate(self, dirstate)
21
21
22 def peer(self, path=None):
22 def peer(self, *args, **kwds):
23 peer = super(narrowrepository, self).peer(path=path)
23 peer = super(narrowrepository, self).peer(*args, **kwds)
24 peer._caps.add(wireprototypes.NARROWCAP)
24 peer._caps.add(wireprototypes.NARROWCAP)
25 peer._caps.add(wireprototypes.ELLIPSESCAP)
25 peer._caps.add(wireprototypes.ELLIPSESCAP)
26 return peer
26 return peer
@@ -484,8 +484,8 b' class bundlerepository:'
484 def cancopy(self):
484 def cancopy(self):
485 return False
485 return False
486
486
487 def peer(self, path=None):
487 def peer(self, path=None, remotehidden=False):
488 return bundlepeer(self, path=path)
488 return bundlepeer(self, path=path, remotehidden=remotehidden)
489
489
490 def getcwd(self):
490 def getcwd(self):
491 return encoding.getcwd() # always outside the repo
491 return encoding.getcwd() # always outside the repo
@@ -5405,6 +5405,12 b' def postincoming(ui, repo, modheads, opt'
5405 _(b'a specific branch you would like to pull'),
5405 _(b'a specific branch you would like to pull'),
5406 _(b'BRANCH'),
5406 _(b'BRANCH'),
5407 ),
5407 ),
5408 (
5409 b'',
5410 b'remote-hidden',
5411 False,
5412 _(b"include changesets hidden on the remote (EXPERIMENTAL)"),
5413 ),
5408 ]
5414 ]
5409 + remoteopts,
5415 + remoteopts,
5410 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]...'),
5416 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]...'),
@@ -5442,6 +5448,14 b' def pull(ui, repo, *sources, **opts):'
5442 Specifying bookmark as ``.`` is equivalent to specifying the active
5448 Specifying bookmark as ``.`` is equivalent to specifying the active
5443 bookmark's name.
5449 bookmark's name.
5444
5450
5451 .. container:: verbose
5452
5453 One can use the `--remote-hidden` flag to pull changesets
5454 hidden on the remote. This flag is "best effort", and will only
5455 work if the server supports the feature and is configured to
5456 allow the user to access hidden changesets. This option is
5457 experimental and backwards compatibility is not garanteed.
5458
5445 Returns 0 on success, 1 if an update had unresolved files.
5459 Returns 0 on success, 1 if an update had unresolved files.
5446 """
5460 """
5447
5461
@@ -5456,12 +5470,16 b' def pull(ui, repo, *sources, **opts):'
5456 for path in urlutil.get_pull_paths(repo, ui, sources):
5470 for path in urlutil.get_pull_paths(repo, ui, sources):
5457 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(path.loc))
5471 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(path.loc))
5458 ui.flush()
5472 ui.flush()
5459 other = hg.peer(repo, opts, path)
5473 other = hg.peer(repo, opts, path, remotehidden=opts[b'remote_hidden'])
5460 update_conflict = None
5474 update_conflict = None
5461 try:
5475 try:
5462 branches = (path.branch, opts.get(b'branch', []))
5476 branches = (path.branch, opts.get(b'branch', []))
5463 revs, checkout = hg.addbranchrevs(
5477 revs, checkout = hg.addbranchrevs(
5464 repo, other, branches, opts.get(b'rev')
5478 repo,
5479 other,
5480 branches,
5481 opts.get(b'rev'),
5482 remotehidden=opts[b'remote_hidden'],
5465 )
5483 )
5466
5484
5467 pullopargs = {}
5485 pullopargs = {}
@@ -65,10 +65,10 b' release = lock.release'
65 sharedbookmarks = b'bookmarks'
65 sharedbookmarks = b'bookmarks'
66
66
67
67
68 def addbranchrevs(lrepo, other, branches, revs):
68 def addbranchrevs(lrepo, other, branches, revs, remotehidden=False):
69 if util.safehasattr(other, 'peer'):
69 if util.safehasattr(other, 'peer'):
70 # a courtesy to callers using a localrepo for other
70 # a courtesy to callers using a localrepo for other
71 peer = other.peer()
71 peer = other.peer(remotehidden=remotehidden)
72 else:
72 else:
73 peer = other
73 peer = other
74 hashbranch, branches = branches
74 hashbranch, branches = branches
@@ -242,7 +242,15 b' def repository('
242 return repo.filtered(b'visible')
242 return repo.filtered(b'visible')
243
243
244
244
245 def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None):
245 def peer(
246 uiorrepo,
247 opts,
248 path,
249 create=False,
250 intents=None,
251 createopts=None,
252 remotehidden=False,
253 ):
246 '''return a repository peer for the specified path'''
254 '''return a repository peer for the specified path'''
247 ui = getattr(uiorrepo, 'ui', uiorrepo)
255 ui = getattr(uiorrepo, 'ui', uiorrepo)
248 rui = remoteui(uiorrepo, opts)
256 rui = remoteui(uiorrepo, opts)
@@ -260,6 +268,7 b' def peer(uiorrepo, opts, path, create=Fa'
260 create,
268 create,
261 intents=intents,
269 intents=intents,
262 createopts=createopts,
270 createopts=createopts,
271 remotehidden=remotehidden,
263 )
272 )
264 _setup_repo_or_peer(rui, peer)
273 _setup_repo_or_peer(rui, peer)
265 else:
274 else:
@@ -274,7 +283,7 b' def peer(uiorrepo, opts, path, create=Fa'
274 intents=intents,
283 intents=intents,
275 createopts=createopts,
284 createopts=createopts,
276 )
285 )
277 peer = repo.peer(path=peer_path)
286 peer = repo.peer(path=peer_path, remotehidden=remotehidden)
278 return peer
287 return peer
279
288
280
289
@@ -381,8 +381,17 b' def parsev1commandresponse(ui, baseurl, '
381
381
382
382
383 class httppeer(wireprotov1peer.wirepeer):
383 class httppeer(wireprotov1peer.wirepeer):
384 def __init__(self, ui, path, url, opener, requestbuilder, caps):
384 def __init__(
385 super().__init__(ui, path=path)
385 self, ui, path, url, opener, requestbuilder, caps, remotehidden=False
386 ):
387 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)
386 self._url = url
395 self._url = url
387 self._caps = caps
396 self._caps = caps
388 self.limitedarguments = caps is not None and b'httppostargs' not in caps
397 self.limitedarguments = caps is not None and b'httppostargs' not in caps
@@ -592,7 +601,9 b' def performhandshake(ui, url, opener, re'
592 return respurl, info
601 return respurl, info
593
602
594
603
595 def _make_peer(ui, path, opener=None, requestbuilder=urlreq.request):
604 def _make_peer(
605 ui, path, opener=None, requestbuilder=urlreq.request, remotehidden=False
606 ):
596 """Construct an appropriate HTTP peer instance.
607 """Construct an appropriate HTTP peer instance.
597
608
598 ``opener`` is an ``url.opener`` that should be used to establish
609 ``opener`` is an ``url.opener`` that should be used to establish
@@ -615,11 +626,19 b' def _make_peer(ui, path, opener=None, re'
615 respurl, info = performhandshake(ui, url, opener, requestbuilder)
626 respurl, info = performhandshake(ui, url, opener, requestbuilder)
616
627
617 return httppeer(
628 return httppeer(
618 ui, path, respurl, opener, requestbuilder, info[b'v1capabilities']
629 ui,
630 path,
631 respurl,
632 opener,
633 requestbuilder,
634 info[b'v1capabilities'],
635 remotehidden=remotehidden,
619 )
636 )
620
637
621
638
622 def make_peer(ui, path, create, intents=None, createopts=None):
639 def make_peer(
640 ui, path, create, intents=None, createopts=None, remotehidden=False
641 ):
623 if create:
642 if create:
624 raise error.Abort(_(b'cannot create new http repository'))
643 raise error.Abort(_(b'cannot create new http repository'))
625 try:
644 try:
@@ -628,7 +647,7 b' def make_peer(ui, path, create, intents='
628 _(b'Python support for SSL and HTTPS is not installed')
647 _(b'Python support for SSL and HTTPS is not installed')
629 )
648 )
630
649
631 inst = _make_peer(ui, path)
650 inst = _make_peer(ui, path, remotehidden=remotehidden)
632
651
633 return inst
652 return inst
634 except error.RepoError as httpexception:
653 except error.RepoError as httpexception:
@@ -388,7 +388,7 b' class peer:'
388
388
389 limitedarguments = False
389 limitedarguments = False
390
390
391 def __init__(self, ui, path=None):
391 def __init__(self, ui, path=None, remotehidden=False):
392 self.ui = ui
392 self.ui = ui
393 self.path = path
393 self.path = path
394
394
@@ -307,8 +307,18 b' class localcommandexecutor:'
307 class localpeer(repository.peer):
307 class localpeer(repository.peer):
308 '''peer for a local repo; reflects only the most recent API'''
308 '''peer for a local repo; reflects only the most recent API'''
309
309
310 def __init__(self, repo, caps=None, path=None):
310 def __init__(self, repo, caps=None, path=None, remotehidden=False):
311 super(localpeer, self).__init__(repo.ui, path=path)
311 super(localpeer, self).__init__(
312 repo.ui, path=path, remotehidden=remotehidden
313 )
314
315 if remotehidden:
316 msg = _(
317 b"ignoring `--remote-hidden` request\n"
318 b"(access to hidden changeset for %r not "
319 b"supported yet)\n"
320 ) % type(self)
321 self.ui.warn(msg)
312
322
313 if caps is None:
323 if caps is None:
314 caps = moderncaps.copy()
324 caps = moderncaps.copy()
@@ -455,8 +465,10 b' class locallegacypeer(localpeer):'
455 """peer extension which implements legacy methods too; used for tests with
465 """peer extension which implements legacy methods too; used for tests with
456 restricted capabilities"""
466 restricted capabilities"""
457
467
458 def __init__(self, repo, path=None):
468 def __init__(self, repo, path=None, remotehidden=False):
459 super(locallegacypeer, self).__init__(repo, caps=legacycaps, path=path)
469 super(locallegacypeer, self).__init__(
470 repo, caps=legacycaps, path=path, remotehidden=remotehidden
471 )
460
472
461 # Begin of baselegacywirecommands interface.
473 # Begin of baselegacywirecommands interface.
462
474
@@ -1657,8 +1669,10 b' class localrepository:'
1657 parts.pop()
1669 parts.pop()
1658 return False
1670 return False
1659
1671
1660 def peer(self, path=None):
1672 def peer(self, path=None, remotehidden=False):
1661 return localpeer(self, path=path) # not cached to avoid reference cycle
1673 return localpeer(
1674 self, path=path, remotehidden=remotehidden
1675 ) # not cached to avoid reference cycle
1662
1676
1663 def unfiltered(self):
1677 def unfiltered(self):
1664 """Return unfiltered version of the repository
1678 """Return unfiltered version of the repository
@@ -372,7 +372,16 b' def _performhandshake(ui, stdin, stdout,'
372
372
373 class sshv1peer(wireprotov1peer.wirepeer):
373 class sshv1peer(wireprotov1peer.wirepeer):
374 def __init__(
374 def __init__(
375 self, ui, path, proc, stdin, stdout, stderr, caps, autoreadstderr=True
375 self,
376 ui,
377 path,
378 proc,
379 stdin,
380 stdout,
381 stderr,
382 caps,
383 autoreadstderr=True,
384 remotehidden=False,
376 ):
385 ):
377 """Create a peer from an existing SSH connection.
386 """Create a peer from an existing SSH connection.
378
387
@@ -383,7 +392,14 b' class sshv1peer(wireprotov1peer.wirepeer'
383 ``autoreadstderr`` denotes whether to automatically read from
392 ``autoreadstderr`` denotes whether to automatically read from
384 stderr and to forward its output.
393 stderr and to forward its output.
385 """
394 """
386 super().__init__(ui, path=path)
395 super().__init__(ui, path=path, remotehidden=remotehidden)
396 if remotehidden:
397 msg = _(
398 b"ignoring `--remote-hidden` request\n"
399 b"(access to hidden changeset for ssh peers not supported "
400 b"yet)\n"
401 )
402 ui.warn(msg)
387 # self._subprocess is unused. Keeping a handle on the process
403 # self._subprocess is unused. Keeping a handle on the process
388 # holds a reference and prevents it from being garbage collected.
404 # holds a reference and prevents it from being garbage collected.
389 self._subprocess = proc
405 self._subprocess = proc
@@ -568,7 +584,16 b' class sshv1peer(wireprotov1peer.wirepeer'
568 self._readerr()
584 self._readerr()
569
585
570
586
571 def _make_peer(ui, path, proc, stdin, stdout, stderr, autoreadstderr=True):
587 def _make_peer(
588 ui,
589 path,
590 proc,
591 stdin,
592 stdout,
593 stderr,
594 autoreadstderr=True,
595 remotehidden=False,
596 ):
572 """Make a peer instance from existing pipes.
597 """Make a peer instance from existing pipes.
573
598
574 ``path`` and ``proc`` are stored on the eventual peer instance and may
599 ``path`` and ``proc`` are stored on the eventual peer instance and may
@@ -598,6 +623,7 b' def _make_peer(ui, path, proc, stdin, st'
598 stderr,
623 stderr,
599 caps,
624 caps,
600 autoreadstderr=autoreadstderr,
625 autoreadstderr=autoreadstderr,
626 remotehidden=remotehidden,
601 )
627 )
602 else:
628 else:
603 _cleanuppipes(ui, stdout, stdin, stderr, warn=None)
629 _cleanuppipes(ui, stdout, stdin, stderr, warn=None)
@@ -606,7 +632,9 b' def _make_peer(ui, path, proc, stdin, st'
606 )
632 )
607
633
608
634
609 def make_peer(ui, path, create, intents=None, createopts=None):
635 def make_peer(
636 ui, path, create, intents=None, createopts=None, remotehidden=False
637 ):
610 """Create an SSH peer.
638 """Create an SSH peer.
611
639
612 The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
640 The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
@@ -658,7 +686,9 b' def make_peer(ui, path, create, intents='
658 ui, sshcmd, args, remotecmd, remotepath, sshenv
686 ui, sshcmd, args, remotecmd, remotepath, sshenv
659 )
687 )
660
688
661 peer = _make_peer(ui, path, proc, stdin, stdout, stderr)
689 peer = _make_peer(
690 ui, path, proc, stdin, stdout, stderr, remotehidden=remotehidden
691 )
662
692
663 # Finally, if supported by the server, notify it about our own
693 # Finally, if supported by the server, notify it about our own
664 # capabilities.
694 # capabilities.
@@ -237,8 +237,8 b' class statichttprepository('
237 def local(self):
237 def local(self):
238 return False
238 return False
239
239
240 def peer(self, path=None):
240 def peer(self, path=None, remotehidden=False):
241 return statichttppeer(self, path=path)
241 return statichttppeer(self, path=path, remotehidden=remotehidden)
242
242
243 def wlock(self, wait=True):
243 def wlock(self, wait=True):
244 raise error.LockUnavailable(
244 raise error.LockUnavailable(
@@ -260,8 +260,12 b' class statichttprepository('
260 pass # statichttprepository are read only
260 pass # statichttprepository are read only
261
261
262
262
263 def make_peer(ui, path, create, intents=None, createopts=None):
263 def make_peer(
264 ui, path, create, intents=None, createopts=None, remotehidden=False
265 ):
264 if create:
266 if create:
265 raise error.Abort(_(b'cannot create new static-http repository'))
267 raise error.Abort(_(b'cannot create new static-http repository'))
266 url = path.loc[7:]
268 url = path.loc[7:]
267 return statichttprepository(ui, url).peer(path=path)
269 return statichttprepository(ui, url).peer(
270 path=path, remotehidden=remotehidden
271 )
@@ -270,8 +270,8 b' class unionrepository:'
270 def cancopy(self):
270 def cancopy(self):
271 return False
271 return False
272
272
273 def peer(self, path=None):
273 def peer(self, path=None, remotehidden=False):
274 return unionpeer(self, path=None)
274 return unionpeer(self, path=None, remotehidden=remotehidden)
275
275
276 def getcwd(self):
276 def getcwd(self):
277 return encoding.getcwd() # always outside the repo
277 return encoding.getcwd() # always outside the repo
@@ -15,10 +15,10 b' def wrapcapable(orig, self, name, *args,'
15 if name in b'$CAP'.split(b' '):
15 if name in b'$CAP'.split(b' '):
16 return False
16 return False
17 return orig(self, name, *args, **kwargs)
17 return orig(self, name, *args, **kwargs)
18 def wrappeer(orig, self, path=None):
18 def wrappeer(orig, self, *args, **kwargs):
19 # Since we're disabling some newer features, we need to make sure local
19 # Since we're disabling some newer features, we need to make sure local
20 # repos add in the legacy features again.
20 # repos add in the legacy features again.
21 return localrepo.locallegacypeer(self, path=path)
21 return localrepo.locallegacypeer(self, *args, **kwargs)
22 EOF
22 EOF
23
23
24 echo '[extensions]' >> $HGRCPATH
24 echo '[extensions]' >> $HGRCPATH
@@ -366,7 +366,7 b' Show all commands + options'
366 parents: rev, style, template
366 parents: rev, style, template
367 paths: template
367 paths: template
368 phase: public, draft, secret, force, rev
368 phase: public, draft, secret, force, rev
369 pull: update, force, confirm, rev, bookmark, branch, ssh, remotecmd, insecure
369 pull: update, force, confirm, rev, bookmark, branch, remote-hidden, ssh, remotecmd, insecure
370 purge: abort-on-err, all, ignored, dirs, files, print, print0, confirm, include, exclude
370 purge: abort-on-err, all, ignored, dirs, files, print, print0, confirm, include, exclude
371 push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
371 push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
372 recover: verify
372 recover: verify
General Comments 0
You need to be logged in to leave comments. Login now