Mercurial > public > mercurial-scm > hg
comparison mercurial/rewriteutil.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 | 8c6329fa6038 |
children | 687b865b95ad |
comparison
equal
deleted
inserted
replaced
43074:9cc55b743713 | 43075:57875cf423c9 |
---|---|
14 node, | 14 node, |
15 obsolete, | 15 obsolete, |
16 revset, | 16 revset, |
17 ) | 17 ) |
18 | 18 |
19 | |
19 def precheck(repo, revs, action='rewrite'): | 20 def precheck(repo, revs, action='rewrite'): |
20 """check if revs can be rewritten | 21 """check if revs can be rewritten |
21 action is used to control the error message. | 22 action is used to control the error message. |
22 | 23 |
23 Make sure this function is called after taking the lock. | 24 Make sure this function is called after taking the lock. |
24 """ | 25 """ |
25 if node.nullrev in revs: | 26 if node.nullrev in revs: |
26 msg = _("cannot %s null changeset") % (action) | 27 msg = _("cannot %s null changeset") % action |
27 hint = _("no changeset checked out") | 28 hint = _("no changeset checked out") |
28 raise error.Abort(msg, hint=hint) | 29 raise error.Abort(msg, hint=hint) |
29 | 30 |
30 if len(repo[None].parents()) > 1: | 31 if len(repo[None].parents()) > 1: |
31 raise error.Abort(_("cannot %s while merging") % action) | 32 raise error.Abort(_("cannot %s while merging") % action) |
32 | 33 |
33 publicrevs = repo.revs('%ld and public()', revs) | 34 publicrevs = repo.revs('%ld and public()', revs) |
34 if publicrevs: | 35 if publicrevs: |
35 msg = _("cannot %s public changesets") % (action) | 36 msg = _("cannot %s public changesets") % action |
36 hint = _("see 'hg help phases' for details") | 37 hint = _("see 'hg help phases' for details") |
37 raise error.Abort(msg, hint=hint) | 38 raise error.Abort(msg, hint=hint) |
38 | 39 |
39 newunstable = disallowednewunstable(repo, revs) | 40 newunstable = disallowednewunstable(repo, revs) |
40 if newunstable: | 41 if newunstable: |
41 raise error.Abort(_("cannot %s changeset with children") % action) | 42 raise error.Abort(_("cannot %s changeset with children") % action) |
43 | |
42 | 44 |
43 def disallowednewunstable(repo, revs): | 45 def disallowednewunstable(repo, revs): |
44 """Checks whether editing the revs will create new unstable changesets and | 46 """Checks whether editing the revs will create new unstable changesets and |
45 are we allowed to create them. | 47 are we allowed to create them. |
46 | 48 |