subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1850261 - in /subversion/site/tools: escape.py upcoming.py
Date Thu, 03 Jan 2019 20:03:25 GMT
Author: danielsh
Date: Thu Jan  3 20:03:24 2019
New Revision: 1850261

URL: http://svn.apache.org/viewvc?rev=1850261&view=rev
Log:
* tools/escape.py,
* tools/upcoming.py: New scripts, to be used in generating 'svn log' filtered
    to show merges only.  See dev@ thread:
    .
        https://svn.haxx.se/dev/archive-2019-01/0010.shtml
        Subject: Display outstanding backported fixes for each release?

Added:
    subversion/site/tools/escape.py   (with props)
    subversion/site/tools/upcoming.py   (with props)

Added: subversion/site/tools/escape.py
URL: http://svn.apache.org/viewvc/subversion/site/tools/escape.py?rev=1850261&view=auto
==============================================================================
--- subversion/site/tools/escape.py (added)
+++ subversion/site/tools/escape.py Thu Jan  3 20:03:24 2019
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+"""HTML-escape and linkify"""
+
+import fileinput
+import html
+import re
+
+revision_numbers = re.compile(r'r(\d+)')
+issue_references = re.compile(r'((?:SVN-|issue [#]?)(\d+))')
+
+for line in fileinput.input():
+    line = html.escape(line)
+    line = revision_numbers.sub(r'<a href="https://svn.apache.org/r\1">r\1</a>',
line)
+    line = issue_references.sub(r'<a href="/issue-\2">\1</a>', line)
+    print(line, end='')

Propchange: subversion/site/tools/escape.py
------------------------------------------------------------------------------
    svn:executable = *

Added: subversion/site/tools/upcoming.py
URL: http://svn.apache.org/viewvc/subversion/site/tools/upcoming.py?rev=1850261&view=auto
==============================================================================
--- subversion/site/tools/upcoming.py (added)
+++ subversion/site/tools/upcoming.py Thu Jan  3 20:03:24 2019
@@ -0,0 +1,64 @@
+#! /usr/bin/env python3
+
+"""
+WIP - INCOMPLETE
+
+Generate 'svn log' output since the last tag to HEAD of the release branch,
+filtering all but merge commits.
+"""
+
+import datetime
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+import xml.etree.ElementTree as ET
+
+SINCE = '1.11.0'
+SVN = os.getenv('SVN', 'svn')
+LOG_SEPARATOR_LINE = ('-' * 72) + '\n'
+
+def get_copyfrom_revision_of_tag(version_number):
+    """Given a version number, return the copyfrom revision of that release's tag."""
+    assert version_number == SINCE
+    # TODO: parse and return `svn log -r0:HEAD --limit=1 --stop-on-copy ^/subversion/tags/1.11.0
-vq`
+    return 1845131
+
+def get_merges_for_range(start, end):
+    """Return an array of revision numbers in the range -r START:END that are
+    merges.  START must be an integer; END need not be."""
+
+    cache = []
+    revisions = \
+        subprocess.check_output(
+            [SVN, 'log', '--xml', '-v', '-r', str(start) + ":" + str(end)],
+        ).decode()
+    log_xml = ET.fromstring(revisions)
+
+    relative_url = subprocess.check_output([SVN, 'info', '--show-item', 'relative-url']).decode().rstrip('\n')
+
+    for logentry in log_xml.findall('./logentry'):
+        is_merge = relative_url[1:] in (path.text for path in logentry.findall('.//path'))
+        if is_merge:
+            yield logentry
+
+def main():
+    for logentry in get_merges_for_range(get_copyfrom_revision_of_tag(SINCE) + 1, "HEAD")
:
+        f = lambda s: logentry.findall('./' + s)[0].text
+        f.__doc__ = """Get the contents of the first child tag whose name is given as an
argument."""
+        print(LOG_SEPARATOR_LINE, end='')
+        print("r%(revision)s | %(author)s | %(date)s | %(linecount)s lines" % dict(
+            revision  = logentry.attrib['revision'],
+            author    = f('author'),
+            date      = datetime.datetime.strptime(f('date'), '%Y-%m-%dT%H:%M:%S.%fZ').strftime('%Y-%m-%d
%H:%M:%S +0000 (%a, %d %b %Y)'),
+            linecount = 1+len(f('msg').splitlines()), # increment because of the empty line
printed next
+        ))
+        print()
+        print(f('msg'))
+
+    print(LOG_SEPARATOR_LINE)
+
+if __name__ == '__main__':
+    main()

Propchange: subversion/site/tools/upcoming.py
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message