Mercurial > evolve
comparison hgext3rd/topic/discovery.py @ 6304:c00332abb66b
topic: remove 4.7 compat for transaction validators
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 15 Aug 2022 18:45:55 +0400 |
parents | a2855aff1268 |
children | 58b856416d2e |
comparison
equal
deleted
inserted
replaced
6303:1c78d704bea4 | 6304:c00332abb66b |
---|---|
263 tr = op.gettransaction() | 263 tr = op.gettransaction() |
264 if tr.hookargs[b'source'] not in (b'push', b'serve'): # not a push | 264 if tr.hookargs[b'source'] not in (b'push', b'serve'): # not a push |
265 return | 265 return |
266 tr._prepushheads = _nbheads(op.repo) | 266 tr._prepushheads = _nbheads(op.repo) |
267 reporef = weakref.ref(op.repo) | 267 reporef = weakref.ref(op.repo) |
268 if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66) | 268 if util.safehasattr(tr, '_validator'): |
269 oldvalidator = tr.validator | |
270 elif util.safehasattr(tr, '_validator'): | |
271 # hg <= 5.3 (36f08ae87ef6) | 269 # hg <= 5.3 (36f08ae87ef6) |
272 oldvalidator = tr._validator | 270 oldvalidator = tr._validator |
273 | 271 |
274 def _validate(tr): | 272 def _validate(tr): |
275 repo = reporef() | 273 repo = reporef() |
301 | 299 |
302 def validator(tr): | 300 def validator(tr): |
303 _validate(tr) | 301 _validate(tr) |
304 return oldvalidator(tr) | 302 return oldvalidator(tr) |
305 | 303 |
306 if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66) | 304 if util.safehasattr(tr, '_validator'): |
307 tr.validator = validator | |
308 elif util.safehasattr(tr, '_validator'): | |
309 # hg <= 5.3 (36f08ae87ef6) | 305 # hg <= 5.3 (36f08ae87ef6) |
310 tr._validator = validator | 306 tr._validator = validator |
311 else: | 307 else: |
312 tr.addvalidator(b'000-new-head-check', _validate) | 308 tr.addvalidator(b'000-new-head-check', _validate) |
313 | 309 |