> Terry, I don't recall whether you have ever published the script that
> builds the snapshots. I think maybe you did, but I have no
> recollection of it. Would it be possible for this script to update
> the source code of leoVersion.py? If so, leoVersion.py would get the
> version from the last-revision file if it exists, and otherwise use
> the hard coded version inserted by your script.
>
> I suppose the essential point here is that updated leoVersion.py would
> *not* be committed to bzr: it would exist only for the nightly build.
> This should be safe enough.
I added this several days ago, the relevant part of the script is
os.system("bzr version-info --python %s >%s/leo/core/bzr_version.py" %
(fname, fname))
cmd = "sed -i \"s/ u'/ '/g\" %s/leo/core/bzr_version.py" % fname
os.system(cmd)
cmd = r"sed -i 's/print \(.*\)/print(\1)/' %s/leo/core/bzr_version.py" % fname
os.system(cmd)
os.system("rm -rf %s/.bzr*" % fname)
Not as smart as running 2to3, but seems to be working fine.
Cheers -Terry
Thanks for this report. This does look like a problem. As I will now
explain, I would have been surprised had there *not* been a problem
after my recent change.
The 4900 number isn't "rounding", it's the fallback revno given by the
static_version constant in leoVersion.py.
leoVersion.py uses the static_version (and static_date) constants when
the file computed by the following code does not exist::
theDir = os.path.basename(__file__)
path = os.path.join(theDir,'..','.bzr','branch','last-revision')
path = os.path.normpath(path)
path = os.path.abspath(path)
As I have just verified, this corresponds to the top-level .bzr
folder. For example, the "trunk" directory contains my working copy
of lp:leo-editor, so the path is::
trunk/.bzr/branch/last-revision
Terry, the challenge, as I see it, is for the nightly-snapshot script
to do one of the following:
1. Include bzr_version.py in the nightly build **without** committing
bzr_version.py.
2. Include some *other* file (*not* part of the bzr repository-name
and location don't much matter) somewhere where the code in
leoVersion.py can get it.
In either case, leoVersion.py will then the code similar to the old
code to get the version info if the last-revision file doesn't exits.
Summary
=======
1. The only hard case is generating proper build and date numbers for
nightly snapshots.
2. It is important that no files in Leo's bzr repository change when
making the snapshots. This will keep the repo "unpolluted".
3. When running code from a nightly snapshot, the last-revision file
will *not* exist, so the script that builds the snapshot should create
some *other* file that leoVersion.py can use.
Edward
> leoVersion.py uses the static_version (and static_date) constants when
> the file computed by the following code does not exist::
Leo has not inited the leoGlobals module when this code executes. If
g were available the code would be something like (untested)::
path = g.os_path_finalize_join(g.app.loadDir,'..','..','.bzr','branch','last-revision')
EKR
> Terry, the challenge, as I see it, is for the nightly-snapshot script
> to do one of the following:
>
> 1. Include bzr_version.py in the nightly build **without** committing
> bzr_version.py.
>
> 2. Include some *other* file (*not* part of the bzr repository-name
> and location don't much matter) somewhere where the code in
> leoVersion.py can get it.
The trick is to make either of these files part of the nightly build,
even though it is not part of Leo's repo.
EKR
> 1. Include bzr_version.py in the nightly build **without** committing
> bzr_version.py.
It's been doing this for a week or so - I think it was working until
the recent changes to look in .bzr.
Cheers -Terry
>> 1. Include bzr_version.py in the nightly build **without** committing
>> bzr_version.py.
>
> It's been doing this for a week or so - I think it was working until
> the recent changes to look in .bzr.
I'm not sure what you mean. Is it something I did?
Edward
Actually I think it's just a bug :-) (as opposed to us leap frogging
each other implementation wise, which is what I thought was happening)
leoVersion.py: /mnt/usr1/usr1/home/tbrown/.leo/.bzr/branch/last-revision does not exist
it's looking in the wrong place, $HOME/.leo instead of directory
containing launchLeo.py, i.e. one up from leo/
Cheers -Terry
> Actually I think it's just a bug :-) (as opposed to us leap frogging
> each other implementation wise, which is what I thought was happening)
>
> leoVersion.py: /mnt/usr1/usr1/home/tbrown/.leo/.bzr/branch/last-revision does not exist
> it's looking in the wrong place, $HOME/.leo instead of directory
> containing launchLeo.py, i.e. one up from leo/
As of rev 4916 the code that computes the location of last-revision is
working well for me.
I just downloaded the latest snapshot, and I see what the problem is.
There is, as expected, no last-revision file. Thus the rev 4916 code
will use the static values.
However, I see that the leo/core directory contains a bzr_version.py
file with the following info::
version_info = {'branch_nick': 'leo-editor-snapshot-20120109',
'build_date': '2012-01-09 02:53:58 -0600',
'clean': None,
'date': '2012-01-08 11:14:52 -0600',
'revision_id': 'edre...@gmail.com-20120108171452-11nrw9t0bffj58r7',
'revno': 4917}
The revno looks one too high, but that's a nit.
In short, all that needs to be done is to have leoVersion.py look in
Leo's core folder for bzr_version.py if last-revision does not exist.
The core folder is as good a place as any, imo, so there should be no
need to change your daily build script.
Terry, if you agree I'll change leoVersion.py accordingly. That
should be the end of the matter.
Edward
> The revno looks one too high, but that's a nit.
My mistake. The revno looks correct.
EKR
> In short, all that needs to be done is to have leoVersion.py look in
> Leo's core folder for bzr_version.py if last-revision does not exist.
> The core folder is as good a place as any, imo, so there should be no
> need to change your daily build script.
>
> Terry, if you agree I'll change leoVersion.py accordingly. That
> should be the end of the matter.
Sounds good to me.
Cheers -Terry
>> In short, all that needs to be done is to have leoVersion.py look in
>> Leo's core folder for bzr_version.py if last-revision does not exist.
>> The core folder is as good a place as any, imo, so there should be no
>> need to change your daily build script.
>>
>> Terry, if you agree I'll change leoVersion.py accordingly. That
>> should be the end of the matter.
Done at rev 4918.
However, I see that bzr_version.py is actually part of Leo's repo.
That won't make any difference when running the bzr code, but I
suppose this means that your daily snapshot script must take
appropriate care not to change it.
My guess is that this is what is happening, in fact, but I wanted to
raise this issue.
Also, I don't have a great way to test the new code that reads
bzr_version. Unlike the code that reads the last-revision file, a
normal import command suffices to get access. Still, one could
imagine that a mistake would cause a crash in the the startup code
when running from a snapshot.
So we need a new test, and don't have one, other than seeing what
happens when using the next snapshot ;-)
Edward
> However, I see that bzr_version.py is actually part of Leo's repo.
> That won't make any difference when running the bzr code, but I
> suppose this means that your daily snapshot script must take
> appropriate care not to change it.
Well, it creates it, overwriting the bzr version, but never commits it
anyway, and it deletes .bzr from the distributed data, making it a .zip
archive, not a branch as such. I suppose it could use bzr export, but
I don't think the results would be any different.
Cheers -Terry
Thanks for the clarification. I suspected as much, but it's good to be sure.
EKR
> Now on revision 4926.
I can't reproduce that, also on 4926 via bzr, and 4926 is reported in
Help->About, in the log, and from <my leo launch script> --version.
Can you try starting Leo a couple of different ways (from the command
line, in the folder containing launchLeo.py and in a different folder),
and maybe from an icon if you do that kind of thing, see if it makes a
difference? Also check the .bzr/branch/last-revision in the folder
containing the launchLeo.py you're using.
Cheers -Terry
The file you want to check is the .bzr\branch\last-revision in the
directory containing launchLeo.py. And / or run `bzr revno` in that
directory.
Cheers -Terry
> Thanks Terry, I realize now that I need to copy the bazaar\.bzr
> folder into my C:\Python32\Lib\site-packages\leo-editor directory.
> The logfiles + help>about now report the correct version.
Thanks for this confirmation. It's useful.
Edward