两个标签之间的Mercurial日志

时间:2014-11-10 18:54:17

标签: mercurial

我想使用hg log生成一个简短的更新日志,涵盖最新版本的更改。发布标有" v"前缀例如" v0.9.1"或" v1.0"。是否可以使用revsets选择以" v"开头的两个最后一个标签之间的范围,不包括两个标签中较旧的标签?

如果我有一个例子:

  • changeset 0
  • 变更集1
    标签:v0.1
  • changeset 2
  • 变更集3
    tag:bar
  • 变更集4
    标签:v0.9
  • 变更集5
    tag:foo
  • changeset 6
  • 变更集7
    标签:v1.0
  • changeset 8

我想选择5到7的变更集,如果可能的话,甚至不指定v0.9和v1.0只使用" v"前缀。

2 个答案:

答案 0 :(得分:3)

如果您知道头顶的标签名称:

hg log -r 'v0.9::v1.0 - v0.9'

如果你没有,你可以找到:

hg log -r 'last(tag("re:^v"), 2)'

如果v0.9v1.0的祖先,则第一个日志命令才有意义;如果不是这种情况,您可以使用单个冒号而不是::,但结果可能是完全无意义的。在这种情况下,您可能需要这样的东西:

hg log -r 'ancestor(v0.9, v1.0)::v1.0 - ancestor(v0.9, v1.0)'

这将生成从v0.9v1.0的最新共同祖先开始的所有更改的日志。如果v0.9v1.0的祖先,则会退化为与第一个日志命令相同的行为。

答案 1 :(得分:3)

如果您真的想要问题的答案,"两次修订之间发生了什么变化"你必须做一些有点冗长的事情:

hg log -r 'ancestors(relB) - ancestors(relA)'

在有分支开发的情况下,这与relA :: relB不同。

考虑以下历史图表:

$ 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

观察@ Kevin的结果和祖先()方法之间的区别:

$ 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

与祖先的方法相比,它讲述了整个故事。

$ 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

实际的&#34;最常见的修订版&#34;两次修订之间似乎是:

 ancestor(ancestors(relB)  - ancestors(relA))

所以变化的glog很多:

$ hg glog -r 'ancestor(ancestors(relB)  - ancestors(relA))::  relB'
o    changeset:   6:b37a8f32de1d
|\   tag:         relB
| |  parent:      5:187092bb7e9b
| |  parent:      3:2d5af4e62ad5
| |  user:        Danny Sadinoff <danny@sadinoff.com>
| |  date:        Fri Nov 21 09:27:47 2014 +0000
| |  summary:     merged
| |
| o  changeset:   5:187092bb7e9b
| |  user:        Danny Sadinoff <danny@sadinoff.com>
| |  date:        Fri Nov 21 09:27:21 2014 +0000
| |  summary:     more branch work
| |
| o  changeset:   4:dbfe8f003e51
| |  parent:      1:68f933b431ec
| |  user:        Danny Sadinoff <danny@sadinoff.com>
| |  date:        Fri Nov 21 09:26:51 2014 +0000
| |  summary:     branched dev
| |
o |  changeset:   3:2d5af4e62ad5
| |  user:        Danny Sadinoff <danny@sadinoff.com>
| |  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@sadinoff.com>
|    date:        Fri Nov 21 09:25:13 2014 +0000
|    summary:     mainline dev
|
o  changeset:   1:68f933b431ec
|  user:        Danny Sadinoff <danny@sadinoff.com>
|  date:        Fri Nov 21 09:24:18 2014 +0000
|  summary:     added a line
|