Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 50370:4fafc6642bee
cat: drop unnecessary internal roundtrip of kwargs
PyCharm seems to stick with the type at the initial assignment, so it flagged
the `get()` with a bytes key since the method argument has str keys. It wasn't
a bug, but then the bytes form is otherwise unused, and converted back to str.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 01 Mar 2023 11:33:57 -0500 |
parents | 798e4314ddd9 |
children | 7b0cc86c5d74 |
comparison
equal
deleted
inserted
replaced
50268:ffdfb1066ac6 | 50370:4fafc6642bee |
---|---|
2752 fm.data(path=path) | 2752 fm.data(path=path) |
2753 | 2753 |
2754 | 2754 |
2755 def cat(ui, repo, ctx, matcher, basefm, fntemplate, prefix, **opts): | 2755 def cat(ui, repo, ctx, matcher, basefm, fntemplate, prefix, **opts): |
2756 err = 1 | 2756 err = 1 |
2757 opts = pycompat.byteskwargs(opts) | |
2758 | 2757 |
2759 def write(path): | 2758 def write(path): |
2760 filename = None | 2759 filename = None |
2761 if fntemplate: | 2760 if fntemplate: |
2762 filename = makefilename( | 2761 filename = makefilename( |
2766 try: | 2765 try: |
2767 os.makedirs(os.path.dirname(filename)) | 2766 os.makedirs(os.path.dirname(filename)) |
2768 except OSError: | 2767 except OSError: |
2769 pass | 2768 pass |
2770 with formatter.maybereopen(basefm, filename) as fm: | 2769 with formatter.maybereopen(basefm, filename) as fm: |
2771 _updatecatformatter(fm, ctx, matcher, path, opts.get(b'decode')) | 2770 _updatecatformatter(fm, ctx, matcher, path, opts.get('decode')) |
2772 | 2771 |
2773 # Automation often uses hg cat on single files, so special case it | 2772 # Automation often uses hg cat on single files, so special case it |
2774 # for performance to avoid the cost of parsing the manifest. | 2773 # for performance to avoid the cost of parsing the manifest. |
2775 if len(matcher.files()) == 1 and not matcher.anypats(): | 2774 if len(matcher.files()) == 1 and not matcher.anypats(): |
2776 file = matcher.files()[0] | 2775 file = matcher.files()[0] |
2801 if not sub.cat( | 2800 if not sub.cat( |
2802 submatch, | 2801 submatch, |
2803 basefm, | 2802 basefm, |
2804 fntemplate, | 2803 fntemplate, |
2805 subprefix, | 2804 subprefix, |
2806 **pycompat.strkwargs(opts), | 2805 **opts, |
2807 ): | 2806 ): |
2808 err = 0 | 2807 err = 0 |
2809 except error.RepoLookupError: | 2808 except error.RepoLookupError: |
2810 ui.status( | 2809 ui.status( |
2811 _(b"skipping missing subrepository: %s\n") % uipathfn(subpath) | 2810 _(b"skipping missing subrepository: %s\n") % uipathfn(subpath) |