是否有一个Mercurial等价于git log——第一个父级?
是否有一个Mercurial等价于git log——第一个父级?,mercurial,hg-log,Mercurial,Hg Log,git log——第一个父级忽略合并提交的所有父级,但第一个父级除外 例如: $ git log --oneline --graph * 087f5ed Master C * 36c50a2 Merge branch 'feature' |\ | * 98c89df Feature B | * 89b3a7b Feature A * | 9a95133 Master B |/ * 766c9b0 Master A $ git log --oneline --graph --fir
git log——第一个父级
忽略合并提交的所有父级,但第一个父级除外
例如:
$ git log --oneline --graph
* 087f5ed Master C
* 36c50a2 Merge branch 'feature'
|\
| * 98c89df Feature B
| * 89b3a7b Feature A
* | 9a95133 Master B
|/
* 766c9b0 Master A
$ git log --oneline --graph --first-parent
* 087f5ed Master C
* 36c50a2 Merge branch 'feature'
* 9a95133 Master B
* 766c9b0 Master A
是否有Mercurial等价物?您可以使用Revset:
hg log -r "p1(merge())"
merge()
获取所有合并提交,而p1()
获取这些提交的第一个父级
使用hg help revsets
获取有关revsets的更多信息。hg log——遵循第一个
似乎做了大致相同的事情,但有一些规定:
git log--first parent branch-a branch-b
),虽然这可能只是因为我对Mercurial缺乏了解hg log-G
的空分支行:
$ hg log -G --template '{node|short} {desc|firstline}'
@ 51b90923fc9d Master C
|
o bb51d979fd68 Merge branch 'feature'
|\
| o a9ca2597ebbc Feature B
| |
| o d0a54af09272 Feature A
| |
o | 77ceb31100be Master B
|/
o b5a0b2c7468f Master A
$ hg log -G --template '{node|short} {desc|firstline}' --follow-first
@ 51b90923fc9d Master C
|
o bb51d979fd68 Merge branch 'feature'
|\
o | 77ceb31100be Master B
|/
o b5a0b2c7468f Master A
上面的示例可能看起来不太糟糕,但请参阅一个示例,在该示例中,此行为会导致难以处理的输出
如果问题#2无法解决,则此问题可能无关紧要,因为没有-G
的hg log
将是使用-遵循优先AFAICT的唯一有用方法
-r“410::426-(p2(merge())或祖先(p2(merge())))”
对于作为源的全范围变更集,更可读的形式如下
hg log-r“!(p2(merge())或祖先(p2(merge())))”
编辑1
我测试了revset,重新思考了方法论(而不是排除我只想添加到空集合中所需的内容),目前最接近我用例的迭代(有bug,找不到解决方案)是
(p1(祖先(p1(426)))或p1(426)或426)和410::426
其中(仍然)包括一些不需要的修订
直接等价物:hg log-r'\u first祖先(…)'
有一个直接的等价物:隐藏的revset\u first祖先
跟随每个合并的第一个父级(p1)端。在Mercurial中,就像在Git中一样,第一个父级是在调用hg merge[second parent]
时签出的提交
hg log-r'\u第一祖先(myfeature)
“hidden”表示它以下划线开头,不在帮助等中列出,但如果您知道它存在,仍然可以使用。我不知道为什么它是隐藏的
例子
每当master
合并到分支中以使其更新时,此revset别名将列出功能分支上的所有提交,而忽略所有祖先。(我工作的商店更喜欢合并而不是重定基线)
用法示例(使用我自己的日志模板):
我不确定OP想要的是什么。听起来他可能想要一条历史的直线,因为他总是只关注合并的左侧。在看过git文档之后,我认为你是对的。这看起来很难。这是一个有趣的用例。你能告诉我你通过这样做想要实现什么吗?我不相信在Mercurial中有一个命令可以做到这一点。但我不明白您为什么要这么做。@Omnifarious我很好奇Mercurial是否有这样的功能。好吧,它可以拼凑在一起。但它对任何事情都不是非常有用。Mercurial的父级认为“第一”是武断的,没有关系对于任何特定的内容(我认为它对散列进行排序,“最低散列”是第一个父级)。@Omnifarious在git中,第一个父级是运行
git merge
时签出的任何提交。因此,如果我将分支功能合并到主级(即在主级上,git merge功能
),当前主提交是合并提交的第一个父级,而如果我将分支主提交合并到功能中(即在功能上,git merge master
),当前功能提交是合并提交的第一个父级。我想情况就是这样。你知道,Mercurial一定在做类似的事情。因为它总是将父级0列为最小哈希,但有时它会以不同的顺序列出父级1和父级0,似乎与“合并中”父级相关。嗯…如果你需要这样的行为,我建议使用Mercurial中的命名分支。这是实现类似操作的更可靠的方法。只需确保你想要所有数据的“特殊”分支有一个特定的名称。然后你可以使用revset语言非常容易地只选择属于它一部分的更改。1.不推荐使用,因为(我想)revset做得更好2.阅读关于-r参数和选项的内容(再次阅读最坏情况下的revset)用于指定范围或某些revision@LazyBadger如果revset做得更好,那么什么revset表达式等效于--follow first
?@Omnifarious命名分支确实在HG存储库本身的情况下工作(HG log-g-r'分支(稳定)“
给出了与hglog-G相同的输出——跟随第一行(包括笨拙的合并行)),但是,如果我正在查看的存储库不在我的控制之下,并且不以这种方式使用命名分支,该怎么办?@Omnifarious我说得太快了:它们实际上只在前1000行中提供相同的输出;diff-u显然我对revset语言没有完全的掌握。@Omnifarious-别担心,我当前的revset答案是同样,buggy和我尝试(现在)润色它(有很长很难阅读的行,甚至还没有最终版本),我仍然没有
>hg glog -r 410:426 --template "{rev} - {desc|firstline|fill68}\n"
o 426 - Merge test fixes for dulwich changes and output changes.
|\
| o 425 - Merge incoming fix.
| |\
| | o 424 - getremotechanges: fix incoming support
| | |
o | | 423 - overlay: stop using deprecated tree.entries() method
| | |
| o | 422 - Fix all-version-tests.
| | |
o | | 421 - Test output format tweaks for test-outgoing.
| | |
o | | 420 - test-incoming: fixes for hg 1.7
| | |
| o | 419 - Merge fix for `hg out` failing on empty repo.
| |\ \
| | o | 418 - In some situations where a reference is being used but does not
| | | | exist in _map_git or _map_hg, silently skip the reference rather
| | | | than throwing an error. This allows hg outgoing to work on
| | | | repositories which do not contain any revisions at all.
| o | | 417 - only want heads and tags
| |/ /
| o | 416 - test-url-parsing: update expecations missed by edaadbd99074
| | |
| o | 415 - to be recognized port number in path to repository
| | |
| o | 414 - Unbreak outgoing to non-git repos with hg pre-1.9
| | |
| o | 413 - test fixes for progress cleanup
| |/
| o 412 - Fix mercurial issue2855
| |
| o 411 - Convert dulwich progress into mercurial ui.progress
|/
o 410 - test-incoming: only run on hg 1.7.x and newer
[revsetalias]
feature($1) = _firstancestors($1) and not _firstancestors(master)
[alias]
f = log -r "feature($(echo $HG_ARGS| sed 's/^f //'))"
$ hg f myfeature
o 423 myfeature default/myfeature -- Esteis -- 2016-07-12 -- 123abc
| this
o 422 -- Esteis -- 2016-07-12 -- 123def
|\ merge master into myfeature
o ~ 421 -- Esteis -- 2016-07-12 -- 456abc
| that
o 420 -- Esteis -- 2016-07-12 -- 789def
| and the other