Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
10cf492e
Commit
10cf492e
authored
14 years ago
by
Merov Linden
Browse files
Options
Downloads
Patches
Plain Diff
STORM-937 : Use subprocess instead os commands in python, suppress crufty svn code
parent
896bc12a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/lib/python/indra/util/llversion.py
+19
-38
19 additions, 38 deletions
indra/lib/python/indra/util/llversion.py
scripts/update_version_files.py
+6
-16
6 additions, 16 deletions
scripts/update_version_files.py
with
25 additions
and
54 deletions
indra/lib/python/indra/util/llversion.py
+
19
−
38
View file @
10cf492e
"""
@file llversion.py
@brief Utility for parsing llcommon/llversion${server}.h
for the version string and channel string
Utility that parses hg or svn info for branch and revision
#!/usr/bin/env python
"""
\
@file llversion.py
@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$
...
...
@@ -27,7 +29,7 @@
$/LicenseInfo$
"""
import
re
,
sys
,
os
,
command
s
import
re
,
sys
,
os
,
subproces
s
# Methods for gathering version information from
# llversionviewer.h and llversionserver.h
...
...
@@ -73,29 +75,13 @@ def get_viewer_channel():
def
get_server_channel
():
return
get_channel
(
'
server
'
)
# Methods for gathering subversion 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
)
# Methods for gathering hg information
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
:
print
>>
sys
.
stderr
,
output
print
>>
sys
.
stderr
,
error
sys
.
exit
(
1
)
if
not
output
:
print
>>
sys
.
stderr
,
'
ERROR: cannot find repo we cloned from
'
...
...
@@ -103,24 +89,19 @@ def get_hg_repo():
return
output
def
get_hg_changeset
():
# The right thing to do:
# status, output = commands.getstatusoutput('hg id -i')
# if status:
# print >> sys.stderr, output
# sys.exit(1)
# The temporary hack:
status
,
output
=
commands
.
getstatusoutput
(
'
hg parents --template
"
{rev}
"'
)
# The right thing to do would be to use the *global* revision id:
# "hg id -i"
# For the moment though, we use the parent revision:
child
=
subprocess
.
Popen
([
"
hg
"
,
"
parents
"
,
"
--template
"
,
"
{rev}
"
],
stdout
=
subprocess
.
PIPE
)
output
,
error
=
child
.
communicate
()
status
=
child
.
returncode
if
status
:
print
>>
sys
.
stderr
,
output
print
>>
sys
.
stderr
,
error
sys
.
exit
(
1
)
lines
=
output
.
splitlines
()
if
len
(
lines
)
>
1
:
print
>>
sys
.
stderr
,
'
ERROR: working directory has %d parents
'
%
len
(
lines
)
return
lines
[
0
]
def
using_svn
():
return
os
.
path
.
isdir
(
os
.
path
.
join
(
get_src_root
(),
'
.svn
'
))
def
using_hg
():
return
os
.
path
.
isdir
(
os
.
path
.
join
(
get_src_root
(),
'
.hg
'
))
This diff is collapsed.
Click to expand it.
scripts/update_version_files.py
+
6
−
16
View file @
10cf492e
...
...
@@ -59,9 +59,6 @@ def add_indra_lib_path():
import
getopt
,
os
,
re
,
commands
from
indra.util
import
llversion
svn
=
os
.
path
.
expandvars
(
"
${SVN}
"
)
if
not
svn
or
svn
==
"
${SVN}
"
:
svn
=
"
svn
"
def
usage
():
print
"
Usage:
"
print
sys
.
argv
[
0
]
+
"""
[options]
...
...
@@ -90,7 +87,7 @@ def usage():
Print this message and exit.
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 build numbers unless we are on a release branch:
...
...
@@ -102,7 +99,7 @@ def usage():
# Update just the viewer version number explicitly:
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 the viewer channel
...
...
@@ -174,9 +171,7 @@ def _getstatusoutput(cmd):
'
CFBundleGetInfoString =
"
Second Life version %(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s
'
))
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
)
version_re
=
re
.
compile
(
'
(\d+).(\d+).(\d+).(\d+)
'
)
def
main
():
script_path
=
os
.
path
.
dirname
(
__file__
)
...
...
@@ -271,13 +266,7 @@ def main():
server_version
=
new_version
else
:
if
llversion
.
using_svn
():
if
new_revision
:
revision
=
new_revision
else
:
revision
=
llversion
.
get_svn_revision
()
branch
=
llversion
.
get_svn_branch
()
elif
llversion
.
using_hg
():
if
llversion
.
using_hg
():
if
new_revision
:
revision
=
new_revision
else
:
...
...
@@ -349,5 +338,6 @@ def main():
print
"
File %(filename)s not present, skipping...
"
%
locals
()
return
0
main
()
if
__name__
==
'
__main__
'
:
sys
.
exit
(
main
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment