Skip to content
Snippets Groups Projects
Commit 49e28d32 authored by Christian Goetze (CG)'s avatar Christian Goetze (CG)
Browse files

Cherrypick Merov's fix for update_version_files.py.

parent e713da24
No related branches found
No related tags found
No related merge requests found
"""@file llversion.py #!/usr/bin/env python
@brief Utility for parsing llcommon/llversion${server}.h """\
for the version string and channel string @file llversion.py
Utility that parses hg or svn info for branch and revision @brief Parses llcommon/llversionserver.h and llcommon/llversionviewer.h
for the version string and channel string.
Parses hg info for branch and revision.
$LicenseInfo:firstyear=2006&license=mit$ $LicenseInfo:firstyear=2006&license=mit$
...@@ -27,7 +29,7 @@ ...@@ -27,7 +29,7 @@
$/LicenseInfo$ $/LicenseInfo$
""" """
import re, sys, os, commands import re, sys, os, subprocess
# Methods for gathering version information from # Methods for gathering version information from
# llversionviewer.h and llversionserver.h # llversionviewer.h and llversionserver.h
...@@ -73,29 +75,13 @@ def get_viewer_channel(): ...@@ -73,29 +75,13 @@ def get_viewer_channel():
def get_server_channel(): def get_server_channel():
return get_channel('server') return get_channel('server')
# Methods for gathering subversion information # Methods for gathering hg information
def get_svn_status_matching(regular_expression):
# Get the subversion info from the working source tree
status, output = commands.getstatusoutput('svn info %s' % get_src_root())
m = regular_expression.search(output)
if not m:
print >> sys.stderr, "Failed to parse svn info output, result follows:"
print >> sys.stderr, output
raise Exception, "No matching svn status in "+src_root
return m.group(1)
def get_svn_branch():
branch_re = re.compile('URL: (\S+)')
return get_svn_status_matching(branch_re)
def get_svn_revision():
last_rev_re = re.compile('Last Changed Rev: (\d+)')
return get_svn_status_matching(last_rev_re)
def get_hg_repo(): def get_hg_repo():
status, output = commands.getstatusoutput('hg showconfig paths.default') child = subprocess.Popen(["hg","showconfig","paths.default"], stdout=subprocess.PIPE)
output, error = child.communicate()
status = child.returncode
if status: if status:
print >> sys.stderr, output print >> sys.stderr, error
sys.exit(1) sys.exit(1)
if not output: if not output:
print >> sys.stderr, 'ERROR: cannot find repo we cloned from' print >> sys.stderr, 'ERROR: cannot find repo we cloned from'
...@@ -103,24 +89,19 @@ def get_hg_repo(): ...@@ -103,24 +89,19 @@ def get_hg_repo():
return output return output
def get_hg_changeset(): def get_hg_changeset():
# The right thing to do: # The right thing to do would be to use the *global* revision id:
# status, output = commands.getstatusoutput('hg id -i') # "hg id -i"
# if status: # For the moment though, we use the parent revision:
# print >> sys.stderr, output child = subprocess.Popen(["hg","parents","--template","{rev}"], stdout=subprocess.PIPE)
# sys.exit(1) output, error = child.communicate()
status = child.returncode
# The temporary hack:
status, output = commands.getstatusoutput('hg parents --template "{rev}"')
if status: if status:
print >> sys.stderr, output print >> sys.stderr, error
sys.exit(1) sys.exit(1)
lines = output.splitlines() lines = output.splitlines()
if len(lines) > 1: if len(lines) > 1:
print >> sys.stderr, 'ERROR: working directory has %d parents' % len(lines) print >> sys.stderr, 'ERROR: working directory has %d parents' % len(lines)
return lines[0] return lines[0]
def using_svn():
return os.path.isdir(os.path.join(get_src_root(), '.svn'))
def using_hg(): def using_hg():
return os.path.isdir(os.path.join(get_src_root(), '.hg')) return os.path.isdir(os.path.join(get_src_root(), '.hg'))
#!/usr/bin/python #!/usr/bin/env python
# """\
# Update all of the various files in the repository to a new version number, @file update_version_files.py
# instead of having to figure it out by hand @brief Update all of the various files in the repository to a new version number,
# instead of having to figure it out by hand
$LicenseInfo:firstyear=2010&license=viewerlgpl$
Second Life Viewer Source Code
Copyright (C) 2010-2011, Linden Research, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
version 2.1 of the License only.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
$/LicenseInfo$
"""
import sys import sys
import os.path import os.path
...@@ -37,9 +59,6 @@ def add_indra_lib_path(): ...@@ -37,9 +59,6 @@ def add_indra_lib_path():
import getopt, os, re, commands import getopt, os, re, commands
from indra.util import llversion from indra.util import llversion
svn = os.path.expandvars("${SVN}")
if not svn or svn == "${SVN}": svn = "svn"
def usage(): def usage():
print "Usage:" print "Usage:"
print sys.argv[0] + """ [options] print sys.argv[0] + """ [options]
...@@ -68,7 +87,7 @@ def usage(): ...@@ -68,7 +87,7 @@ def usage():
Print this message and exit. Print this message and exit.
Common Uses: Common Uses:
# Update server and viewer build numbers to the current SVN revision: # Update server and viewer build numbers to the current hg revision:
update_version_files.py update_version_files.py
# Update build numbers unless we are on a release branch: # Update build numbers unless we are on a release branch:
...@@ -80,7 +99,7 @@ def usage(): ...@@ -80,7 +99,7 @@ def usage():
# Update just the viewer version number explicitly: # Update just the viewer version number explicitly:
update_version_files.py --viewer --version=1.18.1.6 update_version_files.py --viewer --version=1.18.1.6
# Update just the server build number to the current SVN revision: # Update just the server build number to the current hg revision:
update_version_files.py --server update_version_files.py --server
# Update the viewer channel # Update the viewer channel
...@@ -152,9 +171,7 @@ def _getstatusoutput(cmd): ...@@ -152,9 +171,7 @@ def _getstatusoutput(cmd):
'CFBundleGetInfoString = "Second Life version %(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s')) 'CFBundleGetInfoString = "Second Life version %(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s'))
version_re = re.compile('(\d+).(\d+).(\d+).(\d+)') version_re = re.compile('(\d+).(\d+).(\d+).(\d+)')
svn_branch_re = re.compile('^URL:\s+\S+/([^/\s]+)$', re.MULTILINE)
svn_revision_re = re.compile('^Last Changed Rev: (\d+)$', re.MULTILINE)
def main(): def main():
script_path = os.path.dirname(__file__) script_path = os.path.dirname(__file__)
...@@ -249,13 +266,7 @@ def main(): ...@@ -249,13 +266,7 @@ def main():
server_version = new_version server_version = new_version
else: else:
if llversion.using_svn(): if llversion.using_hg():
if new_revision:
revision = new_revision
else:
revision = llversion.get_svn_revision()
branch = llversion.get_svn_branch()
elif llversion.using_hg():
if new_revision: if new_revision:
revision = new_revision revision = new_revision
else: else:
...@@ -327,5 +338,6 @@ def main(): ...@@ -327,5 +338,6 @@ def main():
print "File %(filename)s not present, skipping..." % locals() print "File %(filename)s not present, skipping..." % locals()
return 0 return 0
main() if __name__ == '__main__':
sys.exit(main())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment