Oli
Oli

Reputation: 239880

How can I get the Bazaar version of a file on my website?

There have been similar questions to this that I've been involved with before. One example: How can I get the svn revision number in PHP?

But today I'm tackling a project that is managed with BZR. I need to get the bazaar version for a particular file and publish that figure on our website in a way that it automatically updates when the file is update.

The website is all in Python so I'm open to reading files behind the scenes but I would prefer a more passive method if available.

Upvotes: 1

Views: 116

Answers (3)

jelmer
jelmer

Reputation: 2450

In Python:

from bzrlib.branch import Branch
b = Branch.open(location_of_your_branch)
b.lock_read()
try:
    # Retrieve the contents of the last revision
    t = b.basis_tree()
    revid = t.get_file_revision(t.path2id(your_filename))
    print ".".join([str(x) for x in b.revision_id_to_dotted_revno(revid)])
finally:
    b.unlock()

Upvotes: 2

jcollado
jcollado

Reputation: 40414

If you need to get the latest revision in which a file was modified, you can doit using the following command:

bzr log -l1 --line <file> | cut -f1 -d:

Upvotes: 3

Miki Tebeka
Miki Tebeka

Reputation: 13910

One way is to have a script that pushes to your website, this script case update version.py or something like that:

# update version
echo "VERSION = \"$(bzr revno)\"" > version.py
# push to website
rsync ...
# tag
bzr tag --force deployed-version

Upvotes: 0

Related Questions