Skip to content
Open
33 changes: 33 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions publish.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

@echo off
set PYPI_REPO_NAME=artifactory_upload


choice /C YN /m "Did you change the version?"
if ["%errorlevel%"]==["2"] exit /b

echo Publishing
poetry publish --repository %PYPI_REPO_NAME% --build %*

echo -i https://artifactory.wgdp.io/artifactory/api/pypi/wotk-pypi-wotdevtool/simple/ --extra-index-url https://artifactory.wgdp.io/artifactory/api/pypi/wotd-pypi/simple/ --extra-index-url https://pypi.python.org/simple
echo if this fails - activate python 3.12 venv first
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tool.poetry]
name = "PySVN"
version = "1.19.21"
description = "The pythonic interface to Subversion. Fork."
authors = []
maintainers = ["Aleksei Rubashev <[email protected]>"]
packages = [
{ include = "svn" },
]

[tool.poetry.dependencies]
python = ">=2.7.18"
python-dateutil = ">=2.2"

[[tool.poetry.source]]
name = "artifactory_upload"
url = "https://artifactory.wgdp.io/artifactory/api/pypi/wotk-pypi-wotdevtool/simple"
priority = "primary"

[poetry.group.dev.dependencies]
poetry = "*" #
pytest = ">=4.6"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
48 changes: 43 additions & 5 deletions svn/common.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import collections
import logging
import os
import subprocess
import xml.etree.ElementTree

import dateutil.parser

from svn.common_base import CommonBase
import svn.constants
import svn.exception
import svn.common_base

_LOGGER = logging.getLogger(__name__)

Expand All @@ -19,7 +18,7 @@
_HUNK_HEADER_LINE_NUMBERS_PREFIX = '@@ '


class CommonClient(svn.common_base.CommonBase):
class CommonClient(CommonBase):
def __init__(self, url_or_path, type_, username=None, password=None,
svn_filepath='svn', trust_cert=None, env={}, *args, **kwargs):
super(CommonClient, self).__init__(*args, **kwargs)
Expand All @@ -37,10 +36,10 @@ def __init__(self, url_or_path, type_, username=None, password=None,
self.__type = type_

def run_command(self, subcommand, args, **kwargs):
cmd = [self.__svn_filepath, '--non-interactive']
cmd = [self.__svn_filepath]

if self.__trust_cert:
cmd += ['--trust-server-cert']
cmd += ['--trust-server-cert', '--non-interactive']

if self.__username is not None and self.__password is not None:
cmd += ['--username', self.__username]
Expand Down Expand Up @@ -285,6 +284,45 @@ def export(self, to_path, revision=None, force=False):

self.run_command('export', cmd)

def status(self, rel_path=None, include_changelists=False):
full_url_or_path = self.__url_or_path
if rel_path is not None:
full_url_or_path += '/' + rel_path

raw = self.run_command(
'status',
['--xml', full_url_or_path],
do_combine=True)

root = xml.etree.ElementTree.fromstring(raw)

list_ = root.findall('target/entry')
if include_changelists is True:
list_ += root.findall('changelist/entry')

for entry in list_:
entry_attr = entry.attrib
name = entry_attr['path']

wcstatus = entry.find('wc-status')
wcstatus_attr = wcstatus.attrib

change_type_raw = wcstatus_attr['item']
change_type = svn.constants.STATUS_TYPE_LOOKUP[change_type_raw]

# This will be absent if the file is "unversioned". It'll be "-1"
# if added but not committed.
revision = wcstatus_attr.get('revision')
if revision is not None:
revision = int(revision)

yield svn.constants._STATUS_ENTRY(
name=name,
type_raw_name=change_type_raw,
type=change_type,
revision=revision
)

def list(self, extended=False, rel_path=None):
full_url_or_path = self.__url_or_path
if rel_path is not None:
Expand Down
12 changes: 12 additions & 0 deletions svn/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
import collections

_STATUS_ENTRY = \
collections.namedtuple(
'_STATUS_ENTRY', [
'name',
'type_raw_name',
'type',
'revision',
])


# Kinds

K_DIR = 'dir'
Expand Down
23 changes: 8 additions & 15 deletions svn/local.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import os
import collections

import xml.etree

import svn.constants
import svn.common
from svn.common import CommonClient

_STATUS_ENTRY = \
collections.namedtuple(
'_STATUS_ENTRY', [
'name',
'type_raw_name',
'type',
'revision',
])


class LocalClient(svn.common.CommonClient):
def __init__(self, path_, *args, **kwargs):
if os.path.exists(path_) is False:
class LocalClient(CommonClient):
def __init__(self, path_, allow_nonexistent=True, *args, **kwargs):
if not allow_nonexistent and os.path.exists(path_) is False:
raise EnvironmentError("Path does not exist: %s" % path_)

super(LocalClient, self).__init__(
Expand Down Expand Up @@ -64,7 +55,7 @@ def cleanup(self):
[],
wd=self.path)

def status(self, rel_path=None):
def status(self, rel_path=None, include_changelists=False):
path = self.path
if rel_path is not None:
path += '/' + rel_path
Expand All @@ -77,6 +68,8 @@ def status(self, rel_path=None):
root = xml.etree.ElementTree.fromstring(raw)

list_ = root.findall('target/entry')
if include_changelists is True:
list_ += root.findall('changelist/entry')
for entry in list_:
entry_attr = entry.attrib
name = entry_attr['path']
Expand All @@ -93,7 +86,7 @@ def status(self, rel_path=None):
if revision is not None:
revision = int(revision)

yield _STATUS_ENTRY(
yield svn.constants._STATUS_ENTRY(
name=name,
type_raw_name=change_type_raw,
type=change_type,
Expand Down