Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a revset alias for tags whose names follow a pattern?

In my repository, I have tags of the form version-1.2.3. I would like to make a revset alias new() that is called like this:

hg log -r 'new(1.2.3, 1.2.4)'

...and expands to this:

hg log -r '::version-1.2.4 - ::version-1.2.3'  # What's new in 1.2.4?

When I tried to do this:

[revsetalias]
new($1, $2) = ::version-$2 - ::version-$1

...Mercurial interpreted it as subtracting the revision $2 (e.g. 1.2.3) from the revision version, which was not my intent.

I also tried this, using the ## concatenation operator:

new($1, $2) = ::"version-" ## $2 - ::"version-" ## $1

But then hg log -r 'new(1.2.3, 1.2.4)' gives me this error:

hg: parse error at 13: syntax error

I also tried using ancestors() instead of the :: syntax, but still got the syntax error. Is this possible to do?

like image 549
Kevin Avatar asked Jun 17 '15 21:06

Kevin


1 Answers

I tested the following that works:

new($1, $2) = (::"version-" ## $2) - (::"version-" ## $1)

For reference $1::$2 won't give you the same thing, it means the revision between $1 and $2 An equivalent revset that I would prefer is:

new($1, $2) = only("version-" ## $2, "version-" ## $1)

According to the doc it is strictly equivalent to what you want:

"only(set, [set])"
      Changesets that are ancestors of the first set that are not ancestors of
      any other head in the repo. If a second set is specified, the result is
      ancestors of the first set that are not ancestors of the second set
      (i.e. ::<set1> - ::<set2>).
like image 78
lc2817 Avatar answered Nov 22 '22 15:11

lc2817