From 1dc8f952a5dcd553c144940142a82efc6599477f Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 15 May 2019 13:37:02 +0200 Subject: 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 --- lib/spack/spack/fetch_strategy.py | 11 ++++------- lib/spack/spack/test/conftest.py | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index bafd99f885..dd7ebd248b 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -26,6 +26,7 @@ import sys import re import shutil import copy +import xml.etree.ElementTree from functools import wraps from six import string_types, with_metaclass @@ -771,13 +772,9 @@ class SvnFetchStrategy(VCSFetchStrategy): return self.revision def get_source_id(self): - output = self.svn('info', self.url, output=str) - if not output: - return None - lines = output.split('\n') - for line in lines: - if line.startswith('Revision:'): - return line.split()[-1] + output = self.svn('info', '--xml', self.url, output=str) + info = xml.etree.ElementTree.fromstring(output) + return info.find('entry/commit').get('revision') @_needs_stage def fetch(self): diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 8107ffe122..9991b53f30 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -9,7 +9,7 @@ import inspect import os import os.path import shutil -import re +import xml.etree.ElementTree import ordereddict_backport import py @@ -725,12 +725,9 @@ def mock_svn_repository(tmpdir_factory): } def get_rev(): - output = svn('info', output=str) - assert "Revision" in output - for line in output.split('\n'): - match = re.match(r'Revision: (\d+)', line) - if match: - return match.group(1) + output = svn('info', '--xml', output=str) + info = xml.etree.ElementTree.fromstring(output) + return info.find('entry/commit').get('revision') t = Bunch(checks=checks, url=url, hash=get_rev, path=str(repodir)) yield t -- cgit v1.2.3-60-g2f50