summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-05-15 13:37:02 +0200
committerGitHub <noreply@github.com>2019-05-15 13:37:02 +0200
commit1dc8f952a5dcd553c144940142a82efc6599477f (patch)
treefa1a2cefc8f8b31470f8c47d6713b2df82fef0a1 /lib
parent821b7d3b93174fe629bb80ede3a5c447757b2b9b (diff)
downloadspack-1dc8f952a5dcd553c144940142a82efc6599477f.tar.gz
spack-1dc8f952a5dcd553c144940142a82efc6599477f.tar.bz2
spack-1dc8f952a5dcd553c144940142a82efc6599477f.tar.xz
spack-1dc8f952a5dcd553c144940142a82efc6599477f.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/fetch_strategy.py11
-rw-r--r--lib/spack/spack/test/conftest.py11
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