hgext/infinitepush/__init__.py
changeset 37203 f083e7fd6313
parent 37202 95cc57a74363
child 37204 0d6c12668691
equal deleted inserted replaced
37202:95cc57a74363 37203:f083e7fd6313
   162     default='',
   162     default='',
   163 )
   163 )
   164 configitem('experimental', 'infinitepush-scratchpush',
   164 configitem('experimental', 'infinitepush-scratchpush',
   165     default=False,
   165     default=False,
   166 )
   166 )
   167 configitem('experimental', 'non-forward-move',
       
   168     default=False,
       
   169 )
       
   170 
   167 
   171 experimental = 'experimental'
   168 experimental = 'experimental'
   172 configbookmark = 'server-bundlestore-bookmark'
   169 configbookmark = 'server-bundlestore-bookmark'
   173 configscratchpush = 'infinitepush-scratchpush'
   170 configscratchpush = 'infinitepush-scratchpush'
   174 confignonforwardmove = 'non-forward-move'
       
   175 
   171 
   176 scratchbranchparttype = bundleparts.scratchbranchparttype
   172 scratchbranchparttype = bundleparts.scratchbranchparttype
   177 revsetpredicate = registrar.revsetpredicate()
   173 revsetpredicate = registrar.revsetpredicate()
   178 templatekeyword = registrar.templatekeyword()
   174 templatekeyword = registrar.templatekeyword()
   179 _scratchbranchmatcher = lambda x: False
   175 _scratchbranchmatcher = lambda x: False
   298 
   294 
   299     extensions.wrapfunction(bundle2, 'processparts', processparts)
   295     extensions.wrapfunction(bundle2, 'processparts', processparts)
   300 
   296 
   301 def clientextsetup(ui):
   297 def clientextsetup(ui):
   302     entry = extensions.wrapcommand(commands.table, 'push', _push)
   298     entry = extensions.wrapcommand(commands.table, 'push', _push)
   303 
       
   304     if not any(a for a in entry[1] if a[1] == 'non-forward-move'):
       
   305         entry[1].append(('', 'non-forward-move', None,
       
   306                          _('allows moving a remote bookmark to an '
       
   307                            'arbitrary place')))
       
   308 
   299 
   309     entry[1].append(
   300     entry[1].append(
   310         ('', 'bundle-store', None,
   301         ('', 'bundle-store', None,
   311          _('force push to go to bundle store (EXPERIMENTAL)')))
   302          _('force push to go to bundle store (EXPERIMENTAL)')))
   312 
   303 
   708             scratchpush = True
   699             scratchpush = True
   709             # bundle2 can be sent back after push (for example, bundle2
   700             # bundle2 can be sent back after push (for example, bundle2
   710             # containing `pushkey` part to update bookmarks)
   701             # containing `pushkey` part to update bookmarks)
   711             ui.setconfig(experimental, 'bundle2.pushback', True)
   702             ui.setconfig(experimental, 'bundle2.pushback', True)
   712 
   703 
   713         ui.setconfig(experimental, confignonforwardmove,
       
   714                      opts.get('non_forward_move'), '--non-forward-move')
       
   715         if scratchpush:
   704         if scratchpush:
   716             # this is an infinitepush, we don't want the bookmark to be applied
   705             # this is an infinitepush, we don't want the bookmark to be applied
   717             # rather that should be stored in the bundlestore
   706             # rather that should be stored in the bundlestore
   718             opts['bookmark'] = []
   707             opts['bookmark'] = []
   719             ui.setconfig(experimental, configscratchpush, True)
   708             ui.setconfig(experimental, configscratchpush, True)
   802     # This parameter tells the server that the following bundle is an
   791     # This parameter tells the server that the following bundle is an
   803     # infinitepush. This let's it switch the part processing to our infinitepush
   792     # infinitepush. This let's it switch the part processing to our infinitepush
   804     # code path.
   793     # code path.
   805     bundler.addparam("infinitepush", "True")
   794     bundler.addparam("infinitepush", "True")
   806 
   795 
   807     nonforwardmove = pushop.force or pushop.ui.configbool(experimental,
       
   808                                                           confignonforwardmove)
       
   809     scratchparts = bundleparts.getscratchbranchparts(pushop.repo,
   796     scratchparts = bundleparts.getscratchbranchparts(pushop.repo,
   810                                                      pushop.remote,
   797                                                      pushop.remote,
   811                                                      pushop.outgoing,
   798                                                      pushop.outgoing,
   812                                                      nonforwardmove,
       
   813                                                      pushop.ui,
   799                                                      pushop.ui,
   814                                                      bookmark)
   800                                                      bookmark)
   815 
   801 
   816     for scratchpart in scratchparts:
   802     for scratchpart in scratchparts:
   817         bundler.addpart(scratchpart)
   803         bundler.addpart(scratchpart)
   834 
   820 
   835     # Fast forward update
   821     # Fast forward update
   836     if oldnode in bundle and list(bundle.set('bundle() & %s::', oldnode)):
   822     if oldnode in bundle and list(bundle.set('bundle() & %s::', oldnode)):
   837         return revs
   823         return revs
   838 
   824 
   839     # Forced non-fast forward update
   825     return revs
   840     if force:
       
   841         return revs
       
   842     else:
       
   843         raise error.Abort(_('non-forward push'),
       
   844                           hint=_('use --non-forward-move to override'))
       
   845 
   826 
   846 @contextlib.contextmanager
   827 @contextlib.contextmanager
   847 def logservicecall(logger, service, **kwargs):
   828 def logservicecall(logger, service, **kwargs):
   848     start = time.time()
   829     start = time.time()
   849     logger(service, eventtype='start', **kwargs)
   830     logger(service, eventtype='start', **kwargs)