"""Daira Hopwood's added C++ lines in zcash (src/*.cpp|h), own non-merge commits, at a fixed revision. Excludes third-party imports (src/pow/tromp/ = John Tromp's Equihash solver; src/tinyformat.h = Chris Foster's tinyformat), subtrees, mechanical commits (same BAD regex as added_lines.py, plus import/update/upgrade), copyright/licence lines, and data lines (hex test vectors, long string-literal tables).""" import subprocess, re, sys, collections repo='corpora3/zcash'; rev='558f686599586f55def3db86955d74d3be44605e'; out=sys.argv[1] auth='^Daira(-Emma| Emma)? Hopwood ' EXCL = re.compile(r'(^src/(leveldb|secp256k1|univalue|json|crypto/ctaes|minisketch|crc32c|test/data|qt/forms|snark|rust|crc32c)/|^src/pow/tromp/|^src/tinyformat\.h$|/moc_|\.pb\.|qrc_|/locale/|bitcoinstrings)') BAD = re.compile(r'\b(patch(es)? (from|by)|thanks|merge|move[sd]?|renam|crlf|whitespace|format|copyright|indent|revert|cherry|backport|license|import|update|upgrade|bump|tromp|tinyformat)\b', re.I) DATA = re.compile(r'("[0-9a-fA-F]{32,}"|0x[0-9a-fA-F]{2},\s*0x[0-9a-fA-F]{2},\s*0x|Copyright \(c\)|Distributed under the MIT|opensource\.org/licenses)') import re as _re def comment_consistent(t): # same scanner order as style_metrics.strip_comments_strings: every /* must close inside the hunk, # and no line outside a comment may start with '*' (orphan continuation of a comment opened in context) i=0; n=len(t); inblk=set() while i3 else ''); st['commits']+=1; st['commits_kept']+=ok; continue if line.startswith('+++ '): p=line[6:] if line.startswith('+++ b/') else '' fok= ok and bool(re.search(r'\.(cpp|h)$',p)) and p.startswith('src/') and not EXCL.search(p); continue if line.startswith('@@'): flush(buf); buf=[] continue if fok and line.startswith('+') and not line.startswith('+++'): if DATA.search(line): st['data_dropped']+=1; continue buf.append(line[1:]); yrs[yr]+=1 flush(buf) fh.close(); st['lines_written']=sum(1 for _ in open(out)); print(dict(st), dict(sorted(yrs.items())))