revno and commit_date in app code
george young
gry at ll.mit.edu
Tue Sep 27 19:21:54 BST 2005
[bzr-0.0.9, linux]
I'm starting to use bzr for my main application (in python).
One thing that I need, somehow, is for an installed instance of
the app to know it's rev_no, and if possible, also it's commit date and
committer. I used to do this in CVS with the imbedded keyword values:
cvs_rev = '$Revision: 1.1.1.1 $'[11:-2]
cvs_date = '$Date: 2004/03/05 18:19:33 $'[7:-2]
cvs_author = '$Author: geoyou $'[9:-2]
My current bzr hack is this script(kludged from show_info.py), run by make:
#!/usr/bin/env python2.4
import bzrlib.branch
branch = bzrlib.branch.Branch.open_containing(None)
rev_no = branch.revno()
rev = branch.get_revision(branch.revision_history()[-1])
rev_timestamp = rev.timestamp
print 'import datetime\n' \
'rev_no = %s\n' \
'rev_date = datetime.datetime.fromtimestamp(%d)' % (rev_no, rev_timestamp)
Make install runs "bzr_get_rev_info.py >rev_info.py", and
the app imports the resultant module. Of course, rev_info.py can not
be part of the bzr revision, because it can only be created after the commit.
Is there some cleaner, more stable way to do this? I could spend some time
hacking bzr, if someone would suggest a useful path for me that's not too
laborious. Is anyone working on or thinking about cvs-like keywords, or
commit trigger hooks? Any comments, raves, criticisms are welcome.
-- George
--
"Are the gods not just?" "Oh no, child.
What would become of us if they were?" (CSL)
More information about the bazaar
mailing list