From fd2f374c2b424ef4d219f1c76b277ccf7e8ab3c3 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 16 May 2010 06:51:39 -0400 Subject: [PATCH] Add AUTHOR_HACKS and YEAR_HACKS to update_copyright.py This works around holes in the versioning where files were initially released before being added to the versioning system, or they were never committed under the name of one of the authors. --- update_copyright.py | 56 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/update_copyright.py b/update_copyright.py index 2f7d5a8..fa9f4ef 100755 --- a/update_copyright.py +++ b/update_copyright.py @@ -53,10 +53,13 @@ ALIASES = { 'Alberto Gomez-Casado': ['albertogomcas'], 'Massimo Sandal ': - ['devicerandom', + ['Massimo Sandal', + 'devicerandom', 'unknown'], 'Fabrizio Benedetti':['fabrizio.benedetti.82'], - 'Rolf Schmidt ':['illysam'], + 'Rolf Schmidt ': + ['Rolf Schmidt', + 'illysam'], 'Marco Brucale':['marcobrucale'], 'Pancaldi Paolo':['pancaldi.paolo'], } @@ -65,6 +68,44 @@ IGNORED_PATHS = ['./.hg/', './doc/img', './test/data/', './build/', '/doc/build/'] IGNORED_FILES = ['COPYING', 'COPYING.LESSER'] +# Work around missing author holes in the VCS history +AUTHOR_HACKS = { + ('hooke','driver','hdf5.py'):['Massimo Sandal'], + ('hooke','driver','mcs.py'):['Allen Chen'], + ('hooke','plugin','peakspot.py'):['Fabrizio Benedetti'], + } + +# Work around missing year holes in the VCS history +YEAR_HACKS = { + ('hooke','driver','hdf5.py'):2009, + ('hooke','driver','picoforce.py'):2006, + ('hooke','driver','picoforcealt.py'):2006, + ('hooke','plugin','peakspot.py'):2007, + ('hooke','plugin','tutorial.py'):2007, + } + +# Helpers for VCS-specific commands + +def splitpath(path): + """Recursively split a path into elements. + + Examples + -------- + + >>> splitpath(os.path.join('a', 'b', 'c')) + ('a', 'b', 'c') + >>> splitpath(os.path.join('.', 'a', 'b', 'c')) + ('a', 'b', 'c') + """ + path = os.path.normpath(path) + elements = [] + while True: + dirname,basename = os.path.split(path) + elements.insert(0,basename) + if dirname in ['', '.']: + break + path = dirname + return tuple(elements) # VCS-specific commands @@ -85,20 +126,25 @@ def mercurial_cmd(*args): return (tmp_stdout.getvalue().rstrip('\n'), tmp_stderr.getvalue().rstrip('\n')) -def original_year(filename): +def original_year(filename, year_hacks=YEAR_HACKS): # shortdate filter: YEAR-MONTH-DAY output,error = mercurial_cmd('log', '--follow', '--template', '{date|shortdate}\n', filename) years = [int(line.split('-', 1)[0]) for line in output.splitlines()] + if splitpath(filename) in year_hacks: + years.append(year_hacks[splitpath(filename)]) years.sort() return years[0] -def authors(filename): +def authors(filename, author_hacks=AUTHOR_HACKS): output,error = mercurial_cmd('log', '--follow', '--template', '{author}\n', filename) - return list(set(output.splitlines())) + ret = list(set(output.splitlines())) + if splitpath(filename) in author_hacks: + ret.extend(author_hacks[splitpath(filename)]) + return ret def authors_list(): output,error = mercurial_cmd('log', '--follow', -- 2.26.2