aboutsummaryrefslogtreecommitdiff
path: root/scripts/maint
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/maint')
-rwxr-xr-xscripts/maint/check_config_macros.pl20
-rwxr-xr-xscripts/maint/format_changelog.py29
-rwxr-xr-xscripts/maint/sortChanges.py49
3 files changed, 92 insertions, 6 deletions
diff --git a/scripts/maint/check_config_macros.pl b/scripts/maint/check_config_macros.pl
new file mode 100755
index 000000000..bcde2becc
--- /dev/null
+++ b/scripts/maint/check_config_macros.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my @macros = ();
+
+open(F, 'orconfig.h.in');
+while(<F>) {
+ if (/^#undef +([A-Za-z0-9_]*)/) {
+ push @macros, $1;
+ }
+}
+close F;
+
+for my $m (@macros) {
+ my $s = `git grep '$m' src`;
+ if ($s eq '') {
+ print "Unused: $m\n";
+ }
+}
diff --git a/scripts/maint/format_changelog.py b/scripts/maint/format_changelog.py
index 35044b318..f67e89b60 100755
--- a/scripts/maint/format_changelog.py
+++ b/scripts/maint/format_changelog.py
@@ -23,6 +23,8 @@ import sys
# 100 * the fourth power of overflowed characters
# PLUS
# .1 * a bit more than the cube of ragged space on the last line.
+# PLUS
+# OPENPAREN_PENALTY for each line that starts with (
#
# We use an obvious dynamic programming algorithm to sorta approximate this.
# It's not coded right or optimally, but it's fast enough for changelogs
@@ -44,6 +46,8 @@ OVERFLOW_PENALTY = 2000
ORPHAN_PENALTY = 10000
+OPENPAREN_PENALTY = 200
+
def generate_wrapping(words, divisions):
lines = []
last = 0
@@ -65,6 +69,9 @@ def wrapping_quality(words, divisions, width1, width2):
else:
width = width2
+ if line[0:1] == '(':
+ total += OPENPAREN_PENALTY
+
if length > width:
total += OVERFLOW_PENALTY * (
(length - width) ** OVERFLOW_EXPONENT )
@@ -109,7 +116,7 @@ def wrap_graf(words, prefix_len1=0, prefix_len2=0, width=72):
return lines
def hyphenateable(word):
- if re.match(r'^[^\d\-].*-', word):
+ if re.match(r'^[^\d\-]\D*-', word):
stripped = re.sub(r'^\W+','',word)
stripped = re.sub(r'\W+$','',word)
return stripped not in NO_HYPHENATE
@@ -211,7 +218,7 @@ class ChangeLog(object):
elif tp == TP_ITEMBODY:
if self.curgraf is None:
self.curgraf = []
- self.cursection[2][1][-1].append(self.curgraf)
+ self.cursection[2][-1][1].append(self.curgraf)
self.curgraf.append(line)
else:
@@ -263,7 +270,16 @@ class ChangeLog(object):
CL = ChangeLog()
parser = head_parser
-sys.stdin = open('ChangeLog', 'r')
+if len(sys.argv) == 1:
+ fname = 'ChangeLog'
+else:
+ fname = sys.argv[1]
+
+fname_new = fname+".new"
+
+sys.stdin = open(fname, 'r')
+
+nextline = None
for line in sys.stdin:
line = line.rstrip()
@@ -279,13 +295,14 @@ for line in sys.stdin:
CL.lint()
-sys.stdout = open('ChangeLog.new', 'w')
+sys.stdout = open(fname_new, 'w')
CL.dump()
-print nextline
+if nextline is not None:
+ print nextline
for line in sys.stdin:
sys.stdout.write(line)
-os.rename('ChangeLog.new', 'ChangeLog')
+os.rename(fname_new, fname)
diff --git a/scripts/maint/sortChanges.py b/scripts/maint/sortChanges.py
new file mode 100755
index 000000000..726a723f9
--- /dev/null
+++ b/scripts/maint/sortChanges.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# Copyright (c) 2014, The Tor Project, Inc.
+# See LICENSE for licensing information
+
+"""This script sorts a bunch of changes files listed on its command
+ line into roughly the order in which they should appear in the
+ changelog.
+
+ TODO: collation support.
+"""
+
+import re
+import sys
+
+def fetch(fn):
+ with open(fn) as f:
+ s = f.read()
+ s = "%s\n" % s.rstrip()
+ return s
+
+def score(s):
+ m = re.match(r'^ +o (.*)', s)
+ if not m:
+ print >>sys.stderr, "Can't score %r"%s
+ lw = m.group(1).lower()
+ if lw.startswith("major feature"):
+ score = 0
+ elif lw.startswith("major bug"):
+ score = 1
+ elif lw.startswith("major"):
+ score = 2
+ elif lw.startswith("minor feature"):
+ score = 10
+ elif lw.startswith("minor bug"):
+ score = 11
+ elif lw.startswith("minor"):
+ score = 12
+ else:
+ score = 100
+
+ return (score, lw, s)
+
+
+changes = [ score(fetch(fn)) for fn in sys.argv[1:] if not fn.endswith('~') ]
+
+changes.sort()
+
+for _, _, s in changes:
+ print s