From b8438b499ed3a9fe9b1270983d0f32afdd00cd97 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Feb 2024 20:16:05 +0100 Subject: [PATCH 1/5] VCS: deprecation dates at application level Follow the dates published in our blog: https://about.readthedocs.com/blog/2024/02/drop-support-for-subversion-mercurial-bazaar/ Closes #8840 --- readthedocs/doc_builder/exceptions.py | 1 + readthedocs/notifications/messages.py | 13 ++++++++ readthedocs/vcs_support/backends/bzr.py | 5 +-- readthedocs/vcs_support/backends/hg.py | 4 +-- readthedocs/vcs_support/backends/svn.py | 4 +-- readthedocs/vcs_support/base.py | 43 +++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 6 deletions(-) diff --git a/readthedocs/doc_builder/exceptions.py b/readthedocs/doc_builder/exceptions.py index 2ffa216bad4..abc7783522d 100644 --- a/readthedocs/doc_builder/exceptions.py +++ b/readthedocs/doc_builder/exceptions.py @@ -50,6 +50,7 @@ class BuildUserError(BuildBaseException): BUILD_COMMANDS_IN_BETA = "build:user:build-commands-config-key-in-beta" BUILD_TIME_OUT = "build:user:time-out" BUILD_EXCESSIVE_MEMORY = "build:user:excessive-memory" + VCS_DEPRECATED = "build:vcs:deprecated" class BuildMaxConcurrencyError(BuildUserError): diff --git a/readthedocs/notifications/messages.py b/readthedocs/notifications/messages.py index ed963a52831..f676048c7f6 100644 --- a/readthedocs/notifications/messages.py +++ b/readthedocs/notifications/messages.py @@ -188,6 +188,19 @@ def get_rendered_body(self): ), type=ERROR, ), + Message( + id=BuildUserError.VCS_DEPRECATED, + header=_("Build used a deprecated VCS that's not supported anymore: {{vcs}}."), + body=_( + textwrap.dedent( + """ + {{vcs}} VCS is not supported anymore. + Read more about this in our blog post Dropping support for Subversion, Mercurial, and Bazaar. + """ + ).strip(), + ), + type=ERROR, + ), Message( id=BuildAppError.BUILD_DOCKER_UNKNOWN_ERROR, header=_("Build terminated due to unknown error."), diff --git a/readthedocs/vcs_support/backends/bzr.py b/readthedocs/vcs_support/backends/bzr.py index a065ed1b870..f34afae88fc 100644 --- a/readthedocs/vcs_support/backends/bzr.py +++ b/readthedocs/vcs_support/backends/bzr.py @@ -3,13 +3,14 @@ import csv import re from io import StringIO + from django.conf import settings from readthedocs.projects.exceptions import RepositoryError -from readthedocs.vcs_support.base import BaseVCS, VCSVersion +from readthedocs.vcs_support.base import BaseVCS, Deprecated, VCSVersion -class Backend(BaseVCS): +class Backend(BaseVCS, Deprecated): """Bazaar VCS backend.""" diff --git a/readthedocs/vcs_support/backends/hg.py b/readthedocs/vcs_support/backends/hg.py index fda4a4b7e27..00082f0f90f 100644 --- a/readthedocs/vcs_support/backends/hg.py +++ b/readthedocs/vcs_support/backends/hg.py @@ -2,10 +2,10 @@ from django.conf import settings from readthedocs.projects.exceptions import RepositoryError -from readthedocs.vcs_support.base import BaseVCS, VCSVersion +from readthedocs.vcs_support.base import BaseVCS, Deprecated, VCSVersion -class Backend(BaseVCS): +class Backend(BaseVCS, Deprecated): """Mercurial VCS backend.""" diff --git a/readthedocs/vcs_support/backends/svn.py b/readthedocs/vcs_support/backends/svn.py index 83ed38c4757..34680ea4706 100644 --- a/readthedocs/vcs_support/backends/svn.py +++ b/readthedocs/vcs_support/backends/svn.py @@ -6,10 +6,10 @@ from django.conf import settings from readthedocs.projects.exceptions import RepositoryError -from readthedocs.vcs_support.base import BaseVCS, VCSVersion +from readthedocs.vcs_support.base import BaseVCS, Deprecated, VCSVersion -class Backend(BaseVCS): +class Backend(BaseVCS, Deprecated): """Subversion VCS backend.""" diff --git a/readthedocs/vcs_support/base.py b/readthedocs/vcs_support/base.py index 678224303c2..57638a04bb5 100644 --- a/readthedocs/vcs_support/base.py +++ b/readthedocs/vcs_support/base.py @@ -1,6 +1,8 @@ """Base classes for VCS backends.""" +import datetime import os +import pytz import structlog from readthedocs.core.utils.filesystem import safe_rmtree @@ -33,6 +35,47 @@ def __repr__(self): ) +class Deprecated: + def __init__(self, *args, **kwargs): + tzinfo = pytz.PDT + now = datetime.now(tz=tzinfo) + + # Brownout dates as published in https://about.readthedocs.com/blog/2024/02/drop-support-for-subversion-mercurial-bazaar/ + # fmt: off + disabled = any([ + # 12 hours browndate + datetime.datetime(2024, 4, 1, 0, 0, 0, tzinfo=tzinfo) < now < datetime.datetime(2024, 4, 1, 12, 0, 0, tzinfo=tzinfo), + # 24 hours browndate + datetime.datetime(2024, 5, 6, 0, 0, 0, tzinfo=tzinfo) < now < datetime.datetime(2024, 5, 7, 0, 0, 0, tzinfo=tzinfo), + # 48 hours browndate + datetime.datetime(2024, 5, 20, 0, 0, 0, tzinfo=tzinfo) < now < datetime.datetime(2024, 5, 22, 0, 0, 0, tzinfo=tzinfo), + # Deprecated after June 3 + datetime.datetime(2024, 6, 3, 0, 0, 0, tzinfo=tzinfo) < now, + ]) + # fmt: on + + if disabled: + import bzr + import hg + import svn + + vcs = None + if isinstance(self, bzr.Backend): + vcs = "Bazaar" + elif isinstance(self, svn.Backend): + vcs = "Subversion" + elif isinstance(self, hg.Backend): + vcs = "Mercurial" + + raise BuildUserError( + message_id=BuildUserError.VCS_DEPRECATED, + format_values={ + "vcs": vcs, + }, + ) + super().__init__(self, *args, *kwargs) + + class BaseVCS: """ From a586fd737928a80ed7d7cdf2188278c37f3462f0 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sun, 25 Feb 2024 20:38:31 +0100 Subject: [PATCH 2/5] Minor updates after doing more QA locally --- readthedocs/vcs_support/backends/bzr.py | 2 +- readthedocs/vcs_support/backends/hg.py | 2 +- readthedocs/vcs_support/backends/svn.py | 2 +- readthedocs/vcs_support/base.py | 8 +++----- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/readthedocs/vcs_support/backends/bzr.py b/readthedocs/vcs_support/backends/bzr.py index f34afae88fc..bbe63bd5422 100644 --- a/readthedocs/vcs_support/backends/bzr.py +++ b/readthedocs/vcs_support/backends/bzr.py @@ -10,7 +10,7 @@ from readthedocs.vcs_support.base import BaseVCS, Deprecated, VCSVersion -class Backend(BaseVCS, Deprecated): +class Backend(Deprecated, BaseVCS): """Bazaar VCS backend.""" diff --git a/readthedocs/vcs_support/backends/hg.py b/readthedocs/vcs_support/backends/hg.py index 00082f0f90f..6bf2e9cfc74 100644 --- a/readthedocs/vcs_support/backends/hg.py +++ b/readthedocs/vcs_support/backends/hg.py @@ -5,7 +5,7 @@ from readthedocs.vcs_support.base import BaseVCS, Deprecated, VCSVersion -class Backend(BaseVCS, Deprecated): +class Backend(Deprecated, BaseVCS): """Mercurial VCS backend.""" diff --git a/readthedocs/vcs_support/backends/svn.py b/readthedocs/vcs_support/backends/svn.py index 34680ea4706..dc220610e8d 100644 --- a/readthedocs/vcs_support/backends/svn.py +++ b/readthedocs/vcs_support/backends/svn.py @@ -9,7 +9,7 @@ from readthedocs.vcs_support.base import BaseVCS, Deprecated, VCSVersion -class Backend(BaseVCS, Deprecated): +class Backend(Deprecated, BaseVCS): """Subversion VCS backend.""" diff --git a/readthedocs/vcs_support/base.py b/readthedocs/vcs_support/base.py index 57638a04bb5..4293fa29588 100644 --- a/readthedocs/vcs_support/base.py +++ b/readthedocs/vcs_support/base.py @@ -37,8 +37,8 @@ def __repr__(self): class Deprecated: def __init__(self, *args, **kwargs): - tzinfo = pytz.PDT - now = datetime.now(tz=tzinfo) + tzinfo = pytz.timezone("America/Los_Angeles") + now = datetime.datetime.now(tz=tzinfo) # Brownout dates as published in https://about.readthedocs.com/blog/2024/02/drop-support-for-subversion-mercurial-bazaar/ # fmt: off @@ -55,9 +55,7 @@ def __init__(self, *args, **kwargs): # fmt: on if disabled: - import bzr - import hg - import svn + from .backends import bzr, hg, svn vcs = None if isinstance(self, bzr.Backend): From 05c13052c982c4c7c18b807d2231737caa2523ae Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 27 Feb 2024 10:05:05 +0100 Subject: [PATCH 3/5] Update readthedocs/notifications/messages.py Co-authored-by: Eric Holscher <25510+ericholscher@users.noreply.github.com> --- readthedocs/notifications/messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/notifications/messages.py b/readthedocs/notifications/messages.py index f676048c7f6..b359fb15b59 100644 --- a/readthedocs/notifications/messages.py +++ b/readthedocs/notifications/messages.py @@ -190,7 +190,7 @@ def get_rendered_body(self): ), Message( id=BuildUserError.VCS_DEPRECATED, - header=_("Build used a deprecated VCS that's not supported anymore: {{vcs}}."), + header=_("Build used a deprecated VCS is not supported: {{vcs}}."), body=_( textwrap.dedent( """ From 00e947269b440d75cc5667018bb05bf1774a6bc2 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 27 Feb 2024 10:06:05 +0100 Subject: [PATCH 4/5] Typo --- readthedocs/vcs_support/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/vcs_support/base.py b/readthedocs/vcs_support/base.py index 4293fa29588..902e26f34ba 100644 --- a/readthedocs/vcs_support/base.py +++ b/readthedocs/vcs_support/base.py @@ -71,7 +71,7 @@ def __init__(self, *args, **kwargs): "vcs": vcs, }, ) - super().__init__(self, *args, *kwargs) + super().__init__(self, *args, **kwargs) class BaseVCS: From a871fdd02397313afe7d80e4810d3b07decf907d Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 27 Feb 2024 11:09:51 +0100 Subject: [PATCH 5/5] Call `super()` properly --- readthedocs/vcs_support/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readthedocs/vcs_support/base.py b/readthedocs/vcs_support/base.py index 902e26f34ba..5d79a9e7ca4 100644 --- a/readthedocs/vcs_support/base.py +++ b/readthedocs/vcs_support/base.py @@ -71,7 +71,8 @@ def __init__(self, *args, **kwargs): "vcs": vcs, }, ) - super().__init__(self, *args, **kwargs) + + super().__init__(*args, **kwargs) class BaseVCS: