How to write tags

Augie Fackler durin42 at
Thu Dec 24 12:11:16 CST 2009

On Dec 24, 2009, at 4:06 AM, Frank A. Kingswood wrote:

> Hallo!
> For the perfarce push/pull extension I'm attempting to create a tag  
> imported from p4. The pull does its work through context.memctx to  
> avoid clobbering the working directory state. Unfortunately, the  
> localrepo.tag() function only works on the working state, and the  
> tags module does not export anything useful.
> I'm not terribly keen on reimplementing all of the tags logic in my  
> extension; is there a better way?

I'm not sure what you're trying to do. You have to tag a revision that  
actually exists in hg - as with svn, I expect there can be something  
of a mismatch when coming from Perforce. In Subversion, you can make  
tags from a mixed set of versions of files, which doesn't correspond  
to any single revision on-disk. The solution hgsubversion uses is to  
create a new changeset that represents the tag state as a descendant  
of its "most reasonable" ancestor, and then tag that. To actually  
create the tag, you just need to put a properly-formatted line  
in .hgtags in its own changeset.

> Oh, and localrepo.tags() drops the return value from _tags() with  
> the tagnode.
> Frank
> -- 
> ------------------------------------------------------------------------
> Frank A. Kingswood                      frank at
> Cambridge, United Kingdom                               +44-7545-209  
> 100
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at

More information about the Mercurial-devel mailing list