Skip to content

Commit

Permalink
cleanup: remove svn_rev_info and getversion_svn functions from versio…
Browse files Browse the repository at this point in the history
…n module

SVN repository is no longer supported.

Bug: T378898
Change-Id: I8978bbb0f9a48e14624b38b0eeda2005b1f016c1
  • Loading branch information
xqt committed Dec 4, 2024
1 parent bb86530 commit 7081aac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 69 deletions.
4 changes: 2 additions & 2 deletions ROADMAP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Current Release Changes

**Breaking changes and code cleanups**

* ``svn_rev_info`` and ``getversion_svn`` of :mod:`version` module were be removed.
SVN repository is no longer supported. (:phab:`T362484`)
* Old color escape sequences like ``\03{color}`` were dropped in favour of new color format like ``<<color>>``
* ``tools.formatter.color_format()`` was removed; the new color literals can be used instead
* RedirectPageBot and NoRedirectPageBot bot classes were removed in favour of
Expand Down Expand Up @@ -85,8 +87,6 @@ Pending removal in Pywikibot 11
Pending removal in Pywikibot 10
-------------------------------

* 9.1.0: :func:`version.svn_rev_info` and :func:`version.getversion_svn` will be removed. SVN is no longer supported.
(:phab:`T362484`)
* 7.7.0: :mod:`tools.threading` classes should no longer imported from :mod:`tools`
* 7.6.0: :mod:`tools.itertools` datatypes should no longer imported from :mod:`tools`
* 7.6.0: :mod:`tools.collections` datatypes should no longer imported from :mod:`tools`
Expand Down
70 changes: 3 additions & 67 deletions pywikibot/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import os
import pathlib
import socket
import sqlite3
import subprocess
import sys
import sysconfig
import time
from contextlib import closing, suppress
from contextlib import suppress
from importlib import import_module
from pathlib import Path
from warnings import warn
Expand All @@ -26,8 +25,7 @@
from pywikibot.backports import cache
from pywikibot.comms.http import fetch
from pywikibot.exceptions import VersionParseError
from pywikibot.tools import deprecated, suppress_warnings
from pywikibot.tools._deprecate import _NotImplementedWarning
from pywikibot.tools import deprecated


def _get_program_dir() -> str:
Expand Down Expand Up @@ -91,14 +89,10 @@ def getversiondict() -> dict[str, str]:
exceptions = {}

for vcs_func in (getversion_git,
getversion_svn,
getversion_nightly,
getversion_package):
try:
with suppress_warnings(
f'.*({vcs_func.__name__}|svn_rev_info) is deprecated since '
'release 9.1.', _NotImplementedWarning):
tag, rev, date, hsh = vcs_func(_program_dir)
tag, rev, date, hsh = vcs_func(_program_dir)
except Exception as e:
exceptions[vcs_func] = vcs_func.__name__, e
else:
Expand Down Expand Up @@ -128,64 +122,6 @@ def getversiondict() -> dict[str, str]:
return {'tag': tag, 'rev': rev, 'date': datestring, 'hsh': hsh}


@deprecated(since='9.1')
def svn_rev_info(path):
"""Fetch information about the current revision of a Subversion checkout.
.. deprecated:: 9.1
update to git repository.
.. versionchanged:: 9.1
drop support for svn 1.6 and older.
:param path: directory of the Subversion checkout
:return:
- tag (name for the repository),
- rev (current Subversion revision identifier),
- date (date of current revision),
:rtype: ``tuple`` of two ``str`` and a ``time.struct_time``
"""
if not os.path.isdir(os.path.join(path, '.svn')):
path = os.path.join(path, '..')

with closing(
sqlite3.connect(os.path.join(path, '.svn/wc.db'))) as con:
cur = con.cursor()
cur.execute("""select
local_relpath, repos_path, revision, changed_date, checksum from nodes
order by revision desc, changed_date desc""")
_name, tag, rev, date, _checksum = cur.fetchone()
cur.execute('select root from repository')
tag, = cur.fetchone()

tag = os.path.split(tag)[1]
date = time.gmtime(date / 1_000_000)
return tag, rev, date


@deprecated(since='9.1')
def getversion_svn(path=None):
"""Get version info for a Subversion checkout.
.. deprecated:: 9.1
update to git repository.
:param path: directory of the Subversion checkout
:return:
- tag (name for the repository),
- rev (current Subversion revision identifier),
- date (date of current revision),
- hash '(unknown)'
:rtype: ``tuple`` of three ``str`` and a ``time.struct_time``
"""
_program_dir = path or _get_program_dir()
tag, rev, date = svn_rev_info(_program_dir)
rev = f's{rev}'

if (not date or not tag or not rev) and not path:
raise VersionParseError
return (tag, rev, date, '(unknown)')


def getversion_git(path=None):
"""Get version info for a Git clone.
Expand Down

0 comments on commit 7081aac

Please sign in to comment.