match: indent a large block of code that needs a context manager
No changes here, other than running `black`.
--- a/mercurial/match.py Tue Dec 17 01:10:28 2024 -0500
+++ b/mercurial/match.py Tue Dec 17 01:16:59 2024 -0500
@@ -1737,45 +1737,47 @@
patterns = []
fp = open(filepath, 'rb')
- for lineno, line in enumerate(fp, start=1):
- if b"#" in line:
- global _commentre
- if not _commentre:
- _commentre = util.re.compile(br'((?:^|[^\\])(?:\\\\)*)#.*')
- # remove comments prefixed by an even number of escapes
- m = _commentre.search(line)
- if m:
- line = line[: m.end(1)]
- # fixup properly escaped comments that survived the above
- line = line.replace(b"\\#", b"#")
- line = line.rstrip()
- if not line:
- continue
+ if True:
+ for lineno, line in enumerate(fp, start=1):
+ if b"#" in line:
+ global _commentre
+ if not _commentre:
+ _commentre = util.re.compile(br'((?:^|[^\\])(?:\\\\)*)#.*')
+ # remove comments prefixed by an even number of escapes
+ m = _commentre.search(line)
+ if m:
+ line = line[: m.end(1)]
+ # fixup properly escaped comments that survived the above
+ line = line.replace(b"\\#", b"#")
+ line = line.rstrip()
+ if not line:
+ continue
- if line.startswith(b'syntax:'):
- s = line[7:].strip()
- try:
- syntax = syntaxes[s]
- except KeyError:
- if warn:
- warn(
- _(b"%s: ignoring invalid syntax '%s'\n") % (filepath, s)
- )
- continue
+ if line.startswith(b'syntax:'):
+ s = line[7:].strip()
+ try:
+ syntax = syntaxes[s]
+ except KeyError:
+ if warn:
+ warn(
+ _(b"%s: ignoring invalid syntax '%s'\n")
+ % (filepath, s)
+ )
+ continue
- linesyntax = syntax
- for s, rels in syntaxes.items():
- if line.startswith(rels):
- linesyntax = rels
- line = line[len(rels) :]
- break
- elif line.startswith(s + b':'):
- linesyntax = rels
- line = line[len(s) + 1 :]
- break
- if sourceinfo:
- patterns.append((linesyntax + line, lineno, line))
- else:
- patterns.append(linesyntax + line)
+ linesyntax = syntax
+ for s, rels in syntaxes.items():
+ if line.startswith(rels):
+ linesyntax = rels
+ line = line[len(rels) :]
+ break
+ elif line.startswith(s + b':'):
+ linesyntax = rels
+ line = line[len(s) + 1 :]
+ break
+ if sourceinfo:
+ patterns.append((linesyntax + line, lineno, line))
+ else:
+ patterns.append(linesyntax + line)
fp.close()
return patterns