Mercurial > hg
comparison hgext/remotefilelog/__init__.py @ 50789:cbd1da102417
wrapfunction: use sysstr instead of bytes as argument in "remotefilelog"
This is as valid and simpler, it will help us to eventually get ride of
`safehasattr`.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 03 Feb 2023 04:25:07 +0100 |
parents | 58adcabc295f |
children | a834ec41f17c |
comparison
equal
deleted
inserted
replaced
50788:05430a06a2eb | 50789:cbd1da102417 |
---|---|
315 extensions.wrapcommand(commands.table, b'debugdata', debugdatashallow) | 315 extensions.wrapcommand(commands.table, b'debugdata', debugdatashallow) |
316 | 316 |
317 changegroup.cgpacker = shallowbundle.shallowcg1packer | 317 changegroup.cgpacker = shallowbundle.shallowcg1packer |
318 | 318 |
319 extensions.wrapfunction( | 319 extensions.wrapfunction( |
320 changegroup, b'_addchangegroupfiles', shallowbundle.addchangegroupfiles | 320 changegroup, '_addchangegroupfiles', shallowbundle.addchangegroupfiles |
321 ) | 321 ) |
322 extensions.wrapfunction( | 322 extensions.wrapfunction( |
323 changegroup, b'makechangegroup', shallowbundle.makechangegroup | 323 changegroup, 'makechangegroup', shallowbundle.makechangegroup |
324 ) | 324 ) |
325 extensions.wrapfunction(localrepo, b'makestore', storewrapper) | 325 extensions.wrapfunction(localrepo, 'makestore', storewrapper) |
326 extensions.wrapfunction(exchange, b'pull', exchangepull) | 326 extensions.wrapfunction(exchange, 'pull', exchangepull) |
327 extensions.wrapfunction(merge, b'applyupdates', applyupdates) | 327 extensions.wrapfunction(merge, 'applyupdates', applyupdates) |
328 extensions.wrapfunction(merge, b'_checkunknownfiles', checkunknownfiles) | 328 extensions.wrapfunction(merge, '_checkunknownfiles', checkunknownfiles) |
329 extensions.wrapfunction(context.workingctx, b'_checklookup', checklookup) | 329 extensions.wrapfunction(context.workingctx, '_checklookup', checklookup) |
330 extensions.wrapfunction(scmutil, b'_findrenames', findrenames) | 330 extensions.wrapfunction(scmutil, '_findrenames', findrenames) |
331 extensions.wrapfunction( | 331 extensions.wrapfunction( |
332 copies, b'_computeforwardmissing', computeforwardmissing | 332 copies, '_computeforwardmissing', computeforwardmissing |
333 ) | 333 ) |
334 extensions.wrapfunction(dispatch, b'runcommand', runcommand) | 334 extensions.wrapfunction(dispatch, 'runcommand', runcommand) |
335 extensions.wrapfunction(repair, b'_collectbrokencsets', _collectbrokencsets) | 335 extensions.wrapfunction(repair, '_collectbrokencsets', _collectbrokencsets) |
336 extensions.wrapfunction(context.changectx, b'filectx', filectx) | 336 extensions.wrapfunction(context.changectx, 'filectx', filectx) |
337 extensions.wrapfunction(context.workingctx, b'filectx', workingfilectx) | 337 extensions.wrapfunction(context.workingctx, 'filectx', workingfilectx) |
338 extensions.wrapfunction(patch, b'trydiff', trydiff) | 338 extensions.wrapfunction(patch, 'trydiff', trydiff) |
339 extensions.wrapfunction(hg, b'verify', _verify) | 339 extensions.wrapfunction(hg, 'verify', _verify) |
340 scmutil.fileprefetchhooks.add(b'remotefilelog', _fileprefetchhook) | 340 scmutil.fileprefetchhooks.add(b'remotefilelog', _fileprefetchhook) |
341 | 341 |
342 # disappointing hacks below | 342 # disappointing hacks below |
343 extensions.wrapfunction(scmutil, b'getrenamedfn', getrenamedfn) | 343 extensions.wrapfunction(scmutil, 'getrenamedfn', getrenamedfn) |
344 extensions.wrapfunction(revset, b'filelog', filelogrevset) | 344 extensions.wrapfunction(revset, 'filelog', filelogrevset) |
345 revset.symbols[b'filelog'] = revset.filelog | 345 revset.symbols[b'filelog'] = revset.filelog |
346 | 346 |
347 | 347 |
348 def cloneshallow(orig, ui, repo, *args, **opts): | 348 def cloneshallow(orig, ui, repo, *args, **opts): |
349 if opts.get('shallow'): | 349 if opts.get('shallow'): |
372 # wrapped. So we need to manually invoke our version of it. | 372 # wrapped. So we need to manually invoke our version of it. |
373 return exchangepull(orig, self, *args, **kwargs) | 373 return exchangepull(orig, self, *args, **kwargs) |
374 else: | 374 else: |
375 return orig(self, *args, **kwargs) | 375 return orig(self, *args, **kwargs) |
376 | 376 |
377 extensions.wrapfunction(exchange, b'pull', pull_shallow) | 377 extensions.wrapfunction(exchange, 'pull', pull_shallow) |
378 | 378 |
379 # Wrap the stream logic to add requirements and to pass include/exclude | 379 # Wrap the stream logic to add requirements and to pass include/exclude |
380 # patterns around. | 380 # patterns around. |
381 def setup_streamout(repo, remote): | 381 def setup_streamout(repo, remote): |
382 # Replace remote.stream_out with a version that sends file | 382 # Replace remote.stream_out with a version that sends file |
391 opts['excludepattern'] = b'\0'.join(repo.excludepattern) | 391 opts['excludepattern'] = b'\0'.join(repo.excludepattern) |
392 return remote._callstream(b'stream_out_shallow', **opts) | 392 return remote._callstream(b'stream_out_shallow', **opts) |
393 else: | 393 else: |
394 return orig() | 394 return orig() |
395 | 395 |
396 extensions.wrapfunction(remote, b'stream_out', stream_out_shallow) | 396 extensions.wrapfunction(remote, 'stream_out', stream_out_shallow) |
397 | 397 |
398 def stream_wrap(orig, op): | 398 def stream_wrap(orig, op): |
399 setup_streamout(op.repo, op.remote) | 399 setup_streamout(op.repo, op.remote) |
400 return orig(op) | 400 return orig(op) |
401 | 401 |
402 extensions.wrapfunction( | 402 extensions.wrapfunction( |
403 streamclone, b'maybeperformlegacystreamclone', stream_wrap | 403 streamclone, 'maybeperformlegacystreamclone', stream_wrap |
404 ) | 404 ) |
405 | 405 |
406 def canperformstreamclone(orig, pullop, bundle2=False): | 406 def canperformstreamclone(orig, pullop, bundle2=False): |
407 # remotefilelog is currently incompatible with the | 407 # remotefilelog is currently incompatible with the |
408 # bundle2 flavor of streamclones, so force us to use | 408 # bundle2 flavor of streamclones, so force us to use |
415 if requirements is not None: | 415 if requirements is not None: |
416 requirements.add(constants.SHALLOWREPO_REQUIREMENT) | 416 requirements.add(constants.SHALLOWREPO_REQUIREMENT) |
417 return supported, requirements | 417 return supported, requirements |
418 | 418 |
419 extensions.wrapfunction( | 419 extensions.wrapfunction( |
420 streamclone, b'canperformstreamclone', canperformstreamclone | 420 streamclone, 'canperformstreamclone', canperformstreamclone |
421 ) | 421 ) |
422 | 422 |
423 try: | 423 try: |
424 orig(ui, repo, *args, **opts) | 424 orig(ui, repo, *args, **opts) |
425 finally: | 425 finally: |
719 cachedelta, | 719 cachedelta, |
720 _metatuple=_metatuple, | 720 _metatuple=_metatuple, |
721 ) | 721 ) |
722 | 722 |
723 extensions.wrapfunction( | 723 extensions.wrapfunction( |
724 remotefilelog.remotefilelog, b'addrawrevision', addrawrevision | 724 remotefilelog.remotefilelog, 'addrawrevision', addrawrevision |
725 ) | 725 ) |
726 | 726 |
727 def changelogadd(orig, self, *args, **kwargs): | 727 def changelogadd(orig, self, *args, **kwargs): |
728 oldlen = len(self) | 728 oldlen = len(self) |
729 node = orig(self, *args, **kwargs) | 729 node = orig(self, *args, **kwargs) |
747 b'pending multiple integer revisions are not supported' | 747 b'pending multiple integer revisions are not supported' |
748 ) | 748 ) |
749 del pendingfilecommits[:] | 749 del pendingfilecommits[:] |
750 return node | 750 return node |
751 | 751 |
752 extensions.wrapfunction(changelog.changelog, b'add', changelogadd) | 752 extensions.wrapfunction(changelog.changelog, 'add', changelogadd) |
753 | 753 |
754 | 754 |
755 def getrenamedfn(orig, repo, endrev=None): | 755 def getrenamedfn(orig, repo, endrev=None): |
756 if not isenabled(repo) or copies.usechangesetcentricalgo(repo): | 756 if not isenabled(repo) or copies.usechangesetcentricalgo(repo): |
757 return orig(repo, endrev) | 757 return orig(repo, endrev) |
1081 ) | 1081 ) |
1082 | 1082 |
1083 if util.safehasattr(remote, b'_callstream'): | 1083 if util.safehasattr(remote, b'_callstream'): |
1084 remote._localrepo = repo | 1084 remote._localrepo = repo |
1085 elif util.safehasattr(remote, b'getbundle'): | 1085 elif util.safehasattr(remote, b'getbundle'): |
1086 extensions.wrapfunction(remote, b'getbundle', localgetbundle) | 1086 extensions.wrapfunction(remote, 'getbundle', localgetbundle) |
1087 | 1087 |
1088 return orig(repo, remote, *args, **kwargs) | 1088 return orig(repo, remote, *args, **kwargs) |
1089 | 1089 |
1090 | 1090 |
1091 def _fileprefetchhook(repo, revmatches): | 1091 def _fileprefetchhook(repo, revmatches): |