Tuesday, March 8, 2011

Re: To be strange or not to be strange...?

On Tue, 8 Mar 2011, Bram Moolenaar wrote:

> Ben Haskell wrote:
>
>>>> The hg tags stop at v7-2-235 in my version of the repo, and the
>>>> last log message for .hgtags is:
>>>>
>>>> changeset: 2029:875230a0a1bf
>>>> user: convert-repo
>>>> date: Wed Jan 06 14:58:09 2010 +0000
>>>> summary: update tags
>>>>
>>>> That makes me think they were only carried over from SVN. Bram,
>>>> when you push new patches, are you no longer adding the tags? It
>>>> would be beneficial. Having to inspect/grep the logs is a pretty
>>>> poor substitute for being able to do:
>>>>
>>>> $ hg co v7-3-000
>>>
>>> I haven't looked into this yet. Is there a simple way to apply a
>>> tag to a specific hg changeset version, so that you can check out
>>> that version by that tag?
>>>
>>
>> $ hg tag -r [revision] [name]
>>
>> e.g. the Vim 7.3.000 candidate(s?) named above
>> $ hg tag -r ee53a39d5896 v7-3-000
>> $ hg tag -r 2a2ad267db08 v7-3-000
>
> I'm not going to type these commands, they need to be part of a
> script. So how do we get that revision number for a patch version, or
> the other way around: how do we get the version number from each
> revision number? We actually need both, one for tagging existing
> versions and one to tag each version when I commit a patch.
>
> I already have a script that does "hg commit" with the description
> taken from the patch. I would need to add something to that script to
> tag the version. I suppose that can only be done after the commit?
> Or can "hg commit" add a tag at the same time? The help doesn't
> mention it.

I don't think you can do it in a single command, but tagging the
just-committed patch is easy. The [-r revision] argument is optional,
defaulting to tip (or you can specify [-r tip] explicitly). So:

$ [whatever commands to commit the patch]
$ tagname=v${major}-${minor}-${patch}
$ hg tag $tagname

That autocommits the tag. If that's undesirable for some reason
(aesthetics), the .hgtags file is of the format:
[commit sha-1] <space> [tag name] <nl>

So:
$ hg log -r tip --template "{node} $tagname\n" >> .hgtags


For the scripted portion of going back and adding all of the missing
tags (formatted for less unreadability -- ran it as a one-liner):

$ hg log --template '{node} {desc|firstline}\n' | \
: perl -lnwe 'next unless my ($rev, $major, $minor, $patch) = /^(\S+) updated for version (7)\.([23])\.(\d\d\d)$/;
: my $tag = "v${major}-${minor}-${patch}";
: next if $seen{$tag};
: $seen{$tag}++;
: next if $minor == 2 and $patch <= 325;
: print "$rev $tag"' >> .hgtags
$ hg ci -m 'added missing tags'

I'll send it as an hg email in response to this message.

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: