Skip to content

Commit

Permalink
ENH: Simplify SlicerWizard module removing obsolete "svn" support
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Mar 19, 2024
1 parent 881809c commit 2479862
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 285 deletions.
1 change: 0 additions & 1 deletion Utilities/Scripts/SlicerWizard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ set(SlicerWizard_PYTHON_SCRIPTS
ExtensionProject.py
ExtensionWizard.py
GithubHelper.py
Subversion.py
TemplateManager.py
Utilities.py
WizardHelpFormatter.py
Expand Down
49 changes: 6 additions & 43 deletions Utilities/Scripts/SlicerWizard/ExtensionDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self, repo=None, filepath=None, sourcedir=None, cmakefile="CMakeLis
Extension repository from which to create the description.
:type repo:
:class:`git.Repo <git:git.repo.base.Repo>`,
:class:`.Subversion.Repository` or ``None``.
:param filepath:
Path to an existing ``.s4ext`` to read.
:type filepath:
Expand Down Expand Up @@ -71,7 +70,6 @@ def __init__(self, repo=None, filepath=None, sourcedir=None, cmakefile="CMakeLis
# Handle git repositories
if hasattr(repo, "remotes"):
remote = None
svnRemote = None

# Get SHA of HEAD (may not exist if no commit has been made yet!)
try:
Expand All @@ -88,28 +86,14 @@ def __init__(self, repo=None, filepath=None, sourcedir=None, cmakefile="CMakeLis
remote = repo.remotes[0]

if remote is None:
# Try to get svn remote
config = repo.config_reader()
for s in config.sections():
if s.startswith("svn-remote"):
svnRemote = s[12:-1]
break

if svnRemote is None:
# Do we have any remotes?
if len(repo.remotes) == 0:
setattr(self, "scm", "git")
setattr(self, "scmurl", "NA")
setattr(self, "scmrevision", sha)

else:
raise Exception("unable to determine repository's primary remote")
# Do we have any remotes?
if len(repo.remotes) == 0:
setattr(self, "scm", "git")
setattr(self, "scmurl", "NA")
setattr(self, "scmrevision", sha)

else:
si = self._gitSvnInfo(repo, svnRemote)
setattr(self, "scm", "svn")
setattr(self, "scmurl", si["URL"])
setattr(self, "scmrevision", si["Revision"])
raise Exception("unable to determine repository's primary remote")

else:
setattr(self, "scm", "git")
Expand All @@ -118,13 +102,6 @@ def __init__(self, repo=None, filepath=None, sourcedir=None, cmakefile="CMakeLis

sourcedir = repo.working_tree_dir

# Handle svn repositories
elif hasattr(repo, "wc_root"):
setattr(self, "scm", "svn")
setattr(self, "scmurl", repo.url)
setattr(self, "scmrevision", repo.last_change_revision)
sourcedir = repo.wc_root

# Handle local source directory
elif hasattr(repo, "relative_directory"):
setattr(self, "scm", "local")
Expand Down Expand Up @@ -152,10 +129,6 @@ def __init__(self, repo=None, filepath=None, sourcedir=None, cmakefile="CMakeLis
self._setProjectAttribute("iconurl", p)
self._setProjectAttribute("screenshoturls", p)

if self.scm == "svn":
self._setProjectAttribute("svnusername", p, elideempty=True)
self._setProjectAttribute("svnpassword", p, elideempty=True)

# ---------------------------------------------------------------------------
def __repr__(self):
return repr(self.__dict__)
Expand All @@ -169,16 +142,6 @@ def _remotePublicUrl(remote):

return url

# ---------------------------------------------------------------------------
@staticmethod
def _gitSvnInfo(repo, remote):
result = {}
for line in repo.git.svn("info", R=remote).split("\n"):
if len(line):
key, value = line.split(":", 1)
result[key] = value.strip()
return result

# ---------------------------------------------------------------------------
def _setProjectAttribute(self, name, project, default=None, required=False,
elideempty=False, substitute=True):
Expand Down
1 change: 0 additions & 1 deletion Utilities/Scripts/SlicerWizard/ExtensionWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def haveGit():

from . import __version__, __version_info__

from .ExtensionDescription import ExtensionDescription
from .ExtensionProject import ExtensionProject
from .TemplateManager import TemplateManager
from .Utilities import *
Expand Down
208 changes: 0 additions & 208 deletions Utilities/Scripts/SlicerWizard/Subversion.py

This file was deleted.

25 changes: 4 additions & 21 deletions Utilities/Scripts/SlicerWizard/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ def getRepo(path, tool=None, create=False):
:returns:
The repository instance, or ``None`` if no such repository exists.
:rtype:
:class:`git.Repo <git:git.repo.base.Repo>`, :class:`.Subversion.Repository`,
or ``None``.
:class:`git.Repo <git:git.repo.base.Repo>` or ``None``.
This attempts to obtain a repository for the specified ``path``. If ``tool``
is not ``None``, this will only look for a repository that is managed by the
Expand All @@ -415,8 +414,6 @@ def getRepo(path, tool=None, create=False):
.. seealso:: :func:`.createEmptyRepo`
"""

from . import Subversion

# Try to obtain git repository
if haveGit() and tool in (None, "git"):
try:
Expand All @@ -428,15 +425,6 @@ def getRepo(path, tool=None, create=False):
except:
logging.debug("%r is not a git repository" % path)

# Try to obtain subversion repository
if tool in (None, "svn"):
try:
repo = Subversion.Repository(path)
return repo

except:
logging.debug("%r is not a svn repository" % path)

# Specified path is not a supported / allowed repository; create a repository
# if requested, otherwise return None
if create:
Expand Down Expand Up @@ -510,8 +498,7 @@ def localRoot(repo):
:param repo:
Repository instance.
:type repo:
:class:`git.Repo <git:git.repo.base.Repo>` or
:class:`.Subversion.Repository`.
:class:`git.Repo <git:git.repo.base.Repo>`.
:return: Absolute path to the repository local root.
:rtype: :class:`str`
Expand All @@ -538,8 +525,7 @@ def vcsPrivateDirectory(repo):
:param repo:
Repository instance.
:type repo:
:class:`git.Repo <git:git.repo.base.Repo>` or
:class:`.Subversion.Repository`.
:class:`git.Repo <git:git.repo.base.Repo>`
:return: Absolute path to the |VCS| private directory.
:rtype: :class:`str`
Expand All @@ -548,13 +534,10 @@ def vcsPrivateDirectory(repo):
:exc:`~exceptions.Exception` if the private directory cannot be determined.
This returns the |VCS| private directory for a repository, e.g. the ``.git``
or ``.svn`` directory.
directory.
"""

if hasattr(repo, "git_dir"):
return repo.git_dir

if hasattr(repo, "svn_dir"):
return repo.svn_dir

raise Exception("unable to determine repository local private directory")
3 changes: 0 additions & 3 deletions Utilities/Scripts/SlicerWizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* :mod:`.GithubHelper`:
Helpers for interacting with github.
* :mod:`.Subversion`:
Python API for simple interaction with Subversion.
* :class:`.TemplateManager`:
Template collection manager.
Expand Down

0 comments on commit 2479862

Please sign in to comment.