hgext3rd/topic/discovery.py
branchstable
changeset 4123 119fced5a891
parent 3917 ca7f02c9fa57
child 4187 49d442a2207f
child 4192 e527df0f2a68
equal deleted inserted replaced
4121:7f18c7e1e744 4123:119fced5a891
   151     tr = op.gettransaction()
   151     tr = op.gettransaction()
   152     if tr.hookargs['source'] not in ('push', 'serve'): # not a push
   152     if tr.hookargs['source'] not in ('push', 'serve'): # not a push
   153         return
   153         return
   154     tr._prepushheads = _nbheads(op.repo)
   154     tr._prepushheads = _nbheads(op.repo)
   155     reporef = weakref.ref(op.repo)
   155     reporef = weakref.ref(op.repo)
   156     oldvalidator = tr.validator
   156     if util.safehasattr(tr, 'validator'): # hg <= 4.7
       
   157         oldvalidator = tr.validator
       
   158     else:
       
   159         oldvalidator = tr._validator
   157 
   160 
   158     def validator(tr):
   161     def validator(tr):
   159         repo = reporef()
   162         repo = reporef()
   160         if repo is not None:
   163         if repo is not None:
   161             repo.invalidatecaches()
   164             repo.invalidatecaches()
   169                 if 1 < newnb:
   172                 if 1 < newnb:
   170                     msg = _('push create more than 1 head on new branch "%s"'
   173                     msg = _('push create more than 1 head on new branch "%s"'
   171                             % branch)
   174                             % branch)
   172                     raise error.Abort(msg)
   175                     raise error.Abort(msg)
   173         return oldvalidator(tr)
   176         return oldvalidator(tr)
   174     tr.validator = validator
   177     if util.safehasattr(tr, 'validator'): # hg <= 4.7
       
   178         tr.validator = validator
       
   179     else:
       
   180         tr._validator = validator
   175 handlecheckheads.params = frozenset()
   181 handlecheckheads.params = frozenset()
   176 
   182 
   177 def _pushb2phases(orig, pushop, bundler):
   183 def _pushb2phases(orig, pushop, bundler):
   178     checktypes = ('check:heads', 'check:updated-heads')
   184     checktypes = ('check:heads', 'check:updated-heads')
   179     hascheck = any(p.type in checktypes for p in bundler._parts)
   185     hascheck = any(p.type in checktypes for p in bundler._parts)