Author: danielsh
Date: Fri Aug  2 17:53:38 2019
New Revision: 1864256

URL: http://svn.apache.org/viewvc?rev=1864256&view=rev
Log:
site: upcoming.py: When cwd is not a stable branch working copy root, show
changes of the newest branch.

Fixes SVN-4823.

* site/tools/upcoming.py
  (__doc__): Expand.
  (get_reference_version__from_working_copy): Add TODO.
  (get_reference_version__latest_stable_release): New.
  (get_reference_version): New.
  (main): Update caller.

Modified:
    subversion/site/tools/upcoming.py

Modified: subversion/site/tools/upcoming.py
URL: 
http://svn.apache.org/viewvc/subversion/site/tools/upcoming.py?rev=1864256&r1=1864255&r2=1864256&view=diff
==============================================================================
--- subversion/site/tools/upcoming.py (original)
+++ subversion/site/tools/upcoming.py Fri Aug  2 17:53:38 2019
@@ -1,10 +1,12 @@
 #! /usr/bin/env python3
 
 """
-WIP - INCOMPLETE
+Generate 'svn log' output since the last tag to HEAD of a stable branch,
+filtering all but merge commits.
 
-Generate 'svn log' output since the last tag to HEAD of the release branch
-checked out in the current working directory, filtering all but merge commits.
+If the current working directory is the root of a stable branch (e.g.,
+`svn info --show-item=relative=url` == '^/subversion/branches/1.12.x'),
+show changes to that branch; else, show changes to the newest branch.
 """
 
 import collections
@@ -44,10 +46,33 @@ def get_reference_version__from_working_
     # - on dist;
     # - within the specified minor line;
     # - older than the working copy.
+    #
+    # TODO: This will throw ValueError (max() of an empty sequence) if working 
copy
+    #       is older than the oldest patch version still on dist/.
     reference_version = max(v for v in versions_on_dist_release()
                             if v[:2] == version_broken_down[:2] and v < 
version_broken_down)
     return reference_version
 
+def get_reference_version__latest_stable_release():
+    "Return the version number of the latest stable release."
+    # Get the available GA releases.
+    versions = set(versions_on_dist_release())
+    # Normally dist/ would have only one version for each minor line.  If there
+    # are two patch versions, we err on the side of showing too much rather
+    # than too little.  (The newer patch version might not have been announced
+    # yet.)
+    oldest_patch_version_within_newest_minor_line = min(v for v in versions if 
v[:2] == max(versions)[:2])
+    return oldest_patch_version_within_newest_minor_line
+
+def get_reference_version():
+    "Return the version to use as the oldest end of the 'svn log' output to 
generate."
+    def _is_working_copy():
+        return os.path.exists('subversion/include/svn_version.h')
+    if _is_working_copy():
+        return get_reference_version__from_working_copy()
+    else:
+        return get_reference_version__latest_stable_release()
+
 def copyfrom_revision_of_previous_tag_of_this_stable_branch(reference_version):
     """Returns the copyfrom revision of the REFERENCE_VERSION tag."""
     assert isinstance(reference_version, Version)
@@ -77,7 +102,7 @@ def get_merges_for_range(start, end, tar
             yield logentry
 
 def main():
-    reference_version = get_reference_version__from_working_copy()
+    reference_version = get_reference_version()
     start_revision = 
copyfrom_revision_of_previous_tag_of_this_stable_branch(reference_version) + 1
     target = 
'^/subversion/branches/{major}.{minor}.x'.format(**reference_version._asdict())
     print("Changes in " + target + ":")


Reply via email to