Skip to content

Commit

Permalink
VCS: deprecation dates at application level (#11147)
Browse files Browse the repository at this point in the history
* 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

* Minor updates after doing more QA locally

* Update readthedocs/notifications/messages.py

Co-authored-by: Eric Holscher <[email protected]>

* Typo

---------

Co-authored-by: Eric Holscher <[email protected]>
  • Loading branch information
humitos and ericholscher authored Feb 27, 2024
1 parent 98e33f4 commit 770867f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
1 change: 1 addition & 0 deletions readthedocs/doc_builder/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions readthedocs/notifications/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ def get_rendered_body(self):
),
type=ERROR,
),
Message(
id=BuildUserError.VCS_DEPRECATED,
header=_("Build used a deprecated VCS is not supported: {{vcs}}."),
body=_(
textwrap.dedent(
"""
{{vcs}} VCS is not supported anymore.
Read more about this in our blog post <a href="https://about.readthedocs.com/blog/2024/02/drop-support-for-subversion-mercurial-bazaar/">Dropping support for Subversion, Mercurial, and Bazaar</a>.
"""
).strip(),
),
type=ERROR,
),
Message(
id=BuildAppError.BUILD_DOCKER_UNKNOWN_ERROR,
header=_("Build terminated due to unknown error."),
Expand Down
5 changes: 3 additions & 2 deletions readthedocs/vcs_support/backends/bzr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(Deprecated, BaseVCS):

"""Bazaar VCS backend."""

Expand Down
4 changes: 2 additions & 2 deletions readthedocs/vcs_support/backends/hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(Deprecated, BaseVCS):

"""Mercurial VCS backend."""

Expand Down
4 changes: 2 additions & 2 deletions readthedocs/vcs_support/backends/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(Deprecated, BaseVCS):

"""Subversion VCS backend."""

Expand Down
42 changes: 42 additions & 0 deletions readthedocs/vcs_support/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -33,6 +35,46 @@ def __repr__(self):
)


class Deprecated:
def __init__(self, *args, **kwargs):
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
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:
from .backends import bzr, hg, 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__(*args, **kwargs)


class BaseVCS:

"""
Expand Down

0 comments on commit 770867f

Please sign in to comment.