hgext3rd/topic/discovery.py
changeset 1921 4898296d7d25
parent 1920 2a28bd7eab31
child 1934 9d6d30e36cdd
equal deleted inserted replaced
1920:2a28bd7eab31 1921:4898296d7d25
    75     if tr.hookargs['source'] not in ('push', 'serve'): # not a push
    75     if tr.hookargs['source'] not in ('push', 'serve'): # not a push
    76         return
    76         return
    77     tr._prepushheads = _nbheads(op.repo)
    77     tr._prepushheads = _nbheads(op.repo)
    78     reporef = weakref.ref(op.repo)
    78     reporef = weakref.ref(op.repo)
    79     oldvalidator = tr.validator
    79     oldvalidator = tr.validator
       
    80 
    80     def validator(tr):
    81     def validator(tr):
    81         repo = reporef()
    82         repo = reporef()
    82         if repo is not None:
    83         if repo is not None:
    83             repo.invalidatecaches()
    84             repo.invalidatecaches()
    84             finalheads = _nbheads(repo)
    85             finalheads = _nbheads(repo)
    87                 if oldnb < newnb:
    88                 if oldnb < newnb:
    88                     msg = _('push create a new head on branch "%s"' % branch)
    89                     msg = _('push create a new head on branch "%s"' % branch)
    89                     raise error.Abort(msg)
    90                     raise error.Abort(msg)
    90             for branch, newnb in finalheads.iteritems():
    91             for branch, newnb in finalheads.iteritems():
    91                 if 1 < newnb:
    92                 if 1 < newnb:
    92                     msg = _('push create more than 1 head on new branch "%s"' % branch)
    93                     msg = _('push create more than 1 head on new branch "%s"'
       
    94                             % branch)
    93                     raise error.Abort(msg)
    95                     raise error.Abort(msg)
    94         return oldvalidator(tr)
    96         return oldvalidator(tr)
    95     tr.validator = validator
    97     tr.validator = validator
    96 handlecheckheads.params = frozenset()
    98 handlecheckheads.params = frozenset()
    97 
    99 
    98 def _pushb2phases(orig, pushop, bundler):
   100 def _pushb2phases(orig, pushop, bundler):
    99     hascheck =  any(p.type == 'check:heads' for p in  bundler._parts)
   101     hascheck = any(p.type == 'check:heads' for p in bundler._parts)
   100     if pushop.outdatedphases and not hascheck:
   102     if pushop.outdatedphases and not hascheck:
   101         exchange._pushb2ctxcheckheads(pushop, bundler)
   103         exchange._pushb2ctxcheckheads(pushop, bundler)
   102     return orig(pushop, bundler)
   104     return orig(pushop, bundler)
   103 
   105 
   104 def wireprotocaps(orig, repo, proto):
   106 def wireprotocaps(orig, repo, proto):