Use svn info --xml instead of svn info to get svn revisions (#11466)

- `svn info` prints different results depending on the system locale
  - in particular, Japanese output doesn't contain "Revision:"

- Change Spack code to use XML output instead of using the human output
This commit is contained in:
Todd Gamblin 2019-05-15 13:37:02 +02:00 committed by GitHub
parent 821b7d3b93
commit 1dc8f952a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View File

@ -26,6 +26,7 @@
import re import re
import shutil import shutil
import copy import copy
import xml.etree.ElementTree
from functools import wraps from functools import wraps
from six import string_types, with_metaclass from six import string_types, with_metaclass
@ -771,13 +772,9 @@ def source_id(self):
return self.revision return self.revision
def get_source_id(self): def get_source_id(self):
output = self.svn('info', self.url, output=str) output = self.svn('info', '--xml', self.url, output=str)
if not output: info = xml.etree.ElementTree.fromstring(output)
return None return info.find('entry/commit').get('revision')
lines = output.split('\n')
for line in lines:
if line.startswith('Revision:'):
return line.split()[-1]
@_needs_stage @_needs_stage
def fetch(self): def fetch(self):

View File

@ -9,7 +9,7 @@
import os import os
import os.path import os.path
import shutil import shutil
import re import xml.etree.ElementTree
import ordereddict_backport import ordereddict_backport
import py import py
@ -725,12 +725,9 @@ def mock_svn_repository(tmpdir_factory):
} }
def get_rev(): def get_rev():
output = svn('info', output=str) output = svn('info', '--xml', output=str)
assert "Revision" in output info = xml.etree.ElementTree.fromstring(output)
for line in output.split('\n'): return info.find('entry/commit').get('revision')
match = re.match(r'Revision: (\d+)', line)
if match:
return match.group(1)
t = Bunch(checks=checks, url=url, hash=get_rev, path=str(repodir)) t = Bunch(checks=checks, url=url, hash=get_rev, path=str(repodir))
yield t yield t