Tag keyword (keyword extension)

Benno Dielmann lists at benno-dielmann.de
Mon Jul 14 04:26:07 CDT 2008


On Monday 14 July 2008 Matt Mackall wrote:
| > What do you mean by "expensive"?
|
| Because commits are an atomic repo-wide operation in Mercurial,
| everywhere you use a "tag" keyword ought to say 1.0 when you check out
| 1.0. Thus, when we check out 1.0, even if it only means updating a
| couple files in our working directory (because we were at 0.999
| already), we may have to scan and modify all the tens of thousands of
| files in our project. A sub-second operation now takes minutes or more.
|
| Fortunately, there are better ways to do all the sensible things you
| might want to do with keywords, so there's really no reason to use them
| in the first place.

Thanks for explaining this to me.

I'm almost new to version control (I've used CVS for a little project some 
years ago) and I'm using Mercurial for a small private project so my brain 
doesn't scale very well in this context yet ;-).

Nevertheless, thanks to Christian Ebert for the advise to use hooks for my 
desire to make changelog information available to my Python scripts. 

I've now added this Python function as a hook to commit and update:

~~~~~~~~~~~~~~~~~
import os

def createRevInfofile(ui, repo, **kwargs):
    cctx = repo.changectx()
    f = open(os.path.join(repo.root, 'hgparentinfo.py'), 'w')
    f.write('tags = %s\nrevision = %s' % (repr(cctx.tags()), repr(str(cctx))))
    f.close()
~~~~~~~~~~~~~~~~~

This creates a "hgparentinfo.py" in my repository root which I can import into 
my Python program to have version information available for display in 
an "About" dialog. Cute. 

Unfortunately, this doesn't work for the "archive" command, the only way seems 
to be to use the post-<command> hook, but this is getting complicated...

So, thanks to all of you for your helpfulness, 

Benno.




More information about the Mercurial mailing list