Files @ r26254:4dd185cf8a2d
Branch filter:

Location: cpp/openttd-patchpack/source/versiondump.py - annotation

Theleruby
Merge with master
import subprocess
import os
import datetime
import sys


#================================
# the new version format is MAJORSAVE.MINORSAVE.BUGFIX

# bump MAJORSAVE every time there is a breaking change to the save format 
# bump MINORSAVE every time a save format change would stop save loading in older versions
# bump BUGFIX if save format is untouched
# bumps cause all later numbers to be reset. e.g. if you bump MINORSAVE then BUGFIX goes back to 0.

# save version to end 'pre' for unreleased builds with the version number being that of the next likely release

VERSION_TAG = "TheleTTD-6.0.1pre"
#================================


if sys.platform == "darwin":
	hg_path = "/usr/local/bin/hg"
	hg_shell = True
else:
	hg_path = "hg"
	hg_shell = False

HG_BRANCH = subprocess.Popen(hg_path + " branch", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()
HG_REVISION = subprocess.Popen(hg_path + " identify --num", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()
HG_CHANGESET = subprocess.Popen(hg_path + " parents --template \"{node}\"", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()
HG_CHANGESET_SHORT = subprocess.Popen(hg_path + " parents --template \"{node|short}\"", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()
HG_REPO_OWNER = subprocess.Popen(hg_path + " showconfig ui.username", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()
IS_TAGGED_VERSION = "pre" not in VERSION_TAG and "+" not in HG_REVISION

if "+" in HG_REVISION:
    HG_CHANGESET = HG_CHANGESET + "+"
    HG_CHANGESET_SHORT = HG_CHANGESET_SHORT + "+"
    HG_DATE = subprocess.Popen(hg_path + " identify --template \"{date|isodate}\"", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()
else:
    HG_DATE = subprocess.Popen(hg_path + " parents --template \"{date|isodate}\"", cwd="src/", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=hg_shell).stdout.read().decode('utf-8').strip()

if not IS_TAGGED_VERSION:
    VERSION_TAG = VERSION_TAG + "-h" + HG_CHANGESET_SHORT

# write in format  VERSION ISODATE MODIFIED HASH ISTAG ISSTABLETAG YEAR
version_file = open('.ottdrev-gpp', 'w')
version_file.write("{}\t{}\t{}\t{}\t{}\t{}\t{}\n".format(VERSION_TAG, HG_DATE[:10].replace("-",""), "4" if "+" in HG_REVISION else "3", HG_CHANGESET, "1" if IS_TAGGED_VERSION else "0", "0", HG_DATE[:4]))
version_file.close()

print('This is TheleTTD hg r' + HG_REVISION + ' (' + HG_CHANGESET + ') in branch ' + HG_BRANCH)
print('This build is being performed by: ' + HG_REPO_OWNER)