Fill blank fields of doc/README.scrapyard with a tool
cover Fill blank fields of doc/README.scrapyard with a tool
Masahiro Yamada (2):
scripts: add a utility to fill blank fields of doc/README.scrapyard README.scrapyard: fill commit and date fields
doc/README.scrapyard | 96 +++++++++++++------------- scripts/fill_scrapyard.py | 168 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+), 48 deletions(-) create mode 100755 scripts/fill_scrapyard.py
Signature · 1 line
1.9.1
PATCH 1/2 scripts: add a utility to fill blank fields of doc/README.scrapyard
We are removing bunch of non-generic boards these days.
Updating doc/README.scrapyard is a really tedious task, but it can be automated. I hope this tool will make our life easier.
---
scripts/fill_scrapyard.py | 168 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100755 scripts/fill_scrapyard.py
scripts/fill_scrapyard.py new file +168 -0
@@ -0,0 +1,168 @@ +#!/usr/bin/env python2 +# +# Author: Masahiro Yamada <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +""" +Fill the "Commit" and "Removed" fields of doc/README.scrapyard + +The file doc/README.scrapyard is used to keep track of removed boards. + +When we remove support for boards, we are supposed to add entries to +doc/README.scrapyard leaving "Commit" and "Removed" fields blank. + +The "Commit" field is the commit hash in which the board was removed +and the "Removed" is the date at which the board was removed. Those +two are known only after the board removal patch was applied, thus they +need to be filled in later. + +This effectively means that the person who removes another board is +first supposed to fill in the blank fields and then add the board that +is being removed, again with blank fields for the commit hash and date +of removal. + +That is a really tedious task that should be automated. +This script fills the blank fields of doc/README.scrapyard for you! + +Usage: + +The "Commit" and "Removed" fields must be "-". The other fields should +have already been filled in by a former commit. + +Run + scripts/fill_scrapyard.py +""" + +import os +import subprocess +import sys +import tempfile + +DOC='doc/README.scrapyard' + +def get_last_modify_commit(file, line_num): + """Get the commit that last modified the given line. + + This function runs "git blame" against the given line of the given + file and returns the commit hash that last modified it. + + Arguments: + file: the file to be git-blame'd. + line_num: the line number to be git-blame'd. This line number + starts from 1, not 0. + + Returns: + Commit hash that last modified the line. The number of digits is + long enough to form a unique commit. + """ + result = subprocess.check_output(['git', 'blame', '-L', + '%d,%d' % (line_num, line_num), file]) + commit = result.split()[0] + + if commit[0] == '^': + sys.exit('%s: line %d: ' % (file, line_num) + + 'this line was modified before the beginning of git history') + + if commit == '0' * len(commit): + sys.exit('%s: line %d: locally modified\n' % (file, line_num) + + 'Please run this tool in a clean repository.') + + return commit + +def get_committer_date(commit): + """Get the committer date of the given commit. + + This function returns the date when the given commit was applied. + + Arguments: + commit: commit-ish object. + + Returns: + The committer date of the given commit in the form YY-MM-DD. + """ + committer_date = subprocess.check_output(['git', 'show', '-s', + '--format=%ci', commit]) + return committer_date.split()[0] + +def move_to_topdir(): + """Change directory to the top of the git repository. + + Or, exit with an error message if called out of a git repository. + """ + try: + toplevel = subprocess.check_output(['git', 'rev-parse', + '--show-toplevel']) + except subprocess.CalledProcessError: + sys.exit('Please run in a git repository.') + + # strip '\n' + toplevel = toplevel.rstrip() + + # Change the current working directory to the toplevel of the respository + # for our easier life. + os.chdir(toplevel) + +class TmpFile: + + """Useful class to handle a temporary file. + + tempfile.mkstemp() is often used to create a unique temporary file, + but what is inconvenient is that the caller is responsible for + deleting the file when done with it. + + Even when the caller errors out on the way, the temporary file must + be deleted somehow. The idea here is that we delete the file in + the destructor of this class because the destructor is always + invoked when the instance of the class is freed. + """ + + def __init__(self): + """Constructor - create a temporary file""" + fd, self.filename = tempfile.mkstemp() + self.file = os.fdopen(fd, 'w') + + def __del__(self): + """Destructor - delete the temporary file""" + try: + os.remove(self.filename) + except: + pass + +def main(): + move_to_topdir() + + with open(DOC) as f: + lines = f.readlines() + + line_num = 1 + + tmpfile = TmpFile() + for line in open(DOC): + tmp = line.split(None, 5) + modified = False + + if len(tmp) >= 5: + if tmp[3] == '-': + tmp[3] = get_last_modify_commit(DOC, line_num) + modified = True + if tmp[4] == '-': + tmp[4] = get_committer_date(tmp[3]) + if modified: + line = tmp[0].ljust(17) + line += tmp[1].ljust(12) + line += tmp[2].ljust(15) + line += tmp[3].ljust(12) + line += tmp[4].ljust(12) + if len(tmp) >= 6: + line += tmp[5] + line = line.rstrip() + '\n' + + tmpfile.file.write(line) + line_num += 1 + + os.rename(tmpfile.filename, DOC) + +if __name__ == '__main__': + main()
Signature · 1 line
1.9.1
PATCH 1/2 scripts: add a utility to fill blank fields of doc/README.scrapyard
Hi Masahiro,
Quoted 11 lines · Masahiro Yamada
We are removing bunch of non-generic boards these days.
Updating doc/README.scrapyard is a really tedious task, but it can be automated. I hope this tool will make our life easier.
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/fill_scrapyard.py | 168 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100755 scripts/fill_scrapyard.py
Note there is gitutils.GetTopLevel() available. I don't think you want to use the patman libraries, but thought I would mention it.
Quoted 176 lines
scripts/fill_scrapyard.py new file +168
-1@@ -0,0 +1,168 @@ +#!/usr/bin/env python2 +# +# Author: Masahiro Yamada <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +""" +Fill the "Commit" and "Removed" fields of doc/README.scrapyard + +The file doc/README.scrapyard is used to keep track of removed boards. + +When we remove support for boards, we are supposed to add entries to +doc/README.scrapyard leaving "Commit" and "Removed" fields blank. + +The "Commit" field is the commit hash in which the board was removed +and the "Removed" is the date at which the board was removed. Those +two are known only after the board removal patch was applied, thus they +need to be filled in later. + +This effectively means that the person who removes another board is +first supposed to fill in the blank fields and then add the board that +is being removed, again with blank fields for the commit hash and date +of removal. + +That is a really tedious task that should be automated. +This script fills the blank fields of doc/README.scrapyard for you! + +Usage: + +The "Commit" and "Removed" fields must be "-". The other fields should +have already been filled in by a former commit. + +Run + scripts/fill_scrapyard.py +""" + +import os +import subprocess +import sys +import tempfile + +DOC='doc/README.scrapyard' + +def get_last_modify_commit(file, line_num): + """Get the commit that last modified the given line. + + This function runs "git blame" against the given line of the given + file and returns the commit hash that last modified it. + + Arguments: + file: the file to be git-blame'd. + line_num: the line number to be git-blame'd. This line number + starts from 1, not 0. + + Returns: + Commit hash that last modified the line. The number of digits is + long enough to form a unique commit. + """ + result = subprocess.check_output(['git', 'blame', '-L', + '%d,%d' % (line_num, line_num), file]) + commit = result.split()[0] + + if commit[0] == '^': + sys.exit('%s: line %d: ' % (file, line_num) + + 'this line was modified before the beginning of git history') + + if commit == '0' * len(commit): + sys.exit('%s: line %d: locally modified\n' % (file, line_num) + + 'Please run this tool in a clean repository.') + + return commit + +def get_committer_date(commit): + """Get the committer date of the given commit. + + This function returns the date when the given commit was applied. + + Arguments: + commit: commit-ish object. + + Returns: + The committer date of the given commit in the form YY-MM-DD. + """ + committer_date = subprocess.check_output(['git', 'show', '-s', + '--format=%ci', commit]) + return committer_date.split()[0] + +def move_to_topdir(): + """Change directory to the top of the git repository. + + Or, exit with an error message if called out of a git repository. + """ + try: + toplevel = subprocess.check_output(['git', 'rev-parse', + '--show-toplevel']) + except subprocess.CalledProcessError: + sys.exit('Please run in a git repository.') + + # strip '\n' + toplevel = toplevel.rstrip() + + # Change the current working directory to the toplevel of the respository + # for our easier life. + os.chdir(toplevel) + +class TmpFile: + + """Useful class to handle a temporary file. + + tempfile.mkstemp() is often used to create a unique temporary file, + but what is inconvenient is that the caller is responsible for + deleting the file when done with it. + + Even when the caller errors out on the way, the temporary file must + be deleted somehow. The idea here is that we delete the file in + the destructor of this class because the destructor is always + invoked when the instance of the class is freed. + """ + + def __init__(self): + """Constructor - create a temporary file""" + fd, self.filename = tempfile.mkstemp() + self.file = os.fdopen(fd, 'w') + + def __del__(self): + """Destructor - delete the temporary file""" + try: + os.remove(self.filename) + except: + pass + +def main(): + move_to_topdir() + + with open(DOC) as f: + lines = f.readlines() + + line_num = 1 + + tmpfile = TmpFile() + for line in open(DOC): + tmp = line.split(None, 5) + modified = False + + if len(tmp) >= 5: + if tmp[3] == '-': + tmp[3] = get_last_modify_commit(DOC, line_num) + modified = True + if tmp[4] == '-': + tmp[4] = get_committer_date(tmp[3]) + if modified: + line = tmp[0].ljust(17) + line += tmp[1].ljust(12) + line += tmp[2].ljust(15) + line += tmp[3].ljust(12) + line += tmp[4].ljust(12) + if len(tmp) >= 6: + line += tmp[5] + line = line.rstrip() + '\n' + + tmpfile.file.write(line) + line_num += 1 + + os.rename(tmpfile.filename, DOC) + +if __name__ == '__main__': + main() --
Quoted 2 lines
1.9.1
Regards,
Simon
PATCH 2/2 README.scrapyard: fill commit and date fields
In reply to Masahiro YamadaThis commit was generated by the following command:
scripts/fill_scrapyard.py
---
I notice lots of ppc4xx boards are being removed.
I will send v2 later.
doc/README.scrapyard | 96 ++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-)
doc/README.scrapyard +48 -48
@@ -12,54 +12,54 @@ The list should be sorted in reverse chronological order. Board Arch CPU Commit Removed Last known maintainer/contact ================================================================================================= -A3000 powerpc mpc824x - - -CPC45 powerpc mpc824x - - Josef Wagner <[email protected]> -CU824 powerpc mpc824x - - Wolfgang Denk <[email protected]> -eXalion powerpc mpc824x - - Torsten Demke <[email protected]> -MVBLUE powerpc mpc824x - - -MUSENKI powerpc mpc824x - - Jim Thompson <[email protected]> -Sandpoint8240 powerpc mpc824x - - Wolfgang Denk <[email protected]> -Sandpoint8245 powerpc mpc824x - - Jim Thompson <[email protected]> -utx8245 powerpc mpc824x - - Greg Allen <[email protected]> -atc powerpc mpc8260 - - Wolfgang Denk <[email protected]> -CPU86 powerpc mpc8260 - - Wolfgang Denk <[email protected]> -CPU87 powerpc mpc8260 - - -ep82xxm powerpc mpc8260 - - -gw8260 powerpc mpc8260 - - Oliver Brown <[email protected]> -IPHASE4539 powerpc mpc8260 - - Wolfgang Grandegger <[email protected]> -muas3001 powerpc mpc8260 - - Heiko Schocher <[email protected]> -PM825 powerpc mpc8260 - - Wolfgang Denk <[email protected]> -PM826 powerpc mpc8260 - - Wolfgang Denk <[email protected]> -PM828 powerpc mpc8260 - - -MPC8266ADS powerpc mpc8260 - - Rune Torgersen <[email protected]> -VoVPN-GW powerpc mpc8260 - - -ep8260 powerpc mpc8260 - - Frank Panno <[email protected]> -ppmc8260 powerpc mpc8260 - - Brad Kemp <[email protected]> -sacsng powerpc mpc8260 - - Jerry Van Baren <[email protected]> -cogent_mpc8260 powerpc mpc8260 - - Murray Jensen <[email protected]> -cogent_8xx powerpc mpc8xx - - Murray Jensen <[email protected]> -ESTEEM192E powerpc mpc8xx - - Conn Clark <[email protected]> -IP860 powerpc mpc8xx - - Wolfgang Denk <[email protected]> -IVML24 powerpc mpc8xx - - Wolfgang Denk <[email protected]> -IVMS8 powerpc mpc8xx - - Wolfgang Denk <[email protected]> -lwmon powerpc mpc8xx - - Wolfgang Denk <[email protected]> -NETVIA powerpc mpc8xx - - Pantelis Antoniou <[email protected]> -R360MPI powerpc mpc8xx - - Wolfgang Denk <[email protected]> -RRvision powerpc mpc8xx - - Wolfgang Denk <[email protected]> -SPD823TS powerpc mpc8xx - - Wolfgang Denk <[email protected]> -KUP4K powerpc mpc8xx - - Klaus Heydeck <[email protected]> -KUP4X powerpc mpc8xx - - Klaus Heydeck <[email protected]> -ELPT860 powerpc mpc8xx - - The LEOX team <[email protected]> -hmi1001 powerpc mpc5xxx - - -mucmc52 powerpc mpc5xxx - - Heiko Schocher <[email protected]> -uc101 powerpc mpc5xxx - - Heiko Schocher <[email protected]> -uc100 powerpc mpc8xx - - Stefan Roese <[email protected]> -FPS850L powerpc mpc8xx - - Wolfgang Denk <[email protected]> -FPS860L powerpc mpc8xx - - Wolfgang Denk <[email protected]> -NSCU powerpc mpc8xx - - -SM850 powerpc mpc8xx - - Wolfgang Denk <[email protected]> -TK885D powerpc mpc8xx - - -virtlab2 powerpc mpc8xx - - Wolfgang Denk <[email protected]> +A3000 powerpc mpc824x d622ac39 2015-01-05 +CPC45 powerpc mpc824x d622ac39 2015-01-05 Josef Wagner <[email protected]> +CU824 powerpc mpc824x d622ac39 2015-01-05 Wolfgang Denk <[email protected]> +eXalion powerpc mpc824x d622ac39 2015-01-05 Torsten Demke <[email protected]> +MVBLUE powerpc mpc824x d622ac39 2015-01-05 +MUSENKI powerpc mpc824x d622ac39 2015-01-05 Jim Thompson <[email protected]> +Sandpoint8240 powerpc mpc824x d622ac39 2015-01-05 Wolfgang Denk <[email protected]> +Sandpoint8245 powerpc mpc824x d622ac39 2015-01-05 Jim Thompson <[email protected]> +utx8245 powerpc mpc824x d622ac39 2015-01-05 Greg Allen <[email protected]> +atc powerpc mpc8260 9067b300 2015-01-05 Wolfgang Denk <[email protected]> +CPU86 powerpc mpc8260 f7e1af86 2015-01-05 Wolfgang Denk <[email protected]> +CPU87 powerpc mpc8260 f7e1af86 2015-01-05 +ep82xxm powerpc mpc8260 e2b19629 2015-01-05 +gw8260 powerpc mpc8260 8eecbaf3 2015-01-05 Oliver Brown <[email protected]> +IPHASE4539 powerpc mpc8260 87882f57 2015-01-05 Wolfgang Grandegger <[email protected]> +muas3001 powerpc mpc8260 d2fd1d66 2015-01-05 Heiko Schocher <[email protected]> +PM825 powerpc mpc8260 dc0b2fb4 2015-01-05 Wolfgang Denk <[email protected]> +PM826 powerpc mpc8260 dc0b2fb4 2015-01-05 Wolfgang Denk <[email protected]> +PM828 powerpc mpc8260 dc0b2fb4 2015-01-05 +MPC8266ADS powerpc mpc8260 b3a2bbe1 2015-01-05 Rune Torgersen <[email protected]> +VoVPN-GW powerpc mpc8260 cc90905f 2015-01-05 +ep8260 powerpc mpc8260 4ad015ba 2015-01-05 Frank Panno <[email protected]> +ppmc8260 powerpc mpc8260 793116d2 2015-01-05 Brad Kemp <[email protected]> +sacsng powerpc mpc8260 b35c0ad6 2015-01-05 Jerry Van Baren <[email protected]> +cogent_mpc8260 powerpc mpc8260 d19f6a60 2015-01-05 Murray Jensen <[email protected]> +cogent_8xx powerpc mpc8xx d19f6a60 2015-01-05 Murray Jensen <[email protected]> +ESTEEM192E powerpc mpc8xx af0e3514 2015-01-05 Conn Clark <[email protected]> +IP860 powerpc mpc8xx 5ec71100 2015-01-05 Wolfgang Denk <[email protected]> +IVML24 powerpc mpc8xx ca620cd1 2015-01-05 Wolfgang Denk <[email protected]> +IVMS8 powerpc mpc8xx ca620cd1 2015-01-05 Wolfgang Denk <[email protected]> +lwmon powerpc mpc8xx acc2372d 2015-01-05 Wolfgang Denk <[email protected]> +NETVIA powerpc mpc8xx f017cd7f 2015-01-05 Pantelis Antoniou <[email protected]> +R360MPI powerpc mpc8xx 79cbecb8 2015-01-05 Wolfgang Denk <[email protected]> +RRvision powerpc mpc8xx 8737fc75 2015-01-05 Wolfgang Denk <[email protected]> +SPD823TS powerpc mpc8xx 72ba368f 2015-01-05 Wolfgang Denk <[email protected]> +KUP4K powerpc mpc8xx 4317d070 2015-01-05 Klaus Heydeck <[email protected]> +KUP4X powerpc mpc8xx 4317d070 2015-01-05 Klaus Heydeck <[email protected]> +ELPT860 powerpc mpc8xx 3c5b20f1 2015-01-05 The LEOX team <[email protected]> +hmi1001 powerpc mpc5xxx ceaf499b 2015-01-05 +mucmc52 powerpc mpc5xxx ceaf499b 2015-01-05 Heiko Schocher <[email protected]> +uc101 powerpc mpc5xxx ceaf499b 2015-01-05 Heiko Schocher <[email protected]> +uc100 powerpc mpc8xx ceaf499b 2015-01-05 Stefan Roese <[email protected]> +FPS850L powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk <[email protected]> +FPS860L powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk <[email protected]> +NSCU powerpc mpc8xx 5d2a5ef7 2015-01-05 +SM850 powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk <[email protected]> +TK885D powerpc mpc8xx 5d2a5ef7 2015-01-05 +virtlab2 powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk <[email protected]> hermes powerpc mpc8xx 36da51e 2014-12-08 Wolfgang Denk <[email protected]> PRS200 powerpc mpc5200 ecfdcee 2014-11-12 MCC200 powerpc mpc5200 ecfdcee 2014-11-12
Signature · 1 line
1.9.1
cover Fill blank fields of doc/README.scrapyard with a tool
In reply to Masahiro YamadaQuoted 3 lines · Masahiro Yamada
Masahiro Yamada (2):
scripts: add a utility to fill blank fields of doc/README.scrapyard README.scrapyard: fill commit and date fields
Yay, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150113/d2b24023/attachment.pgp>