Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/diffhelper.py @ 43075:57875cf423c9
style: run a patched black on a subset of mercurial
This applied black to the 20 smallest files in mercurial/:
ls -S1 mercurial/*.py | tail -n20 | xargs black --skip-string-normalization
Note that a few files failed to format, presumably due to a bug in my
patch. The intent is to be able to compare results to D5064 with
https://github.com/python/black/pull/826 applied to black.
I skipped string normalization on this patch for clarity - in reality
I think we'd want one pass without string normalization, followed by
another to normalize strings (which is basically replacing ' with "
globally.)
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6342
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 05 Oct 2019 10:29:34 -0400 |
parents | e7aa113b14f7 |
children | 687b865b95ad |
comparison
equal
deleted
inserted
replaced
43074:9cc55b743713 | 43075:57875cf423c9 |
---|---|
11 | 11 |
12 from . import ( | 12 from . import ( |
13 error, | 13 error, |
14 pycompat, | 14 pycompat, |
15 ) | 15 ) |
16 | |
16 | 17 |
17 def addlines(fp, hunk, lena, lenb, a, b): | 18 def addlines(fp, hunk, lena, lenb, a, b): |
18 """Read lines from fp into the hunk | 19 """Read lines from fp into the hunk |
19 | 20 |
20 The hunk is parsed into two arrays, a and b. a gets the old state of | 21 The hunk is parsed into two arrays, a and b. a gets the old state of |
45 a.append(s) | 46 a.append(s) |
46 else: | 47 else: |
47 b.append(s[1:]) | 48 b.append(s[1:]) |
48 a.append(s) | 49 a.append(s) |
49 | 50 |
51 | |
50 def fixnewline(hunk, a, b): | 52 def fixnewline(hunk, a, b): |
51 """Fix up the last lines of a and b when the patch has no newline at EOF""" | 53 """Fix up the last lines of a and b when the patch has no newline at EOF""" |
52 l = hunk[-1] | 54 l = hunk[-1] |
53 # tolerate CRLF in last line | 55 # tolerate CRLF in last line |
54 if l.endswith('\r\n'): | 56 if l.endswith('\r\n'): |
60 b[-1] = hline[1:] | 62 b[-1] = hline[1:] |
61 if hline.startswith((' ', '-')): | 63 if hline.startswith((' ', '-')): |
62 a[-1] = hline | 64 a[-1] = hline |
63 hunk[-1] = hline | 65 hunk[-1] = hline |
64 | 66 |
67 | |
65 def testhunk(a, b, bstart): | 68 def testhunk(a, b, bstart): |
66 """Compare the lines in a with the lines in b | 69 """Compare the lines in a with the lines in b |
67 | 70 |
68 a is assumed to have a control char at the start of each line, this char | 71 a is assumed to have a control char at the start of each line, this char |
69 is ignored in the compare. | 72 is ignored in the compare. |