Commits

dak180 committed c609b5a

Update the version of autorevision used.

Refs #3765.

  • Participants
  • Parent commits e8c7ff6

Comments (0)

Files changed (1)

File build_tools/autorevision

 	esac
 done
 
-if [[ ! -z "${VAROUT}"  ]] && [[ ! -z "${AFILETYPE}" ]]; then
+if [[ ! -z "${VAROUT}" ]] && [[ ! -z "${AFILETYPE}" ]]; then
 	# If both -s and -t are specified:
 	echo "error: Improper argument combination." 1>&2
 	exit 1
-elif [[ -z "${VAROUT}"  ]] && [[ -z "${AFILETYPE}" ]]; then
+elif [[ -z "${VAROUT}" ]] && [[ -z "${AFILETYPE}" ]]; then
 	# If neither -s or -t are specified:
 	arUsage
-elif [[ -z "${CACHEFILE}"  ]] && [[ "${CACHEFORCE}" = "1" ]]; then
+elif [[ -z "${CACHEFILE}" ]] && [[ "${CACHEFORCE}" = "1" ]]; then
 	# If -f is specified without -o:
 	arUsage
 fi
 	VCS_DATE="$(hg log -r "${VCS_NUM}" -l 1 --template '{date|isodatesec}\n' 2>/dev/null | sed -e 's: :T:' | sed -e 's: ::')"
 }
 
+# For bzr repos
+function bzrRepo {
+	cd "$(bzr root)"
+
+	VCS_TYPE="bzr"
+
+	VCS_BASENAME="$(basename "${PWD}")"
+
+	# Is the working copy clean?
+	bzr version-info --custom --template='{clean}\n' | grep -q '1'
+	VCS_WC_MODIFIED="${?}"
+
+	# Enumeration of changesets
+	VCS_NUM="$(bzr revno)"
+
+	# The full revision hash
+	VCS_FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')"
+
+	# The short hash
+	VCS_SHORT_HASH="$VCS_NUM"
+
+	# Nick of the current branch
+	VCS_BRANCH="$(bzr nick)"
+
+	# Current or last tag ancestor (excluding auto tags, empty if no tags)
+	VCS_TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)"
+
+	# Distance to last tag or an alias of VCS_NUM if there is no tag
+	if [[ ! -z "${VCS_TAG}" ]]; then
+		VCS_TICK="$(bzr log --line -r "tag:${VCS_TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')"
+	else
+		VCS_TICK="${VCS_NUM}"
+	fi
+
+	# Date of the current commit
+	VCS_DATE="$(bzr version-info --custom --template='{date}\n' | sed -e 's: :T:' | sed -e 's: ::')"
+}
+
 # For svn repos
 function svnRepo {
 	VCS_TYPE="svn"
 	SVNVERSION="$(svnversion)"
 
 	# Is the working copy clean?
-    echo "${SVNVERSION}" | grep -vq "M"
-	VCS_WC_MODIFIED="${?}"
+	echo "${SVNVERSION}" | grep -q "M"
+	case "${?}" in
+		0) VCS_WC_MODIFIED="1";;
+		1) VCS_WC_MODIFIED="0";;
+	esac
 
 	# Enumeration of changesets
 	VCS_NUM="$(echo "${SVNVERSION}" | cut -d : -f 1 | sed -e 's:M::' -e 's:S::' -e 's:P::')"
 		fn="${PWD}"
 		while :
 		do
-		    base="$(basename "${fn}")"
-		    if [[ "$base" = 'trunk' ]]; then
+			base="$(basename "${fn}")"
+			if [[ "$base" = 'trunk' ]]; then
 				VCS_BRANCH='trunk'
 				break
-		    elif [[ "${base}" = 'branches' ]] || [[ "${base}" = 'tags' ]]; then
+			elif [[ "${base}" = 'branches' ]] || [[ "${base}" = 'tags' ]]; then
 				VCS_BRANCH="${lastbase}"
 				break
-		    elif [[ "${base}" = '/' ]]; then
+			elif [[ "${base}" = '/' ]]; then
 				VCS_BRANCH=""
 				break
-		    fi
-		    lastbase="${base}"
-		    fn="$(dirname "${fn}")"
+			fi
+			lastbase="${base}"
+			fn="$(dirname "${fn}")"
 		done
 		;;
 	*) VCS_BRANCH="" ;;
 # Functions to output data in different formats.
 # For header output
 function hOutput {
-	case "${VCS_WC_MODIFIED}" in
-		1) VCS_WC_MODIFIED='true' ;;
-		0) VCS_WC_MODIFIED='false' ;;
-	esac
 	cat > "${TARGETFILE}" << EOF
 /* Generated by autorevision - do not hand-hack! */
 #ifndef AUTOREVISION_H
 if [[ -f "${CACHEFILE}" ]] && [[ "${CACHEFORCE}" = "1" ]]; then
 	# When requested only read from the cache to populate our symbols.
 	source "${CACHEFILE}"
-elif [[ -d .git ]] && [[ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]]; then
+elif [[ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]]; then
 	gitRepo
-elif [[ -d .hg ]] && [[ ! -z "$(hg root 2>/dev/null)" ]]; then
+elif [[ ! -z "$(hg root 2>/dev/null)" ]]; then
 	hgRepo
-elif [[ -d .svn ]] && [[ ! -z "$(svn info 2>/dev/null)" ]]; then
+elif [[ ! -z "$(bzr root 2>/dev/null)" ]]; then
+	bzrRepo
+elif [[ ! -z "$(svn info 2>/dev/null)" ]]; then
 	svnRepo
 elif [[ -f "${CACHEFILE}" ]]; then
 	# We are not in a repo; try to use a previously generated cache to populate our symbols.