Files
@ 2d6ec8b9b633
Branch filter:
Location: kallithea/scripts/logformat.py - annotation
2d6ec8b9b633
1.7 KiB
text/x-python
email templates: reorder references to pullrequests
The current references to PRs in email templates are:
Pull request from <repo> branch <branch> to <repo> branch <branch>:
<niceid> <title> by <user>
as the first line can become very long and therefore hard to read, a first
step is to introduce a newline before the destination branch:
Pull request from <repo> branch <branch>
to <repo> branch <branch>:
<niceid> <title> by <user>
But it would be nicer if the from/to part aligns more.
Moreover, the most useful part is (hopefully) the PR title, the from/to is
secondary and can sometimes even be inferred from the title and context the
recipient is already aware of.
Thus, this commit proposes the following format:
Pull request <niceid> <title> by <user>
from <repo> branch <branch>
to <repo> branch <branch>
This adds some divergence with the changeset references, which could be
aligned later if desired.
The current references to PRs in email templates are:
Pull request from <repo> branch <branch> to <repo> branch <branch>:
<niceid> <title> by <user>
as the first line can become very long and therefore hard to read, a first
step is to introduce a newline before the destination branch:
Pull request from <repo> branch <branch>
to <repo> branch <branch>:
<niceid> <title> by <user>
But it would be nicer if the from/to part aligns more.
Moreover, the most useful part is (hopefully) the PR title, the from/to is
secondary and can sometimes even be inferred from the title and context the
recipient is already aware of.
Thus, this commit proposes the following format:
Pull request <niceid> <title> by <user>
from <repo> branch <branch>
to <repo> branch <branch>
This adds some divergence with the changeset references, which could be
aligned later if desired.
8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 665dfa112f2c 8bc8366a6874 8bc8366a6874 665dfa112f2c | #!/usr/bin/env python2
import re
import sys
if len(sys.argv) < 2:
print 'Cleanup of superfluous % formatting of log statements.'
print 'Usage:'
print ''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff'''
raise SystemExit(1)
logre = r'''
(log\.(?:error|info|warning|debug)
[(][ \n]*
)
%s
(
[ \n]*[)]
)
'''
res = [
# handle % () - keeping spaces around the old %
(re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) \( ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) \) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# handle % without () - keeping spaces around the old %
(re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# remove extra space if it is on next line
(re.compile(logre % r'''("[^"]*"|'[^']*') , (\n [ ]) ([ ][\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# remove extra space if it is on same line
(re.compile(logre % r'''("[^"]*"|'[^']*') , [ ]+ () ( [\n ]+) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# remove trailing , and space
(re.compile(logre % r'''("[^"]*"|'[^']*') , () ( [\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
]
for f in sys.argv[1:]:
s = open(f).read()
for r, t in res:
s = r.sub(t, s)
open(f, 'w').write(s)
|