hgext/infinitepush/__init__.py
changeset 40252 090e5f3900b7
parent 39826 c31ce080eb75
child 41759 aaad36b88298
equal deleted inserted replaced
40251:3c89227788a2 40252:090e5f3900b7
   355 @wireprotov1peer.batchable
   355 @wireprotov1peer.batchable
   356 def listkeyspatterns(self, namespace, patterns):
   356 def listkeyspatterns(self, namespace, patterns):
   357     if not self.capable('pushkey'):
   357     if not self.capable('pushkey'):
   358         yield {}, None
   358         yield {}, None
   359     f = wireprotov1peer.future()
   359     f = wireprotov1peer.future()
   360     self.ui.debug('preparing listkeys for "%s" with pattern "%s"\n' %
   360     self.ui.debug('preparing listkeys for "%s"\n' % namespace)
   361                   (namespace, patterns))
       
   362     yield {
   361     yield {
   363         'namespace': encoding.fromlocal(namespace),
   362         'namespace': encoding.fromlocal(namespace),
   364         'patterns': wireprototypes.encodelist(patterns)
   363         'patterns': wireprototypes.encodelist(patterns)
   365     }, f
   364     }, f
   366     d = f.value
   365     d = f.value
   694 def _findcommonincoming(orig, *args, **kwargs):
   693 def _findcommonincoming(orig, *args, **kwargs):
   695     common, inc, remoteheads = orig(*args, **kwargs)
   694     common, inc, remoteheads = orig(*args, **kwargs)
   696     return common, True, remoteheads
   695     return common, True, remoteheads
   697 
   696 
   698 def _push(orig, ui, repo, dest=None, *args, **opts):
   697 def _push(orig, ui, repo, dest=None, *args, **opts):
   699 
   698     opts = pycompat.byteskwargs(opts)
   700     bookmark = opts.get(r'bookmark')
   699     bookmark = opts.get('bookmark')
   701     # we only support pushing one infinitepush bookmark at once
   700     # we only support pushing one infinitepush bookmark at once
   702     if len(bookmark) == 1:
   701     if len(bookmark) == 1:
   703         bookmark = bookmark[0]
   702         bookmark = bookmark[0]
   704     else:
   703     else:
   705         bookmark = ''
   704         bookmark = ''
   716             ui.setconfig(experimental, 'bundle2.pushback', True)
   715             ui.setconfig(experimental, 'bundle2.pushback', True)
   717 
   716 
   718         if scratchpush:
   717         if scratchpush:
   719             # this is an infinitepush, we don't want the bookmark to be applied
   718             # this is an infinitepush, we don't want the bookmark to be applied
   720             # rather that should be stored in the bundlestore
   719             # rather that should be stored in the bundlestore
   721             opts[r'bookmark'] = []
   720             opts['bookmark'] = []
   722             ui.setconfig(experimental, configscratchpush, True)
   721             ui.setconfig(experimental, configscratchpush, True)
   723             oldphasemove = extensions.wrapfunction(exchange,
   722             oldphasemove = extensions.wrapfunction(exchange,
   724                                                    '_localphasemove',
   723                                                    '_localphasemove',
   725                                                    _phasemove)
   724                                                    _phasemove)
   726         # Copy-paste from `push` command
   725         # Copy-paste from `push` command
   730                              hint=_("see 'hg help config.paths'"))
   729                              hint=_("see 'hg help config.paths'"))
   731         destpath = path.pushloc or path.loc
   730         destpath = path.pushloc or path.loc
   732         # Remote scratch bookmarks will be deleted because remotenames doesn't
   731         # Remote scratch bookmarks will be deleted because remotenames doesn't
   733         # know about them. Let's save it before push and restore after
   732         # know about them. Let's save it before push and restore after
   734         remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath)
   733         remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath)
   735         result = orig(ui, repo, dest, *args, **opts)
   734         result = orig(ui, repo, dest, *args, **pycompat.strkwargs(opts))
   736         if common.isremotebooksenabled(ui):
   735         if common.isremotebooksenabled(ui):
   737             if bookmark and scratchpush:
   736             if bookmark and scratchpush:
   738                 other = hg.peer(repo, opts, destpath)
   737                 other = hg.peer(repo, opts, destpath)
   739                 fetchedbookmarks = other.listkeyspatterns('bookmarks',
   738                 fetchedbookmarks = other.listkeyspatterns('bookmarks',
   740                                                           patterns=[bookmark])
   739                                                           patterns=[bookmark])
   897 
   896 
   898                 # Certain parts require a response
   897                 # Certain parts require a response
   899                 if part.type in ('pushkey', 'changegroup'):
   898                 if part.type in ('pushkey', 'changegroup'):
   900                     if op.reply is not None:
   899                     if op.reply is not None:
   901                         rpart = op.reply.newpart('reply:%s' % part.type)
   900                         rpart = op.reply.newpart('reply:%s' % part.type)
   902                         rpart.addparam('in-reply-to', str(part.id),
   901                         rpart.addparam('in-reply-to', b'%d' % part.id,
   903                                        mandatory=False)
   902                                        mandatory=False)
   904                         rpart.addparam('return', '1', mandatory=False)
   903                         rpart.addparam('return', '1', mandatory=False)
   905 
   904 
   906             op.records.add(part.type, {
   905             op.records.add(part.type, {
   907                 'return': 1,
   906                 'return': 1,