FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Commit the hg build identification patch from the pymigr repo. · python-emscripten/cpython@1ca2e79 · GitHub

Repository navigation

Commit 1ca2e79

Browse files
committed
Commit the hg build identification patch from the pymigr repo.
1 parent 7b50c2c commit 1ca2e79

6 files changed

Lines changed: 120 additions & 5 deletions

File tree

‎Include/pythonrun.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
120120
PyAPI_FUNC(const char *) _Py_svnversion(void);
121121
PyAPI_FUNC(const char *) Py_SubversionRevision(void);
122122
PyAPI_FUNC(const char *) Py_SubversionShortBranch(void);
123+
PyAPI_FUNC(const char *) _Py_hgidentifier(void);
124+
PyAPI_FUNC(const char *) _Py_hgversion(void);
123125

124126
/* Internal -- various one-time initializations */
125127
PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);

‎Makefile.pre.in‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ LINKCC= @LINKCC@
3535
AR= @AR@
3636
RANLIB= @RANLIB@
3737
SVNVERSION= @SVNVERSION@
38+
HGVERSION= @HGVERSION@
39+
HGTAG= @HGTAG@
40+
HGBRANCH= @HGBRANCH@
3841

3942
GNULD= @GNULD@
4043

@@ -525,7 +528,12 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
525528
$(SIGNAL_OBJS) \
526529
$(MODOBJS) \
527530
$(srcdir)/Modules/getbuildinfo.c
528-
$(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
531+
$(CC) -c $(PY_CFLAGS) \
532+
-DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" \
533+
-DHGVERSION="\"`LC_ALL=C $(HGVERSION)`\"" \
534+
-DHGTAG="\"`LC_ALL=C $(HGTAG)`\"" \
535+
-DHGBRANCH="\"`LC_ALL=C $(HGBRANCH)`\"" \
536+
-o $@ $(srcdir)/Modules/getbuildinfo.c
529537

530538
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
531539
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \

‎Modules/getbuildinfo.c‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,28 @@
2828
#define SVNVERSION "$WCRANGE$$WCMODS?M:$"
2929
#endif
3030

31+
/* XXX Only unix build process has been tested */
32+
#ifndef HGVERSION
33+
#define HGVERSION ""
34+
#endif
35+
#ifndef HGTAG
36+
#define HGTAG ""
37+
#endif
38+
#ifndef HGBRANCH
39+
#define HGBRANCH ""
40+
#endif
41+
3142
const char *
3243
Py_GetBuildInfo(void)
3344
{
3445
static char buildinfo[50];
35-
const char *revision = Py_SubversionRevision();
46+
const char *revision = _Py_hgversion();
3647
const char *sep = *revision ? ":" : "";
37-
const char *branch = Py_SubversionShortBranch();
48+
const char *hgid = _Py_hgidentifier();
49+
if (!(*hgid))
50+
hgid = "default";
3851
PyOS_snprintf(buildinfo, sizeof(buildinfo),
39-
"%s%s%s, %.20s, %.9s", branch, sep, revision,
52+
"%s%s%s, %.20s, %.9s", hgid, sep, revision,
4053
DATE, TIME);
4154
return buildinfo;
4255
}
@@ -50,3 +63,21 @@ _Py_svnversion(void)
5063
return svnversion; /* it was interpolated, or passed on command line */
5164
return "Unversioned directory";
5265
}
66+
67+
const char *
68+
_Py_hgversion(void)
69+
{
70+
return HGVERSION;
71+
}
72+
73+
const char *
74+
_Py_hgidentifier(void)
75+
{
76+
const char *hgtag, *hgid;
77+
hgtag = HGTAG;
78+
if ((*hgtag) && strcmp(hgtag, "tip") != 0)
79+
hgid = hgtag;
80+
else
81+
hgid = HGBRANCH;
82+
return hgid;
83+
}

‎Python/sysmodule.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,9 @@ _PySys_Init(void)
13581358
SET_SYS_FROM_STRING("subversion",
13591359
Py_BuildValue("(UUU)", "CPython", branch,
13601360
svn_revision));
1361+
SET_SYS_FROM_STRING("_mercurial",
1362+
Py_BuildValue("(szz)", "CPython", _Py_hgidentifier(),
1363+
_Py_hgversion()));
13611364
SET_SYS_FROM_STRING("dont_write_bytecode",
13621365
PyBool_FromLong(Py_DontWriteBytecodeFlag));
13631366
SET_SYS_FROM_STRING("api_version",

‎configure‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# From configure.in Revision: 88561 .
2+
# From configure.in Revision.
33
# Guess values for system-dependent variables and create Makefiles.
44
# Generated by GNU Autoconf 2.68 for python 3.1.
55
#
@@ -639,6 +639,10 @@ LN
639639
INSTALL_DATA
640640
INSTALL_SCRIPT
641641
INSTALL_PROGRAM
642+
HAS_HG
643+
HGBRANCH
644+
HGTAG
645+
HGVERSION
642646
SVNVERSION
643647
ARFLAGS
644648
AR
@@ -5089,6 +5093,58 @@ else
50895093
SVNVERSION="echo Unversioned directory"
50905094
fi
50915095
5096+
5097+
5098+
5099+
# Extract the first word of "hg", so it can be a program name with args.
5100+
set dummy hg; ac_word=$2
5101+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5102+
$as_echo_n "checking for $ac_word... " >&6; }
5103+
if ${ac_cv_prog_HAS_HG+:} false; then :
5104+
$as_echo_n "(cached) " >&6
5105+
else
5106+
if test -n "$HAS_HG"; then
5107+
ac_cv_prog_HAS_HG="$HAS_HG" # Let the user override the test.
5108+
else
5109+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5110+
for as_dir in $PATH
5111+
do
5112+
IFS=$as_save_IFS
5113+
test -z "$as_dir" && as_dir=.
5114+
for ac_exec_ext in '' $ac_executable_extensions; do
5115+
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5116+
ac_cv_prog_HAS_HG="found"
5117+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5118+
break 2
5119+
fi
5120+
done
5121+
done
5122+
IFS=$as_save_IFS
5123+
5124+
test -z "$ac_cv_prog_HAS_HG" && ac_cv_prog_HAS_HG="not-found"
5125+
fi
5126+
fi
5127+
HAS_HG=$ac_cv_prog_HAS_HG
5128+
if test -n "$HAS_HG"; then
5129+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAS_HG" >&5
5130+
$as_echo "$HAS_HG" >&6; }
5131+
else
5132+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5133+
$as_echo "no" >&6; }
5134+
fi
5135+
5136+
5137+
if test $HAS_HG = found
5138+
then
5139+
HGVERSION="hg id -i \$(srcdir)"
5140+
HGTAG="hg id -t \$(srcdir)"
5141+
HGBRANCH="hg id -b \$(srcdir)"
5142+
else
5143+
HGVERSION=""
5144+
HGTAG=""
5145+
HGBRANCH=""
5146+
fi
5147+
50925148
case $MACHDEP in
50935149
bsdos*|hp*|HP*)
50945150
# install -d does not work on BSDI or HP-UX

‎configure.in‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,21 @@ else
785785
SVNVERSION="echo Unversioned directory"
786786
fi
787787

788+
AC_SUBST(HGVERSION)
789+
AC_SUBST(HGTAG)
790+
AC_SUBST(HGBRANCH)
791+
AC_CHECK_PROG(HAS_HG, hg, found, not-found)
792+
if test $HAS_HG = found
793+
then
794+
HGVERSION="hg id -i \$(srcdir)"
795+
HGTAG="hg id -t \$(srcdir)"
796+
HGBRANCH="hg id -b \$(srcdir)"
797+
else
798+
HGVERSION=""
799+
HGTAG=""
800+
HGBRANCH=""
801+
fi
802+
788803
case $MACHDEP in
789804
bsdos*|hp*|HP*)
790805
# install -d does not work on BSDI or HP-UX

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL