How to work with the keyword plugin

Asked by Carnë Draug

I'm trying to get the keyword plugin working (I'm using launchpad for my code).

I downloaded the plugin from launchpad, copied the code into its own folder inside the plugins folder and when I run "bzr selftest keywords.tests" it says it's all ok. I added the lines

[name *.m]
keywords = on

to bazaar.conf since I want it to do it in *.m files (it's octave code). I have the following line into a .m file

main.script_version = "$Revision-Id$";

When I push the code to launchpad, it still appears $Revision-Id$. Even when I download the code from launchpad (with brz branch), it still just appears $Revision-Id$

This is probably quite simple to answer, and I just don't understand the concept of how this keyword plugin is supposed to work. I'm just new to this, not only to bazaar, but to a revision control system.

Thanks in advance

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Ian Clatworthy
Solved:
Last query:
Last reply:
Revision history for this message
Ian Clatworthy (ian-clatworthy) said :
#1

Hi,

It looks like you're doing the right things to me in terms of setup. There's a bug in the keywords plugin (bug #408841) where it doesn't refresh the file content after a commit yet. That may be why the value isn't updated locally.

Some other things:

1. If the goal is to get a nice revision number into your code, be sure to read http://doc.bazaar.canonical.com/latest/en/user-guide/version_info.html. $Revision-Id$ will give you something rather ugly, e.g. $Revision-Id: <email address hidden> $

2. The data which gets pushed to Launchpad will be unexpanded by design. If you branch that to a fresh directory though, it ought to be expanded out.

If you point me to the branch on LP, I'll grab it and see if keywords get expanded for me or not.

Revision history for this message
Carnë Draug (carandraug) said :
#2

Thanks.

My goal is to have a number for each file that would be collected at the start of the program and saved along with the rest of the output. I thought revision-id would give me a number of the revision.

The branch is here https://launchpad.net/frapinator

Revision history for this message
Ian Clatworthy (ian-clatworthy) said :
#3

Wow - what an interesting project.

In Bazaar (unlike CVS say), files don't have individual version numbers. There is only a version/revision identifier for the full tree. See http://doc.bazaar.canonical.com/latest/en/user-guide/core_concepts.html.

Can you use the revno of the tree? Are you looking to display this information when the software executes or just have the data in the tree for support/auditing purposes?

Revision history for this message
Carnë Draug (carandraug) said :
#4

Thanks. I am specially proud of its name and acronym :D

I can use the revno of the tree, no problem. I want the number to be stored together with the rest of the processed data so that I always know which code was used to obtain that data. That's the main reason I decided to use a revision control system. if I insert a bug at a certain point, I'll know which files have the wrongly processed data and I won't have to reprocess everything again.

That said, how do I workaround this bug? In the bug report says that a fix has been committed and merged into lp:brz/2.0 but I'm using bazaar version 2.0.2. And I also just downloaded the keyword plugin so that's in the last version.

Revision history for this message
Best Ian Clatworthy (ian-clatworthy) said :
#5

I'd ignore the keywords plugin and use the version-info command. See http://doc.bazaar.canonical.com/latest/en/user-reference/version-info-help.html.

If Octave offers some API for getting the output of external commands AND you're always running the code from a branch or checkout, then I'd run `bzr version-info` each time to collect the revision number. Otherwise, I gather you have some sort of build process where the software gets packaged up and distributed to others? In that case, use something like ...

  bzr version-info --template "VERSION = '{revno}'" > version.m

as you're building or packaging the software.

Revision history for this message
Carnë Draug (carandraug) said :
#6

Thanks Ian Clatworthy, that solved my question.