Skip to content

Commit d2593a8

Browse files
committed
fix: remap dead hg.python.org release-notes URLs to GitHub
Adds a corrected_release_notes_url property to the Release model that converts old Mercurial-hosted URLs (hg.python.org, now unreachable) to their equivalent paths on GitHub, so legacy release pages still have working changelog links. Closes #2865
1 parent 8bd3f44 commit d2593a8

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

apps/downloads/models.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ def get_absolute_url(self):
114114
return self.release_page.get_absolute_url()
115115
return reverse("download:download_release_detail", kwargs={"release_slug": self.slug})
116116

117+
@property
118+
def corrected_release_notes_url(self):
119+
"""Return the release notes URL, converting dead hg.python.org links to GitHub.
120+
121+
Old Mercurial-hosted URLs (hg.python.org) are no longer reachable.
122+
This property remaps them to their equivalent paths on GitHub so that
123+
the "Release notes" links on the downloads page still work for legacy
124+
releases (3.3.6 and earlier).
125+
126+
Example::
127+
128+
http://hg.python.org/cpython/file/v3.3.6/Misc/NEWS
129+
→ https://github.com/python/cpython/blob/v3.3.6/Misc/NEWS
130+
"""
131+
url = self.release_notes_url
132+
if not url:
133+
return url
134+
match = re.match(r"https?://hg\.python\.org/cpython/file/([^/]+)/(.+)", url)
135+
if match:
136+
tag, path = match.group(1), match.group(2)
137+
return f"https://github.com/python/cpython/blob/{tag}/{path}"
138+
return url
139+
117140
def download_file_for_os(self, os_slug):
118141
"""Given an OS slug return the appropriate download file."""
119142
try:
@@ -430,3 +453,4 @@ class Meta:
430453
violation_error_message="All file URLs must begin with 'https://www.python.org/'",
431454
),
432455
]
456+

0 commit comments

Comments
 (0)