The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <ukleinek@informatik.uni-freiburg.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCHSCRIPT] MAINTAINERS: sort and merge P and M fields
Date: Tue, 9 Sep 2008 00:11:39 +0200	[thread overview]
Message-ID: <20080908221139.GA10991@cassiopeia.tralala> (raw)

[-- Attachment #1: Type: text/plain, Size: 1423 bytes --]

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


[-- Attachment #2: maintainers --]
[-- Type: text/plain, Size: 4504 bytes --]

#! /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())

             reply	other threads:[~2008-09-08 22:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-08 22:11 Uwe Kleine-König [this message]
2008-09-08 22:19 ` [PATCHSCRIPT] MAINTAINERS: sort and merge P and M fields Randy Dunlap
2008-09-09 19:49 ` Uwe Kleine-König
2008-09-09 23:37 ` Paul Bolle
2008-09-10 19:32   ` Uwe Kleine-König
2008-09-10 19:51     ` [PATCH] Reformat MAINTAINERS entry for Cirrus CS4280/CS461X sound driver Uwe Kleine-König
2008-09-10 19:51       ` [PATCH] MAINTAINERS: add a realname for adilger@sun.com Uwe Kleine-König
2008-09-10 19:51         ` [PATCH] MAINTAINERS: remove real names from M fields Uwe Kleine-König
2008-09-10 19:51           ` [PATCH] MAINTAINERS: put corresponding realnames and mail addresses together Uwe Kleine-König
2008-09-10 19:51             ` [PATCH] MAINTAINERS: fix alphabetic ordering Uwe Kleine-König
2008-09-10 19:51               ` [PATCH] MAINTAINERS: merge P and M fields to ease copy'n'paste Uwe Kleine-König
2008-09-10 19:57       ` [PATCH] Reformat MAINTAINERS entry for Cirrus CS4280/CS461X sound driver Uwe Kleine-König
2008-09-10 21:10       ` Nils Faerber
2008-09-12  9:58     ` MAINTAINERS cleanup Uwe Kleine-König
2008-09-12 10:00       ` [PATCH] MAINTAINERS: Remove a stale entry refering to kernel 2.2 Uwe Kleine-König
2008-09-12 10:00         ` [PATCH] MAINTAINERS: add a realname for adilger@sun.com Uwe Kleine-König
2008-09-12 10:00           ` [PATCH] MAINTAINERS: remove real names from M fields Uwe Kleine-König
2008-09-12 10:00             ` [PATCH] MAINTAINERS: put corresponding realnames and mail addresses together Uwe Kleine-König
2008-09-22  9:39       ` [RESEND] MAINTAINERS cleanup Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080908221139.GA10991@cassiopeia.tralala \
    --to=ukleinek@informatik.uni-freiburg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox