lkml.org 
[lkml]   [2008]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCHSCRIPT] MAINTAINERS: sort and merge P and M fields
Hello Linus,

some time ago I sent two patch scripts to LKML that changed the
MAINTAINERS file. One fixed the alphabetic ordering and another merged
the P and M fields to ease copy'n'paste.

See
http://thread.gmane.org/gmane.linux.kernel/702194
for the details.

I still like both changes, but I think it's not sensible to send you the
resulting patches because MAINTAINERS changes frequently.

If you like these two changes, too, I would be happy if you run the
attached script in your working copy. It simply wraps the two scripts
and commits the changes.

Note that you need to apply the patch below before the scripts will
work. And note further that the script expects a clean working copy to
start with, because it uses git commit -a.

Best regards
Uwe

---->8----
From: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Subject: [PATCH] Fix format of MAINTAINERS

... one entry lacked a colon which broke one of my scripts.

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
---
MAINTAINERS | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index af27945..b3e92fb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1593,7 +1593,7 @@ S: Supported
EMBEDDED LINUX
P: Paul Gortmaker
M: paul.gortmaker@windriver.com
-P David Woodhouse
+P: David Woodhouse
M: dwmw2@infradead.org
L: linux-embedded@vger.kernel.org
S: Maintained
--
1.5.6.5
#! /usr/bin/env python
# vim: set fileencoding=utf-8 :

import locale
import os

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

author = 'Uwe Kleine-König'
author_email = 'ukleinek@informatik.uni-freiburg.de'

script_sort = r"""#! /usr/bin/env python

import locale
import re
import sys
import tempfile

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

re_start = re.compile('P:')
re_topic = re.compile('[0-9a-zA-Z][^:]')
# F is undefined but used
re_field = re.compile('[PMLWTSF]:')
re_empty = re.compile('\s*$')

prologue = True
current_topic = None
topic = dict()
fixed_maintainers = tempfile.TemporaryFile()

for line in open('MAINTAINERS'):
if prologue:
print >> fixed_maintainers, line,
mo = re_start.match(line)
if mo:
prologue = False

continue

mo = re_topic.match(line)
if mo:
current_topic = line
if topic.has_key(current_topic):
sys.exit(1)
topic[current_topic] = list()
continue

elif current_topic is None:
# rest of prologue
print >> fixed_maintainers, line,

continue

assert not current_topic is None

mo = re_field.match(line)
if mo:
topic[current_topic].append(line)

else:
mo = re_empty.match(line)
if not mo:
print >> sys.stderr, 'tralala', current_topic, repr(line)
sys.exit(1)

first = True

the_rest = 'THE REST\n'
have_the_rest = False

# sort case insensitive
for t, body in sorted(topic.iteritems(), key=lambda i: i[0].upper()):
if t == the_rest:
have_the_rest = True
continue

if first:
first = False
else:
print >> fixed_maintainers

print >> fixed_maintainers, t,
for line in body:
print >> fixed_maintainers, line,

if have_the_rest:
print >> fixed_maintainers

print >> fixed_maintainers, the_rest,
for line in topic[the_rest]:
print >> fixed_maintainers, line,

fixed_maintainers.seek(0)

maintainers = open('MAINTAINERS', 'w')
for line in fixed_maintainers:
print >> maintainers, line,
"""

script_mergePM = r"""#! /usr/bin/env python

import locale
import re
import sys
import tempfile

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

re_person = re.compile('P:(\s*)(.*)')
re_mail = re.compile('M:\s*(.*)')

fixed_maintainers = tempfile.TemporaryFile()

current_person = None
current_person_used = False

for lineno, line in enumerate(open('MAINTAINERS')):
mo = re_person.match(line)
if mo:
if current_person and not current_person_used:
print >> fixed_maintainers, 'P:%s%s' % (current_person_intend, current_person)

current_person = mo.group(2)
current_person_intend = mo.group(1)
current_person_used = False
continue

mo = re_mail.match(line)
if mo:
if current_person is None:
print 'mail without person at line %d' % (lineno + 1)
sys.exit(1)

mail = mo.group(1)

if mail == 'Mail patches to':
mail = 'p.e@rs.on'

print >> fixed_maintainers, 'P:%s%s <%s>' % (current_person_intend, current_person, mail)
current_person_used = True

else:
if current_person and not current_person_used:
# either there is no mail address or the entry is already correct
print >> fixed_maintainers, 'P:%s%s' % (current_person_intend, current_person)

current_person = None
print >> fixed_maintainers, line,

fixed_maintainers.seek(0)

maintainers = open('MAINTAINERS', 'w')
for line in fixed_maintainers:
print >> maintainers, line,
"""

def tabintend(s):
lines = s.split('\n')
indented_lines = ('\t%s' % l for l in lines)
return '\n'.join(indented_lines)

intended_script_sort = tabintend(script_sort)
intended_script_mergePM = tabintend(script_mergePM)

exec script_sort in dict(globals())

os.system('git commit --author="%(author)s <%(author_email)s>" -a -m "MAINTAINERS: fix alphabetic ordering\n\nThis change was done using the following Python script:\n\n%(intended_script_sort)s\n\nSigned-off-by: %(author)s <%(author_email)s>\n"' % locals())

exec script_mergePM in dict(globals())

os.system('git commit --author="%(author)s <%(author_email)s>" -a -m "MAINTAINERS: merge P and M fields to ease copy\'n\'paste\n\nThis was suggested by Sam Ravnborg and done using the following\nPython script:\n\n%(intended_script_mergePM)s\n\nSigned-off-by: %(author)s <%(author_email)s>\n"' % locals())
\
 
 \ /
  Last update: 2008-09-09 00:15    [W:0.171 / U:8.120 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site