MCPcopy Create free account
hub / github.com/apache/solr / MigrationRunner

Class MigrationRunner

dev-tools/scripts/changes2logchange.py:886–1007  ·  view source on GitHub ↗

Orchestrates the complete migration process.

Source from the content-addressed store, hash-verified

884
885
886class MigrationRunner:
887 """Orchestrates the complete migration process."""
888
889 def __init__(self, changes_file_path: str, output_base_dir: str, last_released_version: Optional[str] = None):
890 self.changes_file_path = changes_file_path
891 self.output_base_dir = Path(output_base_dir)
892 self.parser = ChangesParser(changes_file_path)
893
894 # Fetch release dates and latest version
895 self.version_dates, detected_latest = ReleaseDate.fetch_release_dates_and_latest()
896
897 # Use provided version or detected latest
898 self.last_released_version = last_released_version or detected_latest
899
900 if self.last_released_version:
901 print(f"Latest released version: {self.last_released_version}", file=sys.stderr)
902
903 self.stats = {
904 'versions_processed': 0,
905 'entries_migrated': 0,
906 'entries_skipped': 0,
907 'files_created': 0,
908 'release_dates_written': 0,
909 'unreleased_entries': 0,
910 }
911
912 def run(self):
913 """Execute the migration."""
914 print(f"Parsing CHANGES.txt from: {self.changes_file_path}")
915 self.parser.parse()
916
917 print(f"Found {len(self.parser.versions)} versions")
918
919 for version_section in self.parser.versions:
920 self._process_version(version_section)
921
922 self._print_summary()
923
924 def _process_version(self, version_section: VersionSection):
925 """Process all entries for a single version."""
926 from packaging import version as pkg_version
927
928 # Determine if this version should go to unreleased folder
929 is_unreleased = False
930 if self.last_released_version:
931 try:
932 current_ver = pkg_version.parse(version_section.version)
933 latest_ver = pkg_version.parse(self.last_released_version)
934 is_unreleased = current_ver > latest_ver
935 except Exception:
936 # If parsing fails, treat as unreleased (conservative approach)
937 is_unreleased = True
938
939 # Route to appropriate directory
940 if is_unreleased:
941 version_dir = self.output_base_dir / "unreleased"
942 print(f"\nProcessing version {version_section.version} (unreleased):")
943 self.stats['unreleased_entries'] += len(version_section.entries)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…