Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svn status can now include changelists' items #133

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 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

import svn.common_base
import svn.constants
import svn.exception
import svn.common_base

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -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 _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
4 changes: 3 additions & 1 deletion svn/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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 +77,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 Down