|
|
@ -14,7 +14,7 @@ import subprocess
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
import tempfile
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
from xml.etree import ElementTree
|
|
|
|
import xml.dom.minidom
|
|
|
|
|
|
|
|
|
|
|
|
import gclient_utils
|
|
|
|
import gclient_utils
|
|
|
|
import subprocess2
|
|
|
|
import subprocess2
|
|
|
@ -512,35 +512,38 @@ class SVN(object):
|
|
|
|
"""Returns a dictionary from the svn info output for the given file.
|
|
|
|
"""Returns a dictionary from the svn info output for the given file.
|
|
|
|
|
|
|
|
|
|
|
|
Throws an exception if svn info fails."""
|
|
|
|
Throws an exception if svn info fails."""
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
output = SVN.Capture(['info', '--xml', cwd])
|
|
|
|
output = SVN.Capture(['info', '--xml', cwd])
|
|
|
|
info = ElementTree.XML(output)
|
|
|
|
dom = gclient_utils.ParseXML(output)
|
|
|
|
if info is None:
|
|
|
|
result = {}
|
|
|
|
return result
|
|
|
|
if dom:
|
|
|
|
entry = info.find('entry')
|
|
|
|
GetNamedNodeText = gclient_utils.GetNamedNodeText
|
|
|
|
|
|
|
|
GetNodeNamedAttributeText = gclient_utils.GetNodeNamedAttributeText
|
|
|
|
# Use .text when the item is not optional.
|
|
|
|
def C(item, f):
|
|
|
|
result['Path'] = entry.attrib['path']
|
|
|
|
if item is not None:
|
|
|
|
result['Revision'] = int(entry.attrib['revision'])
|
|
|
|
return f(item)
|
|
|
|
result['Node Kind'] = entry.attrib['kind']
|
|
|
|
# /info/entry/
|
|
|
|
|
|
|
|
# url
|
|
|
|
|
|
|
|
# reposityory/(root|uuid)
|
|
|
|
|
|
|
|
# wc-info/(schedule|depth)
|
|
|
|
|
|
|
|
# commit/(author|date)
|
|
|
|
|
|
|
|
# str() the results because they may be returned as Unicode, which
|
|
|
|
|
|
|
|
# interferes with the higher layers matching up things in the deps
|
|
|
|
|
|
|
|
# dictionary.
|
|
|
|
|
|
|
|
result['Repository Root'] = C(GetNamedNodeText(dom, 'root'), str)
|
|
|
|
|
|
|
|
result['URL'] = C(GetNamedNodeText(dom, 'url'), str)
|
|
|
|
|
|
|
|
result['UUID'] = C(GetNamedNodeText(dom, 'uuid'), str)
|
|
|
|
|
|
|
|
result['Revision'] = C(GetNodeNamedAttributeText(dom, 'entry',
|
|
|
|
|
|
|
|
'revision'),
|
|
|
|
|
|
|
|
int)
|
|
|
|
|
|
|
|
result['Node Kind'] = C(GetNodeNamedAttributeText(dom, 'entry', 'kind'),
|
|
|
|
|
|
|
|
str)
|
|
|
|
# Differs across versions.
|
|
|
|
# Differs across versions.
|
|
|
|
if result['Node Kind'] == 'dir':
|
|
|
|
if result['Node Kind'] == 'dir':
|
|
|
|
result['Node Kind'] = 'directory'
|
|
|
|
result['Node Kind'] = 'directory'
|
|
|
|
result['URL'] = entry.find('url').text
|
|
|
|
result['Schedule'] = C(GetNamedNodeText(dom, 'schedule'), str)
|
|
|
|
repository = entry.find('repository')
|
|
|
|
result['Path'] = C(GetNodeNamedAttributeText(dom, 'entry', 'path'), str)
|
|
|
|
result['Repository Root'] = repository.find('root').text
|
|
|
|
result['Copied From URL'] = C(GetNamedNodeText(dom, 'copy-from-url'), str)
|
|
|
|
result['UUID'] = repository.find('uuid')
|
|
|
|
result['Copied From Rev'] = C(GetNamedNodeText(dom, 'copy-from-rev'), str)
|
|
|
|
wc_info = entry.find('wc-info')
|
|
|
|
|
|
|
|
result['Schedule'] = wc_info.find('schedule').text
|
|
|
|
|
|
|
|
result['Copied From URL'] = wc_info.find('copy-from-url')
|
|
|
|
|
|
|
|
result['Copied From Rev'] = wc_info.find('copy-from-rev')
|
|
|
|
|
|
|
|
for key in result.keys():
|
|
|
|
|
|
|
|
if isinstance(result[key], unicode):
|
|
|
|
|
|
|
|
# Unicode results interferes with the higher layers matching up things
|
|
|
|
|
|
|
|
# in the deps dictionary.
|
|
|
|
|
|
|
|
result[key] = result[key].encode()
|
|
|
|
|
|
|
|
# Automatic conversion of optional parameters.
|
|
|
|
|
|
|
|
result[key] = getattr(result[key], 'text', result[key])
|
|
|
|
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
@ -550,7 +553,9 @@ class SVN(object):
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
Int base revision
|
|
|
|
Int base revision
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return SVN.CaptureInfo(cwd).get('Revision')
|
|
|
|
info = SVN.Capture(['info', '--xml'], cwd=cwd)
|
|
|
|
|
|
|
|
dom = xml.dom.minidom.parseString(info)
|
|
|
|
|
|
|
|
return dom.getElementsByTagName('entry')[0].getAttribute('revision')
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
|
def CaptureStatus(files):
|
|
|
|
def CaptureStatus(files):
|
|
|
@ -585,19 +590,20 @@ class SVN(object):
|
|
|
|
'replaced': 'R',
|
|
|
|
'replaced': 'R',
|
|
|
|
'unversioned': '?',
|
|
|
|
'unversioned': '?',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dom = ElementTree.XML(SVN.Capture(command))
|
|
|
|
dom = gclient_utils.ParseXML(SVN.Capture(command))
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
if dom is None:
|
|
|
|
if dom:
|
|
|
|
return results
|
|
|
|
|
|
|
|
# /status/target/entry/(wc-status|commit|author|date)
|
|
|
|
# /status/target/entry/(wc-status|commit|author|date)
|
|
|
|
for target in dom.findall('target'):
|
|
|
|
for target in dom.getElementsByTagName('target'):
|
|
|
|
for entry in target.findall('entry'):
|
|
|
|
#base_path = target.getAttribute('path')
|
|
|
|
file_path = entry.attrib['path']
|
|
|
|
for entry in target.getElementsByTagName('entry'):
|
|
|
|
wc_status = entry.find('wc-status')
|
|
|
|
file_path = entry.getAttribute('path')
|
|
|
|
|
|
|
|
wc_status = entry.getElementsByTagName('wc-status')
|
|
|
|
|
|
|
|
assert len(wc_status) == 1
|
|
|
|
# Emulate svn 1.5 status ouput...
|
|
|
|
# Emulate svn 1.5 status ouput...
|
|
|
|
statuses = [' '] * 7
|
|
|
|
statuses = [' '] * 7
|
|
|
|
# Col 0
|
|
|
|
# Col 0
|
|
|
|
xml_item_status = wc_status.attrib['item']
|
|
|
|
xml_item_status = wc_status[0].getAttribute('item')
|
|
|
|
if xml_item_status in status_letter:
|
|
|
|
if xml_item_status in status_letter:
|
|
|
|
statuses[0] = status_letter[xml_item_status]
|
|
|
|
statuses[0] = status_letter[xml_item_status]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -605,7 +611,7 @@ class SVN(object):
|
|
|
|
'Unknown item status "%s"; please implement me!' %
|
|
|
|
'Unknown item status "%s"; please implement me!' %
|
|
|
|
xml_item_status)
|
|
|
|
xml_item_status)
|
|
|
|
# Col 1
|
|
|
|
# Col 1
|
|
|
|
xml_props_status = wc_status.attrib['props']
|
|
|
|
xml_props_status = wc_status[0].getAttribute('props')
|
|
|
|
if xml_props_status == 'modified':
|
|
|
|
if xml_props_status == 'modified':
|
|
|
|
statuses[1] = 'M'
|
|
|
|
statuses[1] = 'M'
|
|
|
|
elif xml_props_status == 'conflicted':
|
|
|
|
elif xml_props_status == 'conflicted':
|
|
|
@ -618,13 +624,13 @@ class SVN(object):
|
|
|
|
'Unknown props status "%s"; please implement me!' %
|
|
|
|
'Unknown props status "%s"; please implement me!' %
|
|
|
|
xml_props_status)
|
|
|
|
xml_props_status)
|
|
|
|
# Col 2
|
|
|
|
# Col 2
|
|
|
|
if wc_status.attrib.get('wc-locked') == 'true':
|
|
|
|
if wc_status[0].getAttribute('wc-locked') == 'true':
|
|
|
|
statuses[2] = 'L'
|
|
|
|
statuses[2] = 'L'
|
|
|
|
# Col 3
|
|
|
|
# Col 3
|
|
|
|
if wc_status.attrib.get('copied') == 'true':
|
|
|
|
if wc_status[0].getAttribute('copied') == 'true':
|
|
|
|
statuses[3] = '+'
|
|
|
|
statuses[3] = '+'
|
|
|
|
# Col 4
|
|
|
|
# Col 4
|
|
|
|
if wc_status.attrib.get('switched') == 'true':
|
|
|
|
if wc_status[0].getAttribute('switched') == 'true':
|
|
|
|
statuses[4] = 'S'
|
|
|
|
statuses[4] = 'S'
|
|
|
|
# TODO(maruel): Col 5 and 6
|
|
|
|
# TODO(maruel): Col 5 and 6
|
|
|
|
item = (''.join(statuses), file_path)
|
|
|
|
item = (''.join(statuses), file_path)
|
|
|
|