blob: e9c859946bd6cb88a081af7a2e413adafc4f3a41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# vim: set filencoding=utf8
"""
Subversion Info
@author: Mike Crute (mcrute@gmail.com)
@organization: SoftGroup Interactive, Inc.
@date: April 20, 2010
"""
from xml.dom import pulldom
from obalie.utils import join_url
from obalie.commands import BaseCommand
class RepositoryInfo(object):
def __init__(self, path=None, root=None, uuid=None, revision=None):
self.path = path
self.root = root
self.uuid = uuid
self.revision = revision
@property
def relative_path(self):
return self.path[len(self.root):]
class InfoCommand(BaseCommand):
def __call__(self, path='/'):
path = join_url(self.client.repo_url, path)
self.logger.info('Running info for path: %s', path)
repo_info = RepositoryInfo()
xml = self.client.get_xml_output('info', path)
for event, node in xml:
if event != pulldom.START_ELEMENT:
continue
if node.tagName in ('url', 'root', 'uuid'):
xml.expandNode(node)
if node.tagName == 'url':
repo_info.path = node.firstChild.data
elif node.tagName == 'root':
repo_info.root = node.firstChild.data
elif node.tagName == 'uuid':
repo_info.uuid = node.firstChild.data
return repo_info
|