summaryrefslogtreecommitdiff
path: root/support/vc/bzr-unix/vc-bzr.awk
blob: cec1628f4bbd9770af441be33e6a80b001d57ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# This is file 'vc-bzr.awk' from the vc bundle for TeX.
# The original file can be found at CTAN:support/vc.
# This file is Public Domain.
BEGIN {
### Assume clean working copy.
		Clean = "True"
}
/^revision-id:/ { RevisionId = substr($0, 2+match($0, ":")) }
/^date:/ { Date = substr($0, 2+match($0, ":")) }
/^build-date:/ { BuildDate = substr($0, 2+match($0, ":")) }
/^revno:/ { RevNo = substr($0, 2+match($0, ":")) }
/^branch-nick:/ { BranchNick = substr($0, 2+match($0, ":")) }
/^clean:/ { Clean = substr($0, 2+match($0, ":")) }
END {
### Extract relevant information from variables.
		elements = split(RevisionId, elem, "-")
		Author = elem[1]
		for (i=2; i<elements-2; i++) {
				Author = Author "-" elem[i]
		}
    LongDate = substr(Date, 1, 25)
    DateRAW = substr(LongDate, 1, 10)
    DateISO = DateRAW
    DateTEX = DateISO
    gsub("-", "/", DateTEX)
    Time = substr(LongDate, 12, 14)
		if (Clean=="True") {
				modified = 0
		} else {
				modified = 1
		}
### Write file identification to vc.tex.
		print "%%% This file has been generated by the vc bundle for TeX."
		print "%%% Do not edit this file!"
		print "%%%"
### Write Bazaar specific macros.
    print "%%% Define Bazaar specific macros."
    print "\\gdef\\BZRRevisionId{" RevisionId "}%"
    print "\\gdef\\BZRDate{" Date "}%"
    print "\\gdef\\BZRBuildDate{" BuildDate "}%"
    print "\\gdef\\BZRRevNo{" RevNo "}%"
		if (full==1) {
				print "\\gdef\\BZRBranchNick{" BranchNick "}%"
		}
### Write generic version control macros.
    print "%%% Define generic version control macros."
    print "\\gdef\\VCRevision{\\BZRRevNo}%"
    print "\\gdef\\VCAuthor{" Author "}%"
    print "\\gdef\\VCDateRAW{" DateRAW "}%"
    print "\\gdef\\VCDateISO{" DateISO "}%"
    print "\\gdef\\VCDateTEX{" DateTEX "}%"
    print "\\gdef\\VCTime{" Time "}%"
    print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%"
### Is working copy modified?
    print "%%% Is working copy modified?"
    print "\\gdef\\VCModified{" modified "}%"
		if (modified==0) {
				print "\\gdef\\VCRevisionMod{\\VCRevision}%"
		} else {
				print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%"
		}
}