Author: dsahlberg
Date: Wed Jul 15 09:20:54 2026
New Revision: 1936159

Log:
In tools/dist: Make the backport scripts support both "Candidate changes"
and "Other candidate changes" headlines.

* backport/status.py
  (StatusFile.insert): Add optional parameter add_missing_section (default
                       True) and make function return False if existing
                       header is not found.
* nominate-backport.py
  (main): First try to add the entry to "Other candidate changes" (without
          adding this header) and if that fails to "Candidate changes"

Modified:
   subversion/trunk/tools/dist/backport/status.py
   subversion/trunk/tools/dist/nominate-backport.py

Modified: subversion/trunk/tools/dist/backport/status.py
==============================================================================
--- subversion/trunk/tools/dist/backport/status.py      Wed Jul 15 09:02:08 
2026        (r1936158)
+++ subversion/trunk/tools/dist/backport/status.py      Wed Jul 15 09:20:54 
2026        (r1936159)
@@ -236,7 +236,12 @@ class StatusFile:
         for para in entry_paras:
           para.kind = Kind.unknown
 
-  def insert(self, entry, containing_section):
+  def insert(self, entry, containing_section, add_missing_section = True):
+    """Insert a new entry under the containing_section header.
+    If add_missing_section is True, a new header will be added last if 
+    no existing header is found.
+    If add_missing_section is False and no headline containing_section is
+    found, entry will not be added and insert till return False."""
     p = Paragraph(Kind.nomination,
                   "",
                   entry,
@@ -251,10 +256,13 @@ class StatusFile:
           correct_header = True
         elif correct_header:
           self.paragraphs.insert(i, p)
-          return
+          return True
       i += 1
 
     if not correct_header:
+      if not add_missing_section:
+        return False
+      
       # None found so we need to append a new header followed by the new entry
       self.paragraphs.append(Paragraph(Kind.section_header,
                                        containing_section + ":\n" \
@@ -263,6 +271,7 @@ class StatusFile:
                                        containing_section)
                              )
     self.paragraphs.append(p)
+    return True
 
   def remove(self, entry):
     "Remove ENTRY from SELF."

Modified: subversion/trunk/tools/dist/nominate-backport.py
==============================================================================
--- subversion/trunk/tools/dist/nominate-backport.py    Wed Jul 15 09:02:08 
2026        (r1936158)
+++ subversion/trunk/tools/dist/nominate-backport.py    Wed Jul 15 09:20:54 
2026        (r1936159)
@@ -210,7 +210,8 @@ def main():
   e.justification_str = "\n" + textwrap.fill(justification, initial_indent='  
', subsequent_indent='  ') + "\n"
   e.votes_str = f"  +1: {AVAILID}\n"
   e.branch = branch
-  sf.insert(e, "Candidate changes")
+  if not sf.insert(e, "Other candidate changes", False):
+    sf.insert(e, "Candidate changes")
 
   # Write new STATUS file
   with open(STATUS, mode='w', encoding="UTF-8") as f:

Reply via email to