diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/vc/hg-windows |
Initial commit
Diffstat (limited to 'support/vc/hg-windows')
-rw-r--r-- | support/vc/hg-windows/vc-hg.awk | 75 | ||||
-rw-r--r-- | support/vc/hg-windows/vc.bat | 25 |
2 files changed, 100 insertions, 0 deletions
diff --git a/support/vc/hg-windows/vc-hg.awk b/support/vc/hg-windows/vc-hg.awk new file mode 100644 index 0000000000..077d2ed90d --- /dev/null +++ b/support/vc/hg-windows/vc-hg.awk @@ -0,0 +1,75 @@ +# This is file 'vc-hg.awk' from the vc bundle for TeX. +# The original file can be found at CTAN:support/vc. +# This file is Public Domain. + +BEGIN { + modified = 0 +} + +### Process output of "hg log" +script=="log" && /^Hash:/ { Hash = substr($0, 2+match($0, ":")) } +script=="log" && /^Abr. Hash:/ { AbrHash = substr($0, 2+match($0, ":")) } +script=="log" && /^Branch:/ { Branch = substr($0, 2+match($0, ":")) } +script=="log" && /^Parent1 Hash:/ { Parent1Hash = substr($0, 2+match($0, ":")) } +script=="log" && /^Parent2 Hash:/ { Parent2Hash = substr($0, 2+match($0, ":")) } +script=="log" && /^Abr. Parent1 Hash:/ { AbrParent1Hash = substr($0, 2+match($0, ":")) } +script=="log" && /^Abr. Parent2 Hash:/ { AbrParent2Hash = substr($0, 2+match($0, ":")) } +script=="log" && /^Author Name:/ { AuthorName = substr($0, 2+match($0, ":")) } +script=="log" && /^Author Email:/ { AuthorEmail = substr($0, 2+match($0, ":")) } +script=="log" && /^Author Date:/ { AuthorDate = substr($0, 2+match($0, ":")) } + +### Process output of "hg status" +script=="status" && /^M / { modified = 1 } + +END { + ### Process output of "hg log" + if (script=="log") { + ### Format dates + LongDate = substr(AuthorDate, 1, 25) + DateRAW = substr(LongDate, 1, 10) + DateISO = DateRAW + DateTEX = DateISO + gsub("-", "/", DateTEX) + Time = substr(LongDate, 12, 14) + + print "%%% This file has been generated by the vc bundle for TeX." + print "%%% Do not edit this file!" + print "%%%" + + print "%%% Define HG specific macros." + print "\\gdef\\HGHash{" Hash "}%" + print "\\gdef\\HGAbrHash{" AbrHash "}%" + print "\\gdef\\HGBranch{" Branch "}%" + print "\\gdef\\HGFirstParentHash{" Parent1Hash "}%" + print "\\gdef\\HGSecondParentHash{" Parent2Hash "}%" + print "\\gdef\\HGAbrFirstParentHash{" AbrParent1Hash "}%" + print "\\gdef\\HGAbrSecondParentHash{" AbrParent2Hash "}%" + print "\\gdef\\HGAuthorName{" AuthorName "}%" + print "\\gdef\\HGAuthorEmail{" AuthorEmail "}%" + print "\\gdef\\HGAuthorDate{" AuthorDate "}%" + + print "%%% Define generic version control macros." + print "\\gdef\\VCRevision{\\HGAbrHash}%" + print "\\gdef\\VCAuthor{\\HGAuthorName}%" + print "\\gdef\\VCDateRAW{" DateRAW "}%" + print "\\gdef\\VCDateISO{" DateISO "}%" + print "\\gdef\\VCDateTEX{" DateTEX "}%" + print "\\gdef\\VCTime{" Time "}%" + print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%" + + print "%%% Assume clean working copy." + print "\\gdef\\VCModified{0}%" + print "\\gdef\\VCRevisionMod{\\VCRevision}%" + } + + ### Process output of "hg status" + if (script=="status") { + print "%%% Is working copy modified?" + print "\\gdef\\VCModified{" modified "}%" + if (modified==0) { + print "\\gdef\\VCRevisionMod{\\VCRevision}%" + } else { + print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%" + } + } +} diff --git a/support/vc/hg-windows/vc.bat b/support/vc/hg-windows/vc.bat new file mode 100644 index 0000000000..affb891d25 --- /dev/null +++ b/support/vc/hg-windows/vc.bat @@ -0,0 +1,25 @@ +@echo off +REM This is file 'vc.bat' from the vc bundle for TeX. +REM The original file can be found at CTAN:support/vc. +REM This file is Public Domain. + +setlocal +REM Parse command line options. +set mod=0 +:loopParams +if "%1" NEQ "" ( + if "%1"=="-m" (set mod=1) else ( + echo usage: vc [-m] + exit /b 1 + ) + shift + goto loopParams +) +REM English locale. +set LC_ALL=C + +hg log --pager=off -r . --template "Hash: {node}\nAbr. Hash: {node|short}\nBranch: {branch}\nParent1 Hash: {p1node}\nParent2 Hash: {p2node}\nAbr. Parent1 Hash: {p1node|short}\nAbr. Parent2 Hash: {p2node|short}\nAuthor Name: {author|user}\nAuthor Email: {author|email}\nAuthor Date: {date|isodatesec}" | gawk -v script=log -f vc-hg.awk > vc.tex + +if "%mod%"=="1" ( + hg status --pager=off | gawk -v script=status -f vc-hg.awk >> vc.tex +) |