Commits

Wolfgang Scherer committed 2494d91

genversion.sh: updated.

Comments (0)

Files changed (1)

 
 # --descr--
 # \h1 NAME
-# genversion.sh - version tool
+# genversion.sh - version tool for Mercurial, CVS, RCS
 
 # \h1 SYNOPSIS
 # --usage--
 # <c/genversion.sh/ [OPTIONS] [VERSION-ACTION] [PRINT-ACTIONS]
-#                       [CVS-ACTIONS] [version]
+#                       [VC-ACTIONS] [version]
 # --usage--
 #
 # \h1 DESCRIPTION
                      else eval "${1} () { echo >&2 \"?? ${1}\" \${1+\"\$@\"}; }"; fi; }
 # INCLUDING=1
 # safe_include .script-lib-path
-SHLIB_VERSION="0.10.7"
+SHLIB_VERSION="0.10.11"
 export SHLIB_VERSION
 if test x"${SHLIB_PREFIX+is set}" = x'is set'; then :; else
     SHLIB_PREFIX="/srv/skel"
 # INCLUDING="${base_name_INCLUDING}"
 base_name ()
 {
-  echo $1 | ${SED__PROG-sed} -e '
+  printf "%s\n" "$1" | ${SED__PROG-sed} -e '
 s,//\+,/,
 s,/*$,,
 s,.*[^/]/,,
 # INCLUDING="${file_path_test_INCLUDING}"
 
 if test -z "${_FILE_PATH_TEST_SED}"; then
-    echo >&2 "file_path_test: error: sed(1) srcipts not found"
+    printf "%s\n" >&2 "file_path_test: error: sed(1) srcipts not found"
     # Can we do without it?
     exit 1
 fi
 file_path_test () {
-    return "`echo "$1" | \
+    return "`printf "%s\n" "$1" | \
     ${SED__PROG-sed} -e "${_FILE_PATH_TEST_SED}"`"
 }
 
 # INCLUDING="${dir_name_INCLUDING}"
 
 if test -z "${_DIR_NAME_SED}"; then
-    echo >&2 "dir_name: error: sed(1) srcipts not found"
+    printf "%s\n" >&2 "dir_name: error: sed(1) srcipts not found"
     # Can we do without it?
     exit 1
 fi
 
 dir_name ()
 {
-    echo "$1" | ${SED__PROG-sed} -e "${_DIR_NAME_SED}"
+    printf "%s\n" "$1" | ${SED__PROG-sed} -e "${_DIR_NAME_SED}"
 }
 
 
 # INCLUDING="${dir_name_s_INCLUDING}"
 
 if test -z "${_DIR_NAME_S_SED}"; then
-    echo >&2 "dir_name_s: error: sed(1) srcipts not found"
+    printf "%s\n" >&2 "dir_name_s: error: sed(1) srcipts not found"
     # Can we do without it?
     exit 1
 fi
 
 # squeezing dir_name remove /xxx/../  /./ path elements
 dir_name_s () {
-    echo "$1" | ${SED__PROG-sed} -e "${_DIR_NAME_S_SED}"
+    printf "%s\n" "$1" | ${SED__PROG-sed} -e "${_DIR_NAME_S_SED}"
 }
 
 # make path absolute (if necessary)
 # . .find_prog
 # . .find_lib_script
 # INCLUDING="${echo_n_INCLUDING}"
-echo_n_option=
-echo_n_backslash_c=
-
-if test x"`echo -n`" = x
-then
-    echo_n_option="-n"
-elif test x"`echo "\c"`" = x
-then
-    echo_n_backslash_c='\c'
-elif test x"`echo -e "\c"`" = x
-then
-    echo_n_option="-e"
-    echo_n_backslash_c='\c'
-fi
-
-export echo_n_option echo_n_backslash_c
-
 echo_n ()
 {
-    echo $echo_n_option "$*$echo_n_backslash_c"
+    printf "%s" "$*"
 }
 
 fi # END OF MULTIPLE INCLUDE PROTECTION
         shift
         echo_n "$*"
     else
-        echo "$*"
+        printf "%s\n" "$*"
     fi
 }
 
         shift
         echo_n "${shf_warning}: $*" >&2
     else
-        echo "${shf_warning}: $*" >&2
+        printf "%s\n" "${shf_warning}: $*" >&2
     fi
     unset shf_warning
 }
         shift
         echo_n "${shf_error}: $*" >&2
     else
-        echo "${shf_error}: $*" >&2
+        printf "%s\n" "${shf_error}: $*" >&2
     fi
     unset shf_error
 }
     date="`date +'%d %b %Y'`"
     pfile="$1"; shift
     pname="`base_name $pfile`"
-    pname="`echo $pname | sed 's,^[.],,'`"
+    pname="`printf "%s\n" "$pname" | sed 's,^[.],,'`"
     title="$*"
     test -n "$title" && title=" - $title"
-    echo "\
+    printf "%s\n" "\
 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">
 <!-- This file documents the shell script/procedure $pname. -->"
     
     if test -z "${_SH_LIB_COPYRIGHT_HTML_DEF}"; then
-        echo "\
+        printf "%s\n" "\
 <!--
     This HTML page was generated with Wolfgang Scherer's SHell LIBrary,
     which is copyright (C) 1999, Wolfgang Scherer <Wolfgang.Scherer@gmx.de>.
     This HTML page itself, however, does not have a copyright.
 -->"
     else
-        echo "${_SH_LIB_COPYRIGHT_HTML_DEF}"
+        printf "%s\n" "${_SH_LIB_COPYRIGHT_HTML_DEF}"
     fi
-    echo "\
+    printf "%s\n" "\
 <html>
   <head>"
-    test -n "${_SH_LIB_HTML_STYLE_1_DEF}" && echo "${_SH_LIB_HTML_STYLE_1_DEF}"
-    test -n "${_SH_LIB_HTML_STYLE_2_DEF}" && echo "${_SH_LIB_HTML_STYLE_2_DEF}"
-    test -n "${_SH_LIB_HTML_STYLE_3_DEF}" && echo "${_SH_LIB_HTML_STYLE_3_DEF}"
-    echo "\
+    test -n "${_SH_LIB_HTML_STYLE_1_DEF}" && printf "%s\n" "${_SH_LIB_HTML_STYLE_1_DEF}"
+    test -n "${_SH_LIB_HTML_STYLE_2_DEF}" && printf "%s\n" "${_SH_LIB_HTML_STYLE_2_DEF}"
+    test -n "${_SH_LIB_HTML_STYLE_3_DEF}" && printf "%s\n" "${_SH_LIB_HTML_STYLE_3_DEF}"
+    printf "%s\n" "\
     <title>$pname$title</title>
   </head>
   <!-- NS4 window resize bug (styles disappear) -->
   <body onresize=\"if (document.layers) window.location.reload();\">
     <H1>$pname$title</H1>"
     cat $pfile | ${AWK__PROG-awk} -vdate="$date" "${_EXTRACT_SH_DESCR_HTML_AWK}"
-    echo "\
+    printf "%s\n" "\
   </body>
 </html>"
     return 0;
 {
     date="`date +'%d %b %Y'`"
     pname="`base_name $1`"
-    pname="`echo $pname | sed 's,^[.],,'`"
+    pname="`printf "%s\n" $pname | sed 's,^[.],,'`"
 
-    echo ".\\\" This file documents the shell script/procedure $pname."
+    printf "%s\n" ".\\\" This file documents the shell script/procedure $pname."
 
     case "${2}" in
         1s) section_name="scripts";;
     esac
 
     if test -z "${_SH_LIB_COPYRIGHT_MAN_DEF}"; then
-        echo "\
+        printf "%s\n" "\
 .\\\" This manual page was generated with Wolfgang Scherer's SHell LIBrary,
 .\\\" which is copyright (C) 1999, Wolfgang Scherer <Wolfgang.Scherer@gmx.de>.
 .\\\" This manual page itself, however, does not have a copyright.
 .TH $pname $2 \"$date\" \"sh-lib ${section_name}\""
     else
-        echo "${_SH_LIB_COPYRIGHT_MAN_DEF}" | ${SED__PROG-sed} "
+        printf "%s\n" "${_SH_LIB_COPYRIGHT_MAN_DEF}" | ${SED__PROG-sed} "
 s,@name@,$pname,g
 s,@section@,$2,g
 s,@section_name@,${section_name},
 s,@date@,$date,g
 " 
     fi
-    echo '.ie !\n(.g \{\
+    printf "%s\n" '.ie !\n(.g \{\
 .\" just use the regular .TP, if not under groff
 .  de tP
 .  ie \\n[.$] .TP \\$1
     if test x"$extract_sh_descr_in_MASTER" = x &&
        test -z "$_SH_LIB_HTML_STYLE_1_DEF"; then
         x=safe_include
-        echo >&2 "\
+        printf "%s\n" >&2 "\
 $__esd_pfile:1:dear upgrader! make sure, your inclusion list contains the following:
     $x .extract_sh_descr_help.awe
     $x .extract_sh_descr_man.awe
 #     safe_include .genversion.sh.use
 __USAGE__=\
 '`genversion.sh'\'' [OPTIONS] [VERSION-ACTION] [PRINT-ACTIONS]
-[CVS-ACTIONS] [version]
+[VC-ACTIONS] [version]
 
 OPTIONS
-  -1                             version length 1.                           
-  -2                             version length 2.                           
-  -3                             version length 3.                           
-  -4                             version length 4.                           
-  -C, --directory  directory     change to directory for version information.
-  -f, --file       version-file  specify version file.                       
-  --tag-directory  directory     change to directory for CVS tagging.        
-  --debug                        turn debugging output on.                   
+  -1                             version length 1.                                                   
+  -2                             version length 2.                                                   
+  -3                             version length 3.                                                   
+  -4                             version length 4.                                                   
+  -C, --directory  directory     change to directory for version information.                        
+  -f, --file       version-file  specify version file.                                               
+  --tag-prefix     string        Use string as tag prefix. If this option is not supplied,           
+                                 the contents of .package is used, otherwise the environment variable
+                                 $PACKAGE is used, otherwise the basename of the current directory is
+                                 used, otherwise "Version" is used.                                  
+  --tag-directory  directory     change to directory for CVS tagging.                                
+  --debug                        turn debugging output on.                                           
 
 VERSION ACTIONS
   --next     set next version.             
 # change to directory for version information.
 # \tr \td -f, --file      \td version-file   \td
 # specify version file.
+# \tr \td --tag-prefix   \td string          \td
+# Use string as tag prefix. If this option is not supplied,
+# the contents of .package is used, otherwise the environment variable
+# $PACKAGE is used, otherwise the basename of the current directory is
+# used, otherwise "Version" is used.
 # \tr \td --tag-directory \td directory      \td
 # change to directory for CVS tagging.
 # \tr \td --debug         \td \td
 is_new_version=0
 
 vc_tag_directory=
+vc_tag_prefix=
 vc_do_tag=0
 vc_do_changelog=1
 cvs_check_vfile=1
 
+#for arg in ${1+"$@"}; do printf >&2 "arg: %s\n" "${arg}"; done # |:debug:|
+#set -x
+
 psep=
 while :; do
     test x"${1+set}" = xset || break;
         shift; version_directory="${1}";;
     -f|--f*) # --file
         shift; version_file="${1}";;
-    --t*) # --tag-directory
+    --tag-d*) # --tag-directory
         shift; vc_tag_directory="${1}";;
+    --tag-p*) # --tag-prefix
+        shift; vc_tag_prefix="${1}";;
     --de*) # --debug
         do_debug=1;;
 
     test -n "${VERSION_REL}" && VERSION="${VERSION}.${VERSION_REL}"
     test -n "${VERSION_PAT}" && VERSION="${VERSION}.${VERSION_PAT}"
 
-    VERSION_TAG="${PACKAGE_}_`echo "${VERSION}" | ${SED__PROG-sed} 's,\.,_,g'`"
+    VERSION_TAG="${PACKAGE_}_`echo "${VERSION}" | ${SED__PROG-sed} 's,\.,_,g'`" #`
     test ${vlength} -gt 3 && \
-    VERSION_TAG="`echo "${VERSION_TAG}" | ${SED__PROG-sed} 's,\_0$,,'`"
+    VERSION_TAG="`echo "${VERSION_TAG}" | ${SED__PROG-sed} 's,\_0$,,'`" #`
 
     ${CAT__PROG-cat} <<EOF
 VERSION="${VERSION}";
 {
     version="${VERSION}"
     test ${vlength} -gt 3 && \
-    version="`echo "${version}" | ${SED__PROG-sed} 's,\.0$,,'`"
+    version="`echo "${version}" | ${SED__PROG-sed} 's,\.0$,,'`" # `
     echo "echo '${version}'"
 }
 
 /* This file was automatically generated from genversion - DO NOT EDIT */
 /* @@prefix@@version.c - version information for @@Package@@
 
-   $Id: genversion.sh,v 1.1 2006/11/18 00:04:47 ws Exp $
+   $Id$
  */
 
+#if defined (HAVE_CONFIG_H)
+#include <config.h>
+#else  /* !defined (HAVE_CONFIG_H) */
 #if !defined (__attribute__)
 #define __attribute__(Spec) /* empty */
 #endif /* !defined (__attribute__) */
+#endif /* !defined (HAVE_CONFIG_H) */
 
 #if !defined (VERSION_FPRINTF)
 #define VERSION_FPRINTF fprintf
 #endif /* !defined (VERSION_OUTFILE) */
 
 #if !defined(lint) && defined(FEATURE_VCID)
-static char vcid[] __attribute__ ((unused)) = "$Id: genversion.sh,v 1.1 2006/11/18 00:04:47 ws Exp $";
+static char vcid[] __attribute__ ((unused)) = "$Id$";
 #endif /* !defined(lint) && defined(FEATURE_VCID) */
 
 /***
         print_c_source_template__ >zz-c-version.in
         print_c_source_template__ \
         | ${SED__PROG-sed} "${SED_SCRIPT_TEMPLATE_SUBST}" > zz-c-version.out
-        diff -ubB zz-c-version.in zz-c-version.out
+        ${DIFF_PROG-diff} -ubB zz-c-version.in zz-c-version.out
         rm -f zz-c-version.in zz-c-version.out
     fi # 0 or 1
 
         print_perl_source_template__ >zz-perl-version.in
         print_perl_source_template__ \
         | ${SED__PROG-sed} "${SED_SCRIPT_TEMPLATE_SUBST}" > zz-perl-version.out
-        diff -ubB zz-perl-version.in zz-perl-version.out
+        ${DIFF_PROG-diff} -ubB zz-perl-version.in zz-perl-version.out
         rm -f zz-perl-version.in zz-perl-version.out
     fi # 0 or 1
 
 vc_add ()
 {
     message="${1}"; shift
-    if test ${have_cvs} = 1
+    if test ${have_hg} = 1
     then
-	${CVS__PROG-cvs} >/dev/null add -m "${message}" ${1+"$@"}
-	${CVS__PROG-cvs} >/dev/null commit -m "Initial revision." ${1+"$@"}
+        ${HG___PROG-hg} >/dev/null add ${1+"$@"}
+#       ${HG___PROG-hg} >/dev/null commit  -m "${message}" ${1+"$@"}
+    elif test ${have_cvs} = 1
+    then
+        ${CVS__PROG-cvs} >/dev/null add -m "${message}" ${1+"$@"}
+        ${CVS__PROG-cvs} >/dev/null commit -m "Initial revision." ${1+"$@"}
     elif test ${have_rcs} = 1
     then
-	${CI___PROG-ci} >/dev/null -l -t-"${message}" -m"Initial revision." ${1+"$@"}
+        ${CI___PROG-ci} >/dev/null -l -t-"${message}" -m"Initial revision." ${1+"$@"}
     fi
 }
 
 vc_commit ()
 {
     message="${1}"; shift
-    if test ${have_cvs} = 1
+    if test ${have_hg} = 1
     then
-	${CVS__PROG-cvs} >/dev/null commit -m "${message}" ${1+"$@"}
+        ${HG___PROG-hg} >/dev/null commit -m "${message}" ${1+"$@"}
+    elif test ${have_cvs} = 1
+    then
+        ${CVS__PROG-cvs} >/dev/null commit -m "${message}" ${1+"$@"}
     elif test ${have_rcs} = 1
     then
-	if test x"${1+set}" = xset
-	then
-	    ${CI___PROG-ci} >/dev/null -l -m"${message}" ${1+"$@"}
-	else
-	    ${CI___PROG-ci} >/dev/null -l -m"${message}" \
-	    `${LS___PROG-ls} -1 RCS/.??* RCS/* 2>/dev/null`
-	fi
+        if test x"${1+set}" = xset
+        then
+            ${CI___PROG-ci} >/dev/null -l -m"${message}" ${1+"$@"}
+        else
+            ${CI___PROG-ci} >/dev/null -l -m"${message}" \
+            `${LS___PROG-ls} -1 RCS/.??* RCS/* 2>/dev/null`
+        fi
     fi
 }
 
 {
     rcode=0
     tag="${1}"; shift
-    if test ${have_cvs} = 1
+    if test ${have_hg} = 1
     then
-	${CVS__PROG-cvs} >/dev/null tag -c -F "${tag}" ${1+"$@"}
+        local_changes="`${HG___PROG-hg} status -q`"
+        if test -n "${local_changes}"
+        then
+            echo >&2 "# There are uncommitted changes. correct first."
+            rcode=1
+        else
+            # hg cannot tag single files ${1+"$@"}
+            ${HG___PROG-hg} >/dev/null tag --force "${tag}"
+            rcode="${?}"
+        fi
+    elif test ${have_cvs} = 1
+    then
+        ${CVS__PROG-cvs} >/dev/null tag -c -F "${tag}" ${1+"$@"}
         rcode="${?}"
     elif test ${have_rcs} = 1
     then
-	if test x"${1+set}" = xset
-	then
+        if test x"${1+set}" = xset
+        then
             if ${RCSDIFFPROG-rcsdiff} -q -u ${1+"$@"}
             then
                 ${RCS__PROG-rcs} >/dev/null -N"${tag}": ${1+"$@"}
                 echo >&2 "There are uncommitted changes. correct first."
                 rcode=1
             fi
-	else
+        else
 
             find . -name '*,v' -print | sed -e 's,/RCS/,/,' -e 's/,v$//' | sort \
             | (
                 echo >&2 "# There are uncommitted changes. correct first."
                 rcode=1
             fi
-	fi
+        fi
     fi
     return "${rcode}"
 }
 
 # --------------------------------------------------
+# Generate awk(1) script for clean_change_log_hg
+#
+#!   VAR="`awk_script_clean_change_log_hg`"
+awk_script_clean_change_log_hg ()
+{
+    cat <<'__AWK__'
+BEGIN {
+    in_set = 0;
+    in_hdr = 0;
+    chk_dsc = 0;
+}
+{
+    print $0;
+    next;
+}
+!in_hdr && /^[^:]*changeset:   [0-9]+:[0-9a-f]+$/ {
+    if ( in_set ) {
+        printf ( "%s", cset );
+    }
+    cset = $0 "\n";
+    in_set = 1;
+    in_hdr = 1;
+    chk_dsc = 0;
+    next;
+}
+!in_set {
+    next;
+}
+in_hdr && match( $0, /^[^:]*files:       \.hgtags$/ ) {
+    in_set = 0;
+    in_hdr = 0;
+    next;
+}
+in_hdr && match( $0, /^[^:]*description:$/ ) {
+    in_hdr = 0;
+    chk_dsc = 1;
+    next;
+}
+chk_dsc {
+    chk_dsc = 0;
+    if ( match( $0, /^[-+@o|/\\ \t\r]*\#/ )) {
+        in_set = 0;
+        next;
+    }
+}
+{
+    cset = cset $0 "\n";
+}
+END {
+    if ( in_set ) {
+        printf ( "%s", cset );
+    }
+}
+__AWK__
+}
+AWK_SCRIPT_CLEAN_CHANGE_LOG_HG="`awk_script_clean_change_log_hg`"
+
+# --------------------------------------------------
+#
+#
+#!   clean_change_log_hg
+clean_change_log_hg ()
+{
+    ${AWK__PROG-awk} "${AWK_SCRIPT_CLEAN_CHANGE_LOG_HG}" ${1+"$@"}
+}
+
+# --------------------------------------------------
 #!   awk [ -vclfile="ChangeLog" ] "`awk_script_clean_changelog`"
 awk_script_clean_changelog ()
 {
     (
     clfile="${1-}"
     test -n "${clfile}" && test -r "${clfile}" || exit 1
-    if ${AWK__PROG-awk} -vclfile="${clfile}" "${AWK_SCRIPT_CLEAN_CHANGELOG}" "${clfile}" >"${clfile}".n
+    ccl_script="${AWK_SCRIPT_CLEAN_CHANGELOG}"
+    test ${have_hg} = 1 && ccl_script="${AWK_SCRIPT_CLEAN_CHANGE_LOG_HG}"
+    if ${AWK__PROG-awk} -vclfile="${clfile}" "${ccl_script}" "${clfile}" >"${clfile}".n
     then
-	${RM___PROG-rm} -f "${clfile}"
-	${MV___PROG-mv} "${clfile}".n "${clfile}"
+	if test -s "${clfile}".n
+	then
+            ${RM___PROG-rm} -f "${clfile}"
+            ${MV___PROG-mv} "${clfile}".n "${clfile}"
+	fi
+        ${RM___PROG-rm} -f "${clfile}".n
     fi
     )
 }
 
 # speed up sort
 unset LANG
+unset LANGUAGE
 unset LC_CTYPE
 
 # Set directories
 
 # Version control setup
 have_vc=0
+have_hg=0
 have_cvs=0
 have_rcs=0
 
-if test -d CVS
+if test -d .hg
+then
+    have_hg=1
+    cvs_check_vfile=0
+elif test -d CVS
 then
     have_cvs=1
     test x"${1+set}" = xset && cvs_check_vfile=0
     test -d RCS && have_rcs=1
 fi
 
-( test ${have_cvs} = 1 || test ${have_rcs} = 1 ) && have_vc=1
+( test ${have_hg} = 1 || test ${have_cvs} = 1 || test ${have_rcs} = 1 ) && have_vc=1
 
 # CVS update for version file
 if test ${cvs_check_vfile} = 1
 fi
 
 # Setup package name
-Package=""
-test -r .package && Package="`${CAT__PROG-cat} .package`"
+Package="${vc_tag_prefix}"
+test -z "${Package}" && test -r .package && Package="`${CAT__PROG-cat} .package`"
+test -z "${Package}" && Package="${PACKAGE-}"
 test -z "${Package}" && Package="`basename "\`pwd\`"`"
 test -z "${Package}" && Package="Version"
 
 done
 
 # Version control tagging
-if test ${vc_do_tag} = 1
+if test ${have_hg} = 1 && ( test ${is_new_version} = 1 || test ${vc_do_tag} = 1 )
 then
+    # HG
     if ( cd ${vc_tag_directory} || exit 1
-	 vc_tag "${VERSION_TAG}" )
+        local_changes="`${HG___PROG-hg} status -q`"
+        if test -n "${local_changes}"
+        then
+            echo >&2 "# There are uncommitted changes. correct first."
+            exit 1
+        fi )
     then
         : # everything OK.
     else
         exit 1;
     fi
-fi
 
-# New version and/or ChangeLog
-if ( test ${is_new_version} = 1 || test ${vc_do_tag} = 1 )
-then
-    version_files=
+    vc_do_commit=0
     if test ${is_new_version} = 1
     then
-	rm -f "${version_file}"	# win32 NTFS/cygwin does not let us redirect to .files
-	echo "${VERSION}" >"${version_file}"
-	version_files="${version_file}"
+        add_version=0
+        if test -r "${version_file}"
+        then
+            : # Got a .version
+        else
+            cat /dev/null >.version
+            vc_add 'Version information file.' "${version_file}"
+	    vc_do_commit=1
+        fi
+        rm -f "${version_file}" # win32 NTFS/cygwin does not let us redirect to .files
+        echo "${VERSION}" >"${version_file}"
+#        vc_commit "* New release ${VERSION_TAG}"
     fi
 
     if test ${vc_do_changelog} = 1
     then
-	if test -r ChangeLog
-	then
-	    : # Got a ChangeLog
-	else
-	    cat /dev/null >ChangeLog
-	    vc_add 'Version information file.' ChangeLog
-	fi
-	version_files="${version_files} ChangeLog"
+        if test -r ChangeLog
+        then
+            : # Got a ChangeLog
+        else
+            cat /dev/null >ChangeLog
+            vc_add 'Version information file.' ChangeLog
+	    vc_do_commit=1
+        fi
+
+        ${HG___PROG-hg} -v glog >ChangeLog.new
+        rcode="${?}"
+
+        if test x"${rcode}" = x0; then
+            clean_changelog ChangeLog.new
+            if ${CMP__PROG} ChangeLog ChangeLog.new >/dev/null 2>&1
+            then
+                :
+            else
+                mv ChangeLog.new ChangeLog
+		vc_do_commit=1
+            fi
+        fi
+        rm -f ChangeLog.new
     fi
 
-    if test ${is_new_version} = 1
+    if test ${vc_do_commit} = 1
     then
-	vc_commit "* New release ${VERSION_TAG}" "${version_file}"
+        vc_commit "#version files updated."
     fi
 
-    if test ${vc_do_changelog} = 1
+    if ( cd ${vc_tag_directory} || exit 1
+        vc_tag "${VERSION_TAG}" )
     then
-	if ${RCS2LOG-rcs2log} -R -c /dev/null >ChangeLog.new; then
-	    clean_changelog ChangeLog.new
-            if cmp ChangeLog ChangeLog.new &>/dev/null
+        : # everything OK.
+    else
+        exit 1;
+    fi
+else
+    # CVS/RCS
+    if test ${vc_do_tag} = 1
+    then
+        if ( cd ${vc_tag_directory} || exit 1
+             vc_tag "${VERSION_TAG}" )
+        then
+            : # everything OK.
+        else
+            exit 1;
+        fi
+    fi
+
+    # New version and/or ChangeLog
+    if ( test ${is_new_version} = 1 || test ${vc_do_tag} = 1 )
+    then
+        version_files=
+        if test ${is_new_version} = 1
+        then
+            rm -f "${version_file}"     # win32 NTFS/cygwin does not let us redirect to .files
+            echo "${VERSION}" >"${version_file}"
+            version_files="${version_file}"
+        fi
+
+        if test ${vc_do_changelog} = 1
+        then
+            if test -r ChangeLog
             then
+                : # Got a ChangeLog
+            else
+                cat /dev/null >ChangeLog
+                vc_add 'Version information file.' ChangeLog
+            fi
+            version_files="${version_files} ChangeLog"
+        fi
+
+        if test ${is_new_version} = 1
+        then
+            vc_commit "* New release ${VERSION_TAG}" "${version_file}"
+        fi
+
+        if test ${vc_do_changelog} = 1
+        then
+            if test ${have_hg} = 1
+            then
+                hg -v glog >ChangeLog.new
+                rcode="${?}"
+            else
+                ${RCS2LOG-rcs2log} -R -c /dev/null >ChangeLog.new
+                rcode="${?}"
+            fi
+            if test x"${rcode}" = x0; then
+                clean_changelog ChangeLog.new
+                if ${CMP__PROG-cmp} ChangeLog ChangeLog.new >/dev/null 2>&1
+                then
+                    rm -f ChangeLog.new
+                    vc_do_changelog=0
+                else
+                    mv ChangeLog.new ChangeLog
+                    vc_commit "#updated." ChangeLog
+                fi
+            else
                 rm -f ChangeLog.new
                 vc_do_changelog=0
-            else
-                mv ChangeLog.new ChangeLog
-                vc_commit "#updated." ChangeLog
             fi
-	else
-	    rm -f ChangeLog.new
-            vc_do_changelog=0
-	fi
-    fi
+        fi
 
-    if test ${is_new_version} = 1 || test ${vc_do_changelog} = 1
-    then
-	vc_tag "${VERSION_TAG}" ${version_files}
+        if test ${is_new_version} = 1 || test ${vc_do_changelog} = 1
+        then
+            vc_tag "${VERSION_TAG}" ${version_files}
+        fi
     fi
 fi
 
 
 # \h1 ENVIRONMENT
 # \table
-# \tr \td AWK__PROG \td the <c,awk,(1) program to use
-# \tr \td FIND_PROG \td the <c,find,(1) program to use
-# \tr \td GREP_PROG \td the <c,grep,(1) program to use
-# \tr \td GZIP_PROG \td the <c,gzip,(1) program to use
-# \tr \td SED__PROG \td the <c,sed,(1) program to use
-# \tr \td TAR__PROG \td the <c,tar,(1) program to use
-# \tr \td TR___PROG \td the <c,tr,(1) program to use
+# \tr \td AWK__PROG   \td the <c,awk,(1) program to use
+# \tr \td CAT__PROG   \td the <c,cat,(1) program to use
+# \tr \td CI___PROG   \td the <c,ci,(1) program to use
+# \tr \td CMP__PROG   \td the <c,cmp,(1) program to use
+# \tr \td CVS__PROG   \td the <c,cvs,(1) program to use
+# \tr \td DIFF_PROG   \td the <c,diff,(1) program to use
+# \tr \td HG___PROG   \td the <c,hg,(1) program to use
+# \tr \td LS___PROG   \td the <c,ls,(1) program to use
+# \tr \td MV___PROG   \td the <c,mv,(1) program to use
+# \tr \td RCSDIFFPROG \td the <c,rcsdiff,(1) program to use
+# \tr \td RCS__PROG   \td the <c,rcs,(1) program to use
+# \tr \td RM__PROG    \td the <c,rm,(1) program to use
+# \tr \td SED__PROG   \td the <c,sed,(1) program to use
+# \tr \td TR___PROG   \td the <c,tr,(1) program to use
 # \table
 
 # \h1 VERSION
-# $Id: genversion.sh,v 1.1 2006/11/18 00:04:47 ws Exp $
+# $Id$
 
 # Generated by .stpl 1.37 2001/03/25 01:40:09
 # --only-man--
 # mode: docu-minor
 # comment-start-skip: "#+ ?"
 # outline-regexp: "##+ "
-# mmm-classes: (here-doc)
 # mode: mmm
 # End:
+# mmm-classes: (here-doc)