How to write tags
steve at borho.org
Thu Dec 24 20:04:08 CST 2009
On Thu, Dec 24, 2009 at 7:44 PM, Frank A. Kingswood
<frank at kingswood-consulting.co.uk> wrote:
> 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
>> 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
Slightly off-topic, but you may want to store the perforce tags in a
localtags file to avoid this memctx issue, and to avoid the future
issue of knowing not to push changes to the .hgtags file back to
Since p4 tags are not allowed to move (AFAIK), they don't need to be
versioned like native tags.
It just seems to kill two birds..
More information about the Mercurial-devel