Reputation: 33
I want to use hg log
to generate a brief changelog covering the changes of the latest release. Releases are tagged with a "v" prefix e.g. "v0.9.1" or "v1.0". Is it possible with revsets to select a range between the two last tags that start with "v", not including the older one of the two tags?
As an example if I have:
I'd like to select changesets 5 to 7, if possible without even specifying v0.9 and v1.0 only using the "v" prefix.
Upvotes: 3
Views: 2191
Reputation: 5612
IF you really want the answer to the question, "what changed between two revisions" you have to do something a little verbose:
hg log -r 'ancestors(relB) - ancestors(relA)'
This is different than relA::relB in the case where there was branched development.
Consider the following history graph:
$ hg glog
@ changeset: 7:cb998461fc2f
| tag: tip
| user: Danny Sadinoff <danny>
| date: Fri Nov 21 09:28:46 2014 +0000
| summary: Added tag relB for changeset b37a8f32de1d
|
o changeset: 6:b37a8f32de1d
|\ tag: relB
| | parent: 5:187092bb7e9b
| | parent: 3:2d5af4e62ad5
| | user: Danny Sadinoff <danny>
| | date: Fri Nov 21 09:27:47 2014 +0000
| | summary: merged
| |
| o changeset: 5:187092bb7e9b
| | user: Danny Sadinoff <danny>
| | date: Fri Nov 21 09:27:21 2014 +0000
| | summary: more branch work
| |
| o changeset: 4:dbfe8f003e51
| | parent: 1:68f933b431ec
| | user: Danny Sadinoff <danny>
| | date: Fri Nov 21 09:26:51 2014 +0000
| | summary: branched dev
| |
o | changeset: 3:2d5af4e62ad5
| | user: Danny Sadinoff <danny>
| | date: Fri Nov 21 09:26:17 2014 +0000
| | summary: Added tag relA for changeset 0ad160ab1455
| |
o | changeset: 2:0ad160ab1455
|/ tag: relA
| user: Danny Sadinoff <danny>
| date: Fri Nov 21 09:25:13 2014 +0000
| summary: mainline dev
|
o changeset: 1:68f933b431ec
| user: Danny Sadinoff <danny>
| date: Fri Nov 21 09:24:18 2014 +0000
| summary: added a line
|
o changeset: 0:4738f4f68f1e
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:23:54 2014 +0000
observe the difference between @Kevin's result and the ancestors() approach:
$ hg log -r 'ancestor(relA, relB)::relB - ancestor(relA, relB)'
changeset: 3:2d5af4e62ad5
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:26:17 2014 +0000
summary: Added tag relA for changeset 0ad160ab1455
changeset: 6:b37a8f32de1d
tag: relB
parent: 5:187092bb7e9b
parent: 3:2d5af4e62ad5
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:27:47 2014 +0000
summary: merged
versus the ancestors approach, which tells the whole story.
$ hg log -r 'ancestors(relB) - ancestors(relA)'
changeset: 3:2d5af4e62ad5
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:26:17 2014 +0000
summary: Added tag relA for changeset 0ad160ab1455
changeset: 4:dbfe8f003e51
parent: 1:68f933b431ec
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:26:51 2014 +0000
summary: branched dev
changeset: 5:187092bb7e9b
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:27:21 2014 +0000
summary: more branch work
changeset: 6:b37a8f32de1d
tag: relB
parent: 5:187092bb7e9b
parent: 3:2d5af4e62ad5
user: Danny Sadinoff <danny>
date: Fri Nov 21 09:27:47 2014 +0000
summary: merged
the actual "greatest common revision" between two revisions seems to be:
ancestor(ancestors(relB) - ancestors(relA))
so a pretty glog of the changes becomes:
$ hg glog -r 'ancestor(ancestors(relB) - ancestors(relA)):: relB'
o changeset: 6:b37a8f32de1d
|\ tag: relB
| | parent: 5:187092bb7e9b
| | parent: 3:2d5af4e62ad5
| | user: Danny Sadinoff <[email protected]>
| | date: Fri Nov 21 09:27:47 2014 +0000
| | summary: merged
| |
| o changeset: 5:187092bb7e9b
| | user: Danny Sadinoff <[email protected]>
| | date: Fri Nov 21 09:27:21 2014 +0000
| | summary: more branch work
| |
| o changeset: 4:dbfe8f003e51
| | parent: 1:68f933b431ec
| | user: Danny Sadinoff <[email protected]>
| | date: Fri Nov 21 09:26:51 2014 +0000
| | summary: branched dev
| |
o | changeset: 3:2d5af4e62ad5
| | user: Danny Sadinoff <[email protected]>
| | date: Fri Nov 21 09:26:17 2014 +0000
| | summary: Added tag relA for changeset 0ad160ab1455
| |
o | changeset: 2:0ad160ab1455
|/ tag: relA
| user: Danny Sadinoff <[email protected]>
| date: Fri Nov 21 09:25:13 2014 +0000
| summary: mainline dev
|
o changeset: 1:68f933b431ec
| user: Danny Sadinoff <[email protected]>
| date: Fri Nov 21 09:24:18 2014 +0000
| summary: added a line
|
Upvotes: 3
Reputation: 30181
If you know the names of the tags off the top of your head:
hg log -r 'v0.9::v1.0 - v0.9'
If you don't, you can find out:
hg log -r 'last(tag("re:^v"), 2)'
The first log command only makes sense if v0.9
is an ancestor of v1.0
; if this is not the case, you can use a single colon instead of ::
, but the result will probably be total nonsense. In that scenario, you may want something like this instead:
hg log -r 'ancestor(v0.9, v1.0)::v1.0 - ancestor(v0.9, v1.0)'
That will produce a log of all changes starting from the most recent common ancestor of v0.9
and v1.0
. If v0.9
is an ancestor of v1.0
, this degenerates to the same behavior as the first log command.
Upvotes: 3