I have a python project under SVN, and I\'m wanting to display the version number when it is run. Is there any way of doing this (such as automatically running a short scrip
You could do this programmatically by parsing the output from 'svn info --xml' to an xml Element:
def get_svn_rev(dir: Union[str, Path]) -> str:
"""Get the svn revision of the given directory"""
dir = str(dir)
svn_info_cmd = ['svn', 'info', '--xml', dir]
print(' '.join(svn_info_cmd))
svn_info_process = subprocess.run(svn_info_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if svn_info_process.returncode:
eprint(svn_info_process.stderr.decode().strip())
raise subprocess.CalledProcessError(returncode=svn_info_process.returncode, cmd=svn_info_cmd,
output=svn_info_process.stdout,
stderr=svn_info_process.stderr)
else:
info = ElementTree.fromstring(svn_info_process.stdout.decode().strip())
entry = info.find('entry')
revision = entry.get('revision')
return revision