hgext/pushexperiment.py
branchmercurial-3.6
changeset 1604 61dd08f4dc62
parent 1549 81a221db8a72
child 1757 86e71a0b3319
equal deleted inserted replaced
1601:15318c3460bf 1604:61dd08f4dc62
     1 """Small extension altering some push behavior
     1 """Small extension altering some push behavior
     2 
     2 
     3 - Add a new wire protocol command to exchange obsolescence markers. Sending the
     3 - Add a new wire protocol command to exchange obsolescence markers. Sending the
     4   raw file as a binary instead of using pushkey hack.
     4   raw file as a binary instead of using pushkey hack.
     5 - Add a "push done" notification
     5 - Add a "push done" notification
     6 - Push obsolescence marker before anything else (This works around the lack of global transaction)
     6 - Push obsolescence marker before anything else (This works around the lack
       
     7 of global transaction)
     7 
     8 
     8 """
     9 """
     9 
    10 
    10 import errno
    11 import errno
    11 from StringIO import StringIO
    12 from StringIO import StringIO
    59     return orig(repo, remote)
    60     return orig(repo, remote)
    60 
    61 
    61 
    62 
    62 def client_notifypushend(self):
    63 def client_notifypushend(self):
    63     """wire peer  command to notify a push is done"""
    64     """wire peer  command to notify a push is done"""
    64     self.requirecap('_push_experiment_notifypushend_0', _('hook once push is all done'))
    65     self.requirecap('_push_experiment_notifypushend_0',
       
    66                     _('hook once push is all done'))
    65     return self._call('push_experiment_notifypushend_0')
    67     return self._call('push_experiment_notifypushend_0')
    66 
    68 
    67 
    69 
    68 def srv_notifypushend(repo, proto):
    70 def srv_notifypushend(repo, proto):
    69     """wire protocol command to notify a push is done"""
    71     """wire protocol command to notify a push is done"""
    73 
    75 
    74 
    76 
    75 def augmented_push(orig, repo, remote, *args, **kwargs):
    77 def augmented_push(orig, repo, remote, *args, **kwargs):
    76     """push wrapped that call the wire protocol command"""
    78     """push wrapped that call the wire protocol command"""
    77     if not remote.canpush():
    79     if not remote.canpush():
    78         raise util.Abort(_("destination does not support push"))
    80         raise error.Abort(_("destination does not support push"))
    79     if (obsolete.isenabled(repo, obsolete.exchangeopt) and repo.obsstore
    81     if (obsolete.isenabled(repo, obsolete.exchangeopt) and repo.obsstore
    80         and remote.capable('_push_experiment_pushobsmarkers_0')):
    82         and remote.capable('_push_experiment_pushobsmarkers_0')):
    81         # push marker early to limit damage of pushing too early.
    83         # push marker early to limit damage of pushing too early.
    82         try:
    84         try:
    83             obsfp = repo.svfs('obsstore')
    85             obsfp = repo.svfs('obsstore')
   102 
   104 
   103 
   105 
   104 def extsetup(ui):
   106 def extsetup(ui):
   105     wireproto.wirepeer.push_experiment_pushobsmarkers_0 = client_pushobsmarkers
   107     wireproto.wirepeer.push_experiment_pushobsmarkers_0 = client_pushobsmarkers
   106     wireproto.wirepeer.push_experiment_notifypushend_0 = client_notifypushend
   108     wireproto.wirepeer.push_experiment_notifypushend_0 = client_notifypushend
   107     wireproto.commands['push_experiment_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
   109     wireproto.commands['push_experiment_pushobsmarkers_0'] = \
   108     wireproto.commands['push_experiment_notifypushend_0'] = (srv_notifypushend, '')
   110         (srv_pushobsmarkers, '')
       
   111     wireproto.commands['push_experiment_notifypushend_0'] = \
       
   112         (srv_notifypushend, '')
   109     extensions.wrapfunction(wireproto, 'capabilities', capabilities)
   113     extensions.wrapfunction(wireproto, 'capabilities', capabilities)
   110     extensions.wrapfunction(obsolete, 'syncpush', syncpush)
   114     extensions.wrapfunction(obsolete, 'syncpush', syncpush)
   111     extensions.wrapfunction(localrepo.localrepository, 'push', augmented_push)
   115     extensions.wrapfunction(localrepo.localrepository, 'push', augmented_push)
   112 
   116 
   113 
   117