#12481: Fix branch_current_hg()
------------------------+---------------------------------------------------
Reporter: jdemeyer | Owner: jason
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: misc | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
------------------------+---------------------------------------------------
This is just horrible code (`sage/misc/misc.py`):
{{{
def branch_current_hg():
"""
Return the current hg Mercurial branch name. If the branch is
'main', which is the default branch, then just '' is returned.
"""
try:
s = os.popen('ls -l %s/devel/sage'%os.environ['SAGE_ROOT']).read()
except IOError:
# this happens when running sage under gdb on macs
return 'gdb'
if 'No such file or directory' in s:
raise RuntimeError, "unable to determine branch?!"
# do ls -l and look for a symlink, which `ls` represents by a '->'
i = s.rfind('->')
if i == -1:
raise RuntimeError, "unable to determine branch?!"
s = s[i+2:]
i = s.find('-')
if i == -1:
return ''
br = s[i+1:].strip()
return br
}}}
For one, this clearly needs an "lstat" instead of parsing "ls" output.
The "gdb" is also broken, since the string "gdb" doesn't contain "->".
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12481>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.