Any good way to get build numbers?

2 views
Skip to first unread message

Edward K. Ream

unread,
Jul 17, 2009, 2:58:47 PM7/17/09
to leo-editor
Rev 2245 of the trunk contains code that uses leoVersion.py to
determine signons.

I have spent all day messing with signons. It's amazingly
complicated. Details omitted.

In the process, I stumbled across the fact that build numbers are not
being updated. The old code relied on the cvs $Revision field, but
bzr doesn't update that. That doesn't seem surprising given the
differences between bzr and cvs.

Is there any meaningful build number that Leo could report? We
mustn't assume that bzr is available, or rather, we must assume that
bzr will not be available.

Edward

Ville M. Vainio

unread,
Jul 17, 2009, 3:07:32 PM7/17/09
to leo-e...@googlegroups.com
On Fri, Jul 17, 2009 at 9:58 PM, Edward K. Ream<edre...@gmail.com> wrote:

> In the process, I stumbled across the fact that build numbers are not
> being updated.  The old code relied on the cvs $Revision field, but
> bzr doesn't update that.  That doesn't seem surprising given the
> differences between bzr and cvs.

Every time you do a build, you could run "bzr version-info" and put
the output in a file. E.g., for doing the bzr snapshots of the debs, I
run the following ileo script:

verinfo= !bzr version-info
bzr_revno = verinfo.grep('revno').fields(1)[0]

--
Ville M. Vainio
http://tinyurl.com/vainio

Edward K. Ream

unread,
Jul 17, 2009, 3:21:52 PM7/17/09
to leo-e...@googlegroups.com
On Fri, Jul 17, 2009 at 2:07 PM, Ville M. Vainio <viva...@gmail.com> wrote:

Every time you do a build, you could run "bzr version-info" and put
the output in a file. E.g., for doing the bzr snapshots of the debs, I
run the following ileo script:

verinfo= !bzr version-info
bzr_revno = verinfo.grep('revno').fields(1)[0]

Thanks for this tip.

Edward

Edward K. Ream

unread,
Jul 19, 2009, 2:31:07 PM7/19/09
to leo-e...@googlegroups.com

An easier way to print the revision is simply bzr revno.

This is an interesting puzzle.  I just verified that the hook described at:
http://doc.bazaar-vcs.org/latest/en/user-guide/index.html#using-hooks
works.  Here it is:
QQQ
from bzrlib import branch

def post_push_hook(push_result):
print "The new revno is %d" % push_result.new_revno

branch.Branch.hooks.install_named_hook(
'post_push', post_push_hook,
'My post_push hook')
QQQ
What I'd like is to have the script alter the revision number in leoVersion.py, but I'd settle for altering a revision number in, say, leoVersion.txt.  The trick is to determine the path to the proper leoVersion.txt inside this plugin.

There doesn't seem to be much documentation for push_result.  I could have read the source code, but instead I added the following to the plugin:

    for z in dir(push_result):
        print z,repr(getattr(push_result,z))

And got the following (deleting uninteresting items):

QQQ
local_branch None
master_branch BzrBranch6('file:///C:/leo.repo/trunk/')
new_revid 'edre...@gmail.com-20090719181929-jw2w8vq59k453qt3'
new_revno 2255
old_revid 'edre...@gmail.com-20090719181842-w0s49lt0jaefh0gx'
old_revno 2254
source_branch BzrBranch6('file:///C:/leo.repo/test-branch/')
tag_conflicts []
target_branch BzrBranch6('file:///C:/leo.repo/trunk/')
QQQ

So there we have it: push_result.source_branch is the path to the branch. From this we can compute the path to branch/leo/core/leoVersion.txt.  Coming soon...

Edward

Edward K. Ream

unread,
Jul 19, 2009, 2:32:32 PM7/19/09
to leo-e...@googlegroups.com
On Sun, Jul 19, 2009 at 1:31 PM, Edward K. Ream <edre...@gmail.com> wrote:
 
What I'd like is to have the script alter the revision number in leoVersion.py, but I'd settle for altering a revision number in, say, leoVersion.txt.

I guess leoVersion.txt had better be bzr ignored...

EKR

Ville M. Vainio

unread,
Jul 19, 2009, 3:14:28 PM7/19/09
to leo-e...@googlegroups.com
On Sun, Jul 19, 2009 at 9:31 PM, Edward K. Ream<edre...@gmail.com> wrote:

> An easier way to print the revision is simply bzr revno.

Ah, I had missed it.

One thing to investigate might be this:

http://bazaar-vcs.org/KeywordExpansion

Edward K. Ream

unread,
Jul 19, 2009, 3:42:48 PM7/19/09
to leo-e...@googlegroups.com

Maybe not.  It has to be part of the repository for leoVersion.py to work.

I'm not sure whether continually updating leoVersion.txt is going to cause a problem with merges...

Edward

Ville M. Vainio

unread,
Jul 19, 2009, 3:45:03 PM7/19/09
to leo-e...@googlegroups.com
On Sun, Jul 19, 2009 at 10:42 PM, Edward K. Ream<edre...@gmail.com> wrote:

> I'm not sure whether continually updating leoVersion.txt is going to cause a
> problem with merges...

I still think you should upgrade it occasionally by a script. If the
nightly tarball thing is using bzr (well, it pretty much has to ;-),
it can update it as well.

Edward K. Ream

unread,
Jul 19, 2009, 5:12:40 PM7/19/09
to leo-e...@googlegroups.com
On Sun, Jul 19, 2009 at 2:45 PM, Ville M. Vainio <viva...@gmail.com> wrote:

On Sun, Jul 19, 2009 at 10:42 PM, Edward K. Ream<edre...@gmail.com> wrote:

> I'm not sure whether continually updating leoVersion.txt is going to cause a
> problem with merges...

I still think you should upgrade it occasionally by a script. If the
nightly tarball thing is using bzr (well, it pretty much has to ;-),
it can update it as well.

Yes, this might be best.  I just experimented importing bzrlib from test.leo, and that fails on my machine, which means it wouldn't be convenient for leoVersion.py to compute the version number.

We went over a year with bzr without anyone noticing that the build numbers were bogus, so I suspect that keeping the numbers up to date is not too important :-)

Edward
Reply all
Reply to author
Forward
0 new messages