[Jython-checkins] jython (2.5): hg version support
philip.jenvey
jython-checkins at python.org
Sat May 7 23:54:30 CEST 2011
http://hg.python.org/jython/rev/f38f32d05761
changeset: 6200:f38f32d05761
branch: 2.5
parent: 6198:af8a3b6579e9
user: Philip Jenvey <pjenvey at underboss.org>
date: Sun Mar 20 06:07:17 2011 +0000
summary:
hg version support
(transplanted from 5ea8da7349edef793af8a3714517263735f5cf01)
files:
build.xml | 28 ++++++++++-
src/org/python/Version.java | 36 ++++++++++++++
src/org/python/core/PySystemState.java | 4 +
3 files changed, 67 insertions(+), 1 deletions(-)
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -398,10 +398,33 @@
<exec executable="svnversion" failifexecutionfails="false" outputproperty="build.svn.revision"/>
</target>
+ <!-- XXX: Might this work on Windows? -->
+ <target name="hg-branch" if="os.family.unix">
+ <exec executable="hg" failifexecutionfails="false" outputproperty="build.hg.branch">
+ <arg line="id -b"/>
+ </exec>
+ </target>
+ <target name="hg-tag" if="os.family.unix">
+ <exec executable="hg" failifexecutionfails="false" outputproperty="build.hg.tag">
+ <arg line="id -t"/>
+ </exec>
+ </target>
+ <target name="hg-version" if="os.family.unix">
+ <exec executable="hg" failifexecutionfails="false" outputproperty="build.hg.version">
+ <arg line="id -i"/>
+ </exec>
+ </target>
+ <target name="hg-id" depends="hg-branch, hg-tag, hg-version"/>
+
<!-- skip-brand can be set in ant.properties or as a system property to keep from updating the
version.properties file and making the jar on every developer build. -->
+ <!-- when hg:
+ <target name="brand-version" depends="init, hg-id" unless="skip-brand">-->
<target name="brand-version" depends="init, svnversion" unless="skip-brand">
<property name="build.svn.revision" value=""/>
+ <property name="build.hg.branch" value=""/>
+ <property name="build.hg.tag" value=""/>
+ <property name="build.hg.version" value=""/>
<tstamp>
<format property="build.date" pattern="MMM d yyyy" offset="0"/>
<format property="build.time" pattern="HH:mm:ss" offset="0"/>
@@ -416,7 +439,10 @@
jython.release_serial=${jython.release_serial}
jython.build.date=${build.date}
jython.build.time=${build.time}
-jython.build.svn_revision=${build.svn.revision}</echo>
+jython.build.svn_revision=${build.svn.revision}
+jython.build.hg_branch=${build.hg.branch}
+jython.build.hg_tag=${build.hg.tag}
+jython.build.hg_version=${build.hg.version}</echo>
</target>
<target name="brand-readme-version" depends="checkout" if="do.snapshot.build">
diff --git a/src/org/python/Version.java b/src/org/python/Version.java
--- a/src/org/python/Version.java
+++ b/src/org/python/Version.java
@@ -34,6 +34,8 @@
public static String DATE;
public static String TIME;
public static String SVN_REVISION;
+ /** Current hg global revision id (hg id -i). */
+ public static String HG_VERSION;
/** Determined from headURL, branch is the path under the
* subversion root, e.g. branches/asm. */
@@ -42,6 +44,12 @@
/** Short version of branch, e.g. asm. */
public static String SHORT_BRANCH;
+ /** Current hg branch (hg id -b). */
+ public static String HG_BRANCH;
+
+ /** Current hg tag (hg id -t), e.g. 'tip'. */
+ public static String HG_TAG;
+
/** The flags that are set by default in a code object. */
private static final Collection<CodeFlag> defaultCodeFlags = Arrays.asList(
CodeFlag.CO_NESTED, CodeFlag.CO_GENERATOR_ALLOWED);
@@ -103,6 +111,9 @@
DATE = properties.getProperty("jython.build.date");
TIME = properties.getProperty("jython.build.time");
SVN_REVISION = properties.getProperty("jython.build.svn_revision");
+ HG_BRANCH = properties.getProperty("jython.build.hg_branch");
+ HG_TAG = properties.getProperty("jython.build.hg_tag");
+ HG_VERSION = properties.getProperty("jython.build.hg_version");
} catch (IOException ioe) {
System.err.println("There was a problem loading ".concat(versionProperties)
.concat(":"));
@@ -137,6 +148,21 @@
}
/**
+ * Return the current hg version number. May be an empty string on environments that
+ * can't determine it.
+ */
+ public static String getHGVersion() {
+ return HG_VERSION;
+ }
+
+ /**
+ * Return the current hg identifier name, either the current branch or tag.
+ */
+ public static String getHGIdentifier() {
+ return "".equals(HG_TAG) || "tip".equals(HG_TAG) ? HG_BRANCH : HG_TAG;
+ }
+
+ /**
* Return the current build information, including revision and
* timestamp.
*/
@@ -148,6 +174,16 @@
}
/**
+ * Return the current build information, including revision and timestamp.
+ */
+ public static String getBuildInfoHG() {
+ String revision = getHGVersion();
+ String sep = "".equals(revision) ? "" : ":";
+ String hgId = getHGIdentifier();
+ return String.format("%s%s%s, %.20s, %.9s", hgId, sep, revision, DATE, TIME);
+ }
+
+ /**
* Describe the current Java VM.
*/
public static String getVM() {
diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java
--- a/src/org/python/core/PySystemState.java
+++ b/src/org/python/core/PySystemState.java
@@ -66,6 +66,8 @@
public final static int maxunicode = 1114111;
public static PyTuple subversion;
+
+ public static PyTuple _mercurial;
/**
* The copyright notice for this release.
*/
@@ -946,6 +948,8 @@
Py.newInteger(Version.PY_RELEASE_SERIAL));
subversion = new PyTuple(Py.newString("Jython"), Py.newString(Version.BRANCH),
Py.newString(Version.SVN_REVISION));
+ _mercurial = new PyTuple(Py.newString("Jython"), Py.newString(Version.getHGIdentifier()),
+ Py.newString(Version.getHGVersion()));
}
public static boolean isPackageCacheEnabled() {
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list