updaterevision/updaterevision.py

changeset 2
8be472cb0bca
parent 1
4dd5bde4e777
child 77
32ef969adeed
equal deleted inserted replaced
1:4dd5bde4e777 2:8be472cb0bca
57 rev = rev[0:7] 57 rev = rev[0:7]
58 58
59 if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+': 59 if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+':
60 rev += '+' 60 rev += '+'
61 61
62 if branch != 'default':
63 rev += '-%s' % branch
64
65 if rev == oldrev: 62 if rev == oldrev:
66 print "%s is up to date at %s" % (sys.argv[1], rev) 63 print "%s is up to date at %s" % (sys.argv[1], rev)
67 quit (0) 64 quit (0)
68 65
69 with open (sys.argv[1], 'w') as fp: 66 with open (sys.argv[1], 'w') as fp:
70 fp.write ('// %s\n' % rev) 67 fp.write ('// %s\n' % rev)
71 fp.write ('#define REVISION_STRING "%s"\n' % rev) 68 fp.write ('#define HG_NODE "%s"\n' % rev)
72 fp.write ('#define REVISION_DATE "%s"\n' % datestring) 69 fp.write ('#define HG_BRANCH "%s"\n' % branch)
73 fp.write ('#define REVISION_DISPLAY_DATE "%s"\n' % date.strftime ('%d %b %Y')) 70 fp.write ('#define HG_DATE_VERSION "%s"\n' % datestring)
74 fp.write ('#define REVISION_TIME %d\n' % int (timestamp)) 71 fp.write ('#define HG_DATE_STRING "%s"\n' % date.strftime ('%d %b %Y'))
72 fp.write ('#define HG_DATE_TIME %d\n' % int (timestamp))
75 print '%s updated to %s' % (sys.argv[1], rev) 73 print '%s updated to %s' % (sys.argv[1], rev)

mercurial