Version numbers, again

19 views
Skip to first unread message

Edward K. Ream

unread,
Jan 8, 2012, 10:51:19 AM1/8/12
to leo-editor
I'd like to start a new thread here, rather than continue the
discussion for bug "911521: Help about and --version should be
accurate" so that more people might see it.

Here is my present summary of the situation:

The v.bat way is not acceptable: it effectively doubles the number of
commits needed, which adds a lot of cruft to the bzr log.

But how to fix matters? There are three cases, two of which are
almost identical:

1. Running Leo from a bzr repository. This is the easy case.
leoVersion.py should get the version from the .bzr/branch/last-
revision file. I am going to add this code today.

2. Running Leo from a nightly snapshot.

3. Running Leo from an official release.

Cases 2 and 3 are almost identical. The only difference is that for
case 3 we could consider running a distribution script to update
leoVersion.py. We could also run such a script for nightly snapshots,
but that would not be automatic.

In short, the essential question is how to update leoVersion.py for
nightly snapshots.

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.

Any other comments or ideas?

Edward

Edward K. Ream

unread,
Jan 8, 2012, 12:06:48 PM1/8/12
to leo-editor
On Jan 8, 9:51 am, "Edward K. Ream" <edream...@gmail.com> wrote:

> 1. Running Leo from a bzr repository.  This is the easy case.
> leoVersion.py should get the version from the .bzr/branch/last-
> revision file.  I am going to add this code today.

Done at rev 4916. leoVersion.py now gives the expected time and
version number.

There is no more need for v.bat for those using bzr. This is a big
improvement for Leo's own developers.

However, we still need a way to update the static_version and
static_date fields for official releases and nightly snapshots.

Edward

Terry Brown

unread,
Jan 8, 2012, 5:02:05 PM1/8/12
to leo-e...@googlegroups.com
On Sun, 8 Jan 2012 07:51:19 -0800 (PST)
"Edward K. Ream" <edre...@gmail.com> wrote:

> 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

HansBKK

unread,
Jan 8, 2012, 8:06:25 PM1/8/12
to leo-e...@googlegroups.com
Just did a fresh branch, worked fine and bzr reported 4917, but Help->About Leo reports:

build 4900, 2012-01-08

I'm not saying this is a problem, just letting you know something's doing some "rounding" somewhere 8-)

Edward K. Ream

unread,
Jan 9, 2012, 8:33:08 AM1/9/12
to leo-e...@googlegroups.com

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

Edward K. Ream

unread,
Jan 9, 2012, 8:36:40 AM1/9/12
to leo-e...@googlegroups.com
On Mon, Jan 9, 2012 at 7:33 AM, Edward K. Ream <edre...@gmail.com> wrote:

> 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

Edward K. Ream

unread,
Jan 9, 2012, 9:45:41 AM1/9/12
to leo-e...@googlegroups.com
On Mon, Jan 9, 2012 at 7:33 AM, Edward K. Ream <edre...@gmail.com> wrote:

> 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

Terry Brown

unread,
Jan 9, 2012, 10:06:08 AM1/9/12
to leo-e...@googlegroups.com
On Mon, 9 Jan 2012 07:33:08 -0600

"Edward K. Ream" <edre...@gmail.com> wrote:

> 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

Edward K. Ream

unread,
Jan 9, 2012, 10:08:19 AM1/9/12
to leo-e...@googlegroups.com
On Mon, Jan 9, 2012 at 9:06 AM, Terry Brown <terry_...@yahoo.com> wrote:

>> 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

Terry Brown

unread,
Jan 9, 2012, 10:20:24 AM1/9/12
to leo-e...@googlegroups.com
On Mon, 9 Jan 2012 09:08:19 -0600

"Edward K. Ream" <edre...@gmail.com> wrote:

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

Edward K. Ream

unread,
Jan 9, 2012, 10:36:38 AM1/9/12
to leo-e...@googlegroups.com
On Mon, Jan 9, 2012 at 9:20 AM, Terry Brown <terry_...@yahoo.com> wrote:

> 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

Edward K. Ream

unread,
Jan 9, 2012, 10:38:45 AM1/9/12
to leo-e...@googlegroups.com
On Mon, Jan 9, 2012 at 9:36 AM, Edward K. Ream <edre...@gmail.com> wrote:

> The revno looks one too high, but that's a nit.

My mistake. The revno looks correct.

EKR

Terry Brown

unread,
Jan 9, 2012, 10:49:38 AM1/9/12
to leo-e...@googlegroups.com
On Mon, 9 Jan 2012 09:36:38 -0600

"Edward K. Ream" <edre...@gmail.com> wrote:

> 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

Edward K. Ream

unread,
Jan 9, 2012, 12:55:15 PM1/9/12
to leo-e...@googlegroups.com
On Mon, Jan 9, 2012 at 9:49 AM, Terry Brown <terry_...@yahoo.com> wrote:

>> 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

Terry Brown

unread,
Jan 9, 2012, 1:18:42 PM1/9/12
to leo-e...@googlegroups.com
On Mon, 9 Jan 2012 11:55:15 -0600

"Edward K. Ream" <edre...@gmail.com> wrote:

> 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

Edward K. Ream

unread,
Jan 9, 2012, 1:26:41 PM1/9/12
to leo-e...@googlegroups.com

Thanks for the clarification. I suspected as much, but it's good to be sure.

EKR

Edward K. Ream

unread,
Jan 11, 2012, 2:43:39 PM1/11/12
to leo-editor
On Jan 8, 9:51 am, "Edward K. Ream" <edream...@gmail.com> wrote:
> I'd like to start a new thread here, rather than continue the
> discussion for bug "911521: Help about and --version should be
> accurate" so that more people might see it.

The project is complete, or very nearly so.

1. Rev 4922 now handles the --version option properly: Leo prints the
version number and exits.

2. Aside from this detail, the most recent daily build handles version
numbers properly, regardless of whether Leo is run from a daily build
or from a bzr repo.

In short, tonight's daily build should work properly in all respects.

Edward

lewis

unread,
Jan 13, 2012, 9:35:16 AM1/13/12
to leo-editor
I'm running build 4926, updating using bzr.

C:\bazaar\leo-editor>bzr qpull
Run command: bzr pull --overwrite --remember
Using saved parent location: http://bazaar.launchpad.net/~leo-editor-team/leo-editor/trunk3/
Now on revision 4926.
M leo/core/leoAtFile.py
M leo/core/leoEditCommands.py
M leo/core/leoFrame.py
M leo/core/leoImport.py
M leo/core/leoMenu.py
M leo/core/runLeo.py
M leo/doc/leoProjects.txt
M leo/doc/leoToDo.txt
M leo/plugins/baseNativeTree.py
M leo/plugins/qtGui.py
All changes applied successfully.

However doing Help>About Leo still reports build 4914.
logfile: Leo Log Window
Leo 4.9.1 devel, build 4914, 2012-01-07 09:55:01 -0600
Python 3.2.2, qt version 4.8.0
Windows 6, 1, 7601, 2, Service Pack 1

Are there still some files which need to be updated manually?

Regards
Lewis

Terry Brown

unread,
Jan 13, 2012, 10:22:15 AM1/13/12
to leo-e...@googlegroups.com
On Fri, 13 Jan 2012 06:35:16 -0800 (PST)
lewis <lewi...@operamail.com> wrote:

> 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

lewis

unread,
Jan 13, 2012, 7:39:20 PM1/13/12
to leo-editor
I typically start leo from a Console tab.
Started from cmd.exe it still reports
Leo 4.9.1 devel, build 4914, 2012-01-07 09:55:01 -0600
Python 3.2.2, qt version 4.8.0
Double click on launchleo.py from inside C:\Python32\Lib\site-packages
\leo-editor directory reports the same.

The C:\bazaar\.bzr\branch\last-revision file contents is "0 null:"
This file is dated 10/01/2012

Lewis

Terry Brown

unread,
Jan 13, 2012, 10:28:25 PM1/13/12
to leo-e...@googlegroups.com
On Fri, 13 Jan 2012 16:39:20 -0800 (PST)
lewis <lewi...@operamail.com> wrote:

> The C:\bazaar\.bzr\branch\last-revision file contents is "0 null:"
> This file is dated 10/01/2012

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

lewis

unread,
Jan 14, 2012, 3:25:33 AM1/14/12
to leo-editor
.bzr\branch\last-revision only exists in my C:\bazaar\.bzr\branch\
directory, not in my
C:\Python32\Lib\site-packages\leo-editor directory.
Doing 'bzr revno' it reports 4926
C:\bazaar\leo-editor>bzr revno
4926

Regards
Lewis

On Jan 14, 2:28 pm, Terry Brown <terry_n_br...@yahoo.com> wrote:
> On Fri, 13 Jan 2012 16:39:20 -0800 (PST)
>

lewis

unread,
Jan 14, 2012, 8:17:27 AM1/14/12
to leo-editor
On Jan 14, 7:25 pm, lewis <lewisn...@operamail.com> wrote:
> .bzr\branch\last-revision only exists in my C:\bazaar\.bzr\branch\
> directory, not in my
> C:\Python32\Lib\site-packages\leo-editor directory.

Thanks Terry, I realise 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.

Regards
Lewis

Edward K. Ream

unread,
Jan 14, 2012, 9:07:31 AM1/14/12
to leo-e...@googlegroups.com
On Sat, Jan 14, 2012 at 7:17 AM, lewis <lewi...@operamail.com> wrote:

> 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

Reply all
Reply to author
Forward
0 new messages