#!/usr/bin/python
### forward-diffs.py --- forward emacs-diffs mails to maintainers
-## Copyright (C) 2012 Free Software Foundation, Inc.
+## Copyright (C) 2012-2014 Free Software Foundation, Inc.
## Author: Glenn Morris <rgm@gnu.org>
+## Maintainer: emacs-devel@gnu.org
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
##
## package1/file1 email1
## package2/file2 email2,email3
+## package3 email4
##
## Use "nomail" for the email field to not send a mail.
+## An entry that is a directory applies to all files in that directory
+## that do not have specific maintainers.
##
## overmaint = like maintfile, but takes precedence over it.
help="sender address for forwards")
parser.add_option( "--create", dest="create", default=False,
action="store_true", help="create maintfile")
-parser.add_option( "--no-scan", dest="noscan", default=False,
+parser.add_option( "--no-scan", dest="noscan", default=True,
action="store_true",
help="don't scan for maintainers; implies --no-update")
parser.add_option( "--no-update", dest="noupdate", default=False,
parser.error('No sender specified')
-## Create the maintfile.
-if opts.create:
- scan_dir( opts.packagedir, opts.maintfile )
- sys.exit()
-
-
try:
lfile = open( opts.logfile, 'a' )
except Exception as err:
lfile.write('Error opening maintfile: %s\n' % str(err))
sys.exit(1)
+## Create the maintfile.
+if opts.create:
+ scan_dir( opts.packagedir, opts.maintfile )
+ sys.exit()
+
+
## Each element is package/file: maint1, maint2, ...
maints = {}
for line in text.splitlines():
- if re.match( 'modified:$', line ):
+ # Look for and process things that look like (Git):
+ #
+ # Summary of changes:
+ # packages/vlf/vlf.el | 2 +-
+ # 1 files changed, 1 insertions(+), 1 deletions(-)
+ #
+ # or things that look like (Git):
+ #
+ # ---
+ # packages/vlf/vlf.el | 2 +-
+ # 1 files changed, 1 insertions(+), 1 deletions(-)
+
+ #BZR: if re.match( 'modified:$', line ):
+ if re.match( '---|Summary of changes:$', line ):
start = True
continue
## An empty line or a line with non-empty first character.
if re.match( '( *$|[^ ])', line ): break
-
+ # Any line that doesn't match the diffstat format (Git).
+ if not re.match( ' [^ ]+ +\| ', line ):
+ lfile.write('Stop scanning at: %s\n' % line)
+ break
if opts.prefix:
- reg = re.match( '%s([^ ]+)' % opts.prefix, line.strip() )
- if not reg: continue
+ #BZR: reg = re.match( '%s([^ ]+)' % opts.prefix, line.strip() )
+ reg = re.match( ' %s([^ ]+)' % opts.prefix, line )
+ if not reg:
+ lfile.write('Skip: %s\n' % line)
+ continue
pfile = reg.group(1)
else:
pfile = line.strip()
lfile.write('Unknown maintainer\n')
- if opts.noscan: continue
-
- lfile.write('Scanning file...\n')
- thismaint = []
- thisfile = os.path.join( opts.packagedir, pfile )
- scan_file( thisfile, thismaint )
- if not thismaint: continue
+ if not opts.noscan:
+
+ lfile.write('Scanning file...\n')
+ thismaint = []
+ thisfile = os.path.join( opts.packagedir, pfile )
+ # scan_file( thisfile, thismaint )
+
+ if thismaint:
+ maints[pfile] = thismaint
+
+ ## Append maintainer to file.
+ if not opts.noupdate:
+ try:
+ mfile = open( opts.maintfile, 'a' )
+ string = "%-50s %s\n" % (pfile, ",".join(thismaint))
+ mfile.write(string)
+ mfile.close()
+ lfile.write('Appended to maintfile\n')
+ except Exception as err:
+ lfile.write('Error appending to maintfile: %s\n' %
+ str(err))
+
+ ## Didn't scan, or scanning did not work.
+ ## Look for a directory maintainer.
+ if not pfile in maints:
+ lfile.write('No file maintainer, trying directories...\n')
+ while True:
+ (pfile, tail) = os.path.split(pfile)
+ if not pfile: break
+ if pfile in maints: break
- maints[pfile] = thismaint
- ## Append maintainer to file.
- if not opts.noupdate:
- try:
- mfile = open( opts.maintfile, 'a' )
- string = "%-50s %s\n" % (pfile, ",".join(thismaint))
- mfile.write(string)
- mfile.close()
- lfile.write('Appended to maintfile\n')
- except Exception as err:
- lfile.write('Error appending to maintfile: %s\n' % str(err))
+ if not pfile in maints:
+ lfile.write('No maintainer, skipping\n')
+ continue
for maint in maints[pfile]: