|
25 | 25 | ##
|
26 | 26 | ########################################################################
|
27 | 27 |
|
28 |
| -# Generate a header file that provides the public symbols from Octave's |
29 |
| -# autoconf-generated config.h file. See the notes at the top of the |
30 |
| -# generated octave-config.h file for more details. |
| 28 | +## Display the Mercurial ID of the current revision. If the source tree |
| 29 | +## does not appear to be a Mercurial repo but does contain a file named |
| 30 | +## HG-ID, display the contents of that file. If that file does not |
| 31 | +## exist, or the Mercurial fails to provide the ID, display |
| 32 | +## "unknown-hg-id". If invoked with the --disable option, display |
| 33 | +## "hg-id-disabled". |
31 | 34 |
|
32 | 35 | set -e
|
33 | 36 |
|
|
39 | 42 | srcdir="$1"
|
40 | 43 |
|
41 | 44 | hg_id=HG-ID
|
42 |
| -move_if_change="$srcdir/build-aux/move-if-change" |
43 | 45 |
|
44 | 46 | ## A user's ~/.hgrc may redefine or add default options to any hg subcommand,
|
45 | 47 | ## potentially altering its behavior and possibly its standard output. Always
|
46 | 48 | ## run hg subcommands with configuration variables set to ensure that the
|
47 | 49 | ## user's preferences do not influence the expected behavior.
|
| 50 | + |
48 | 51 | hg_safe ()
|
49 | 52 | {
|
50 | 53 | cmd=$1; shift
|
51 | 54 | hg --config alias.${cmd}=${cmd} --config defaults.${cmd}= ${cmd} "$@"
|
52 | 55 | }
|
53 | 56 |
|
54 | 57 | if [ $# -eq 2 ] && [ x"$2" = x--disable ]; then
|
55 |
| - echo "hg-id-disabled" > ${hg_id}-t |
56 |
| - ${move_if_change} ${hg_id}-t ${hg_id} |
57 |
| -elif [ -d $srcdir/.hg ]; then |
58 |
| - ( cd $srcdir && hg_safe identify --id || echo "unknown" ) > ${hg_id}-t |
59 |
| - ${move_if_change} ${hg_id}-t ${hg_id} |
60 |
| -elif [ ! -f $srcdir/${hg_id} ]; then |
61 |
| - echo "WARNING: $srcdir/${hg_id} is missing!" 1>&2 |
62 |
| - echo "unknown" > ${hg_id}-t && mv ${hg_id}-t ${hg_id} |
| 58 | + echo "hg-id-disabled" |
| 59 | +elif [ -d "$srcdir/.hg" ]; then |
| 60 | + ( cd "$srcdir" && hg_safe identify --id || echo "unknown-hg-id" ) |
| 61 | +elif [ ! -f "$srcdir/$hg_id" ]; then |
| 62 | + echo "WARNING: $srcdir/$hg_id is missing!" 1>&2 |
| 63 | + echo "unknown-hg-id" |
63 | 64 | else
|
64 |
| - echo "preserving existing ${hg_id} file" 1>&2 |
65 |
| - if [ "x$srcdir" != "x." ] && [ -f $srcdir/${hg_id} ] && [ ! -f ${hg_id} ]; then |
66 |
| - cp ${srcdir}/${hg_id} ${hg_id} |
67 |
| - touch -r ${srcdir}/${hg_id} ${hg_id} |
68 |
| - fi |
| 65 | + cat "$srcdir/$hg_id" |
69 | 66 | fi
|
70 |
| - |
71 |
| -cat ${hg_id} |
0 commit comments