[texhax] TeX support in Autorevision

Joel C. Salomon joelcsalomon at gmail.com
Sun Dec 9 20:24:59 CET 2012


I've added TeX support to Autorevision
(https://github.com/Autorevision/autorevision) and thought folks here
might like to know about this.

Autorevision works similarly to <http://ctan.org/pkg/gitinfo>,
<http://ctan.org/pkg/rcs>, and others, except it supports multiple
repository types (git, hg, svn, and bzr) and multiple languages.

At some point (either in a Makefile or in a checkout hook), run the command

    autorevision -t tex > ar.tex

This produces a file which you can \include{} in your document, and
defines the following macros:

\vcsType
The repository type - "git", "hg", or "svn".

\vcsBasename
The basename of the directory root. For most VCSes this will simply be
the basename of the repository root directory. For Subversion,
autorevision will navigate up though trunk, branches, and tags
directories to find the actual root.

\vcsNum
A count of revisions between the current one and the initial one;
useful for reporting build numbers.

\vcsDate
The date of the most recent commit in true ISO-8601/RFC3339 format,
including seconds.

\vcsBranch
The name of the branch of the commit graph that was selected when
autoversion was run. Under Subversion this will normally be either
trunk or the basename of some branch or tag subdirectory, depending on
where autoversion was run. Under git, this will normally be the
shortname of the current branch (the asterisked line in the output of
of "git branch") except that when the branch doesn’t have a shortname
it will be a full refspec. Under hg the feature that is called
branches is actually a sort of graph coloring (multiple heads can have
the same branch name) so this variable is filled with the current
bookmark if it exists, with the current branch name as a fallback.
Under bzr, this is the nick of the branch you are on.

\vcsTag
The name of the most recent tag ancestral to the current commit. Empty
under Subversion.

\vcsTick
A count of commits since most recent tag ancestral to the current
commit or an alias of vcs_num if there are no prior tags. Empty under
Subversion.

\vcsFullHash
A full unique identifier for the current revision.

\vcsShortHash
A shortened version of \vcsFullHash, but \vcsFullHash if it cannot be shortened.

\vcsWcModified
Set to "true" if the current working directory has been modified and
"false" if not.
[The original documentation says: Set to 1 if the current working
directory has been modified and 0 if not. If the output language is
interpreted and has native Boolean literals, true will mean modified
and false unmodified.]

The generated file is about as simple as can be: a sequence of lines of the form

    \def \vcsType {<type>}

I’m not so excited about my choice of "true" and "false" for
\vcsWcModified, but don’t see a good choice for boolean values outside
Expl3 mode. Perhaps this should be a \newif\vcsIfWcModified ?
Suggestions welcome.

—Joel Salomon



More information about the texhax mailing list