Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 50836:180ac919f062
locate: migrate `opts` to native kwargs
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 20 Aug 2023 01:27:36 -0400 |
parents | 2bbc76528733 |
children | 2c78ebaf4c2a |
comparison
equal
deleted
inserted
replaced
50835:2bbc76528733 | 50836:180ac919f062 |
---|---|
4495 | 4495 |
4496 See :hg:`help files` for a more versatile command. | 4496 See :hg:`help files` for a more versatile command. |
4497 | 4497 |
4498 Returns 0 if a match is found, 1 otherwise. | 4498 Returns 0 if a match is found, 1 otherwise. |
4499 """ | 4499 """ |
4500 opts = pycompat.byteskwargs(opts) | 4500 if opts.get('print0'): |
4501 if opts.get(b'print0'): | |
4502 end = b'\0' | 4501 end = b'\0' |
4503 else: | 4502 else: |
4504 end = b'\n' | 4503 end = b'\n' |
4505 ctx = logcmdutil.revsingle(repo, opts.get(b'rev'), None) | 4504 ctx = logcmdutil.revsingle(repo, opts.get('rev'), None) |
4506 | 4505 |
4507 ret = 1 | 4506 ret = 1 |
4508 m = scmutil.match( | 4507 m = scmutil.match( |
4509 ctx, pats, opts, default=b'relglob', badfn=lambda x, y: False | 4508 ctx, |
4509 pats, | |
4510 pycompat.byteskwargs(opts), | |
4511 default=b'relglob', | |
4512 badfn=lambda x, y: False, | |
4510 ) | 4513 ) |
4511 | 4514 |
4512 ui.pager(b'locate') | 4515 ui.pager(b'locate') |
4513 if ctx.rev() is None: | 4516 if ctx.rev() is None: |
4514 # When run on the working copy, "locate" includes removed files, so | 4517 # When run on the working copy, "locate" includes removed files, so |
4516 filesgen = sorted(repo.dirstate.matches(m)) | 4519 filesgen = sorted(repo.dirstate.matches(m)) |
4517 else: | 4520 else: |
4518 filesgen = ctx.matches(m) | 4521 filesgen = ctx.matches(m) |
4519 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats)) | 4522 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats)) |
4520 for abs in filesgen: | 4523 for abs in filesgen: |
4521 if opts.get(b'fullpath'): | 4524 if opts.get('fullpath'): |
4522 ui.write(repo.wjoin(abs), end) | 4525 ui.write(repo.wjoin(abs), end) |
4523 else: | 4526 else: |
4524 ui.write(uipathfn(abs), end) | 4527 ui.write(uipathfn(abs), end) |
4525 ret = 0 | 4528 ret = 0 |
4526 | 4529 |