Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 52644:e627cc25b6f3
pyupgrade: rewrite `yield` statements in a loop to `yield from`
This is the `legacy` fixer in `pyupgrade`, with the `yield` statement yielding
loop commented back in. This seems to help pytype in some cases, and hurt it in
others. But that can be manually fixed later.
Note that it's possibly buggy in that it aggressively changed `import-checker.py`
to `yield from 'fcntl', 'grp', 'pwd', 'select', 'termios': # Unix only`, which
is invalid syntax. Possibly it needed help from the token fixer that I've
disabled locally (because that wants to make a bunch of unrelated changes).
Just change those few places to yield from a list, to avoid having to constantly
revert that.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 05 Jan 2025 22:26:16 -0500 |
parents | e6a44bc91bc2 |
children | 45dc0f874b8c |
comparison
equal
deleted
inserted
replaced
52643:5cc8deb96b48 | 52644:e627cc25b6f3 |
---|---|
632 If actions is None, all files are returned | 632 If actions is None, all files are returned |
633 """ | 633 """ |
634 # TODO: think whether we should return renamedelete and | 634 # TODO: think whether we should return renamedelete and |
635 # diverge filenames also | 635 # diverge filenames also |
636 if actions is None: | 636 if actions is None: |
637 for f in self._filemapping: | 637 yield from self._filemapping |
638 yield f | |
639 | 638 |
640 else: | 639 else: |
641 for a in actions: | 640 for a in actions: |
642 for f in self._actionmapping[a]: | 641 yield from self._actionmapping[a] |
643 yield f | |
644 | 642 |
645 def removefile(self, filename): | 643 def removefile(self, filename): |
646 """removes a file from the mergeresult object as the file might | 644 """removes a file from the mergeresult object as the file might |
647 not merging anymore""" | 645 not merging anymore""" |
648 action, data, message = self._filemapping[filename] | 646 action, data, message = self._filemapping[filename] |
675 | 673 |
676 return sum(len(self._actionmapping[a]) for a in actions) | 674 return sum(len(self._actionmapping[a]) for a in actions) |
677 | 675 |
678 def filemap(self, sort=False): | 676 def filemap(self, sort=False): |
679 if sort: | 677 if sort: |
680 for key, val in sorted(self._filemapping.items()): | 678 yield from sorted(self._filemapping.items()) |
681 yield key, val | |
682 else: | 679 else: |
683 for key, val in self._filemapping.items(): | 680 yield from self._filemapping.items() |
684 yield key, val | |
685 | 681 |
686 def addcommitinfo(self, filename, key, value): | 682 def addcommitinfo(self, filename, key, value): |
687 """adds key-value information about filename which will be required | 683 """adds key-value information about filename which will be required |
688 while committing this merge""" | 684 while committing this merge""" |
689 self._commitinfo[filename][key] = value | 685 self._commitinfo[filename][key] = value |