How to write tags

Frank A. Kingswood frank at kingswood-consulting.co.uk
Thu Dec 24 19:44:10 CST 2009


Some more detail.

>> 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?
>>
>> Oh, and localrepo.tags() drops the return value from _tags() with the
>> tagnode.
> 
> I don't understand what you are trying to do here. Create tags in mercurial via memctx ?

Yes. I'm importing changes in my ersatz 'pull' from p4. Because this is 
a pull, I'm leaving the local directory state as it is, using a memctx 
to create the changesets.

Augie Fackler wrote:

> [...] 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.

After the revision is committed I am holding its id and if there is a p4 
tag (the "most reasonable" being "yes the tag appears on this revision" 
irrespective of whether it exists on other revisions as well) I want to 
add it to .hgtags. But the tag functions in localrepo modify the working 
state, and tags.py does not export anything useful.

So at worst I'll be reimplementing all of the .hgtag manipulation in my 
extension, something I thought is not desirable. I can just assume the 
.hgtags format is fixed and append lines to it, it just does not seem 
very maintainable.

Frank
-- 
------------------------------------------------------------------------
Frank A. Kingswood                      frank at kingswood-consulting.co.uk
Cambridge, United Kingdom                               +44-7545-209 100


More information about the Mercurial-devel mailing list