Commit 065c85b3 authored by Matti Picus's avatar Matti Picus
Browse files

slightly improve version detection with git, for bettern udir creation

parent b86b4af25a6e
Pipeline #59408 passed with stage
in 5 minutes and 23 seconds
from __future__ import print_function
import sys
from py.io import ansi_print, get_terminal_width
......@@ -120,7 +121,7 @@ class Driver(object):
def restart(self):
""" Restarts the current generator. """
print >>sys.stderr
print('', file=sys.stderr)
self.init()
def dot(self):
......@@ -134,7 +135,7 @@ class Driver(object):
self.init()
except StopIteration:
if DEBUG and self.interesting_coordinates:
print >>sys.stderr, "Interesting coordinates:", self.interesting_coordinates
print("Interesting coordinates:", self.interesting_coordinates, file=sys.stderr)
self.interesting_coordinates = []
kwargs = self.kwargs
self.zoom_location += 1
......@@ -144,7 +145,7 @@ class Driver(object):
self.max_colour = loc[3]
if DEBUG:
# Only used for debugging new locations:
print "Colour range", self.colour_range
print("Colour range", self.colour_range)
self.colour_range = None
self.restart()
return
......@@ -152,7 +153,7 @@ class Driver(object):
self.interesting_coordinates.append(dict(x=(x, self.mandelbrot.x_range[x]),
y=(y, self.mandelbrot.y_range[y])))
if x == self.width - 1:
print >>sys.stderr
print('', file=sys.stderr)
def print_pixel(self, colour, invert=1):
chars = [".", ".", "+", "*", "%", "#"]
......@@ -183,4 +184,4 @@ if __name__ == '__main__':
if 0 and random.random() < 0.01:
string = "WARNING! " * 3
d.jump(len(string))
print string,
print(string, end='')
......@@ -33,8 +33,16 @@ def get_repo_version_info(hgexe=None, root=rpythonroot):
def _get_repo_version_info(hgexe, root):
# Try to see if we can get info from Git if hgexe is not specified.
if not hgexe:
if os.path.isdir(os.path.join(root, '.git')):
gitfile = os.path.join(root, '.git')
if os.path.isdir(gitfile):
return _get_git_version(root)
elif os.path.exists(gitfile):
# Can be a file with a relative path like
# gitdir: ../.git/modules/pypy
with open(gitfile) as fid:
contents = fid.read()
if contents.startswith('gitdir:'):
return _get_git_version(root)
# Fallback to trying Mercurial.
if hgexe is None:
......@@ -129,13 +137,15 @@ def _get_git_version(root):
)
if p.wait() != 0:
maywarn(p.stderr.read(), 'Git')
return '?', revision_id
return 'pypy-HEAD', revision_id
branch = '?'
for line in p.stdout.read().strip().split('\n'):
if line.startswith('* '):
branch = line[1:].strip()
if branch == '(no branch)':
branch = '?'
branch = 'pypy-HEAD'
if branch.startswith("(HEAD detached"):
branch = 'pypy-HEAD'
break
return branch, revision_id
return p.stdout.read().strip(), revision_id
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment