|
1 | 1 | """Base classes for VCS backends."""
|
| 2 | +import datetime |
2 | 3 | import os
|
3 | 4 |
|
| 5 | +import pytz |
4 | 6 | import structlog
|
5 | 7 |
|
6 | 8 | from readthedocs.core.utils.filesystem import safe_rmtree
|
@@ -33,6 +35,46 @@ def __repr__(self):
|
33 | 35 | )
|
34 | 36 |
|
35 | 37 |
|
| 38 | +class Deprecated: |
| 39 | + def __init__(self, *args, **kwargs): |
| 40 | + tzinfo = pytz.timezone("America/Los_Angeles") |
| 41 | + now = datetime.datetime.now(tz=tzinfo) |
| 42 | + |
| 43 | + # Brownout dates as published in https://about.readthedocs.com/blog/2024/02/drop-support-for-subversion-mercurial-bazaar/ |
| 44 | + # fmt: off |
| 45 | + disabled = any([ |
| 46 | + # 12 hours browndate |
| 47 | + datetime.datetime(2024, 4, 1, 0, 0, 0, tzinfo=tzinfo) < now < datetime.datetime(2024, 4, 1, 12, 0, 0, tzinfo=tzinfo), |
| 48 | + # 24 hours browndate |
| 49 | + datetime.datetime(2024, 5, 6, 0, 0, 0, tzinfo=tzinfo) < now < datetime.datetime(2024, 5, 7, 0, 0, 0, tzinfo=tzinfo), |
| 50 | + # 48 hours browndate |
| 51 | + datetime.datetime(2024, 5, 20, 0, 0, 0, tzinfo=tzinfo) < now < datetime.datetime(2024, 5, 22, 0, 0, 0, tzinfo=tzinfo), |
| 52 | + # Deprecated after June 3 |
| 53 | + datetime.datetime(2024, 6, 3, 0, 0, 0, tzinfo=tzinfo) < now, |
| 54 | + ]) |
| 55 | + # fmt: on |
| 56 | + |
| 57 | + if disabled: |
| 58 | + from .backends import bzr, hg, svn |
| 59 | + |
| 60 | + vcs = None |
| 61 | + if isinstance(self, bzr.Backend): |
| 62 | + vcs = "Bazaar" |
| 63 | + elif isinstance(self, svn.Backend): |
| 64 | + vcs = "Subversion" |
| 65 | + elif isinstance(self, hg.Backend): |
| 66 | + vcs = "Mercurial" |
| 67 | + |
| 68 | + raise BuildUserError( |
| 69 | + message_id=BuildUserError.VCS_DEPRECATED, |
| 70 | + format_values={ |
| 71 | + "vcs": vcs, |
| 72 | + }, |
| 73 | + ) |
| 74 | + |
| 75 | + super().__init__(*args, **kwargs) |
| 76 | + |
| 77 | + |
36 | 78 | class BaseVCS:
|
37 | 79 |
|
38 | 80 | """
|
|
0 commit comments