[英]Is there a Mercurial equivalent to git log --first-parent?
git log --first-parent
omits all but the first parent of merge commits. git log --first-parent
忽略除合并提交的第一个父项以外的所有内容。
Example: 例:
$ 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
Is there a Mercurial equivalent? 是否有水银当量?
hg log -r '_firstancestors(...)'
hg log -r '_firstancestors(...)'
There is a direct equivalent: the hidden revset _firstancestors
follows the first-parent (p1) side of each merge. 有一个直接的等效项:隐藏的revset
_firstancestors
跟随每个合并的第一父级(p1)。 In Mercurial, like in Git, the first parent is the commit that was checked-out when hg merge [second parent]
was called. 在Mercurial中,就像在Git中一样,第一父节点是在调用
hg merge [second parent]
时签出的提交。
hg log -r '_firstancestors(myfeature)'
'hidden' means that it starts with an underscore, and is not listed in the help etc., but can still be used if you know it exists. “隐藏”表示它以下划线开头,未在帮助等中列出,但是如果您知道它存在,仍可以使用。 I don't know why it is hidden.
我不知道为什么它被隐藏了。
This revset alias lists all commits on a feature branch while ignoring all the ancestry whenever master
is merged into the branch to bring it up-to-date. 该修订集别名列出了功能分支上的所有提交,而每当
master
合并到分支以使其为最新时,都会忽略所有祖先。 (The shop I work prefers merging over rebasing). (我工作的商店更喜欢合并而不是重新定级)。
[revsetalias]
feature($1) = _firstancestors($1) and not _firstancestors(master)
[alias]
f = log -r "feature($(echo $HG_ARGS| sed 's/^f //'))"
Example usage (uses my own logging template): 用法示例(使用我自己的日志记录模板):
$ 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
You can use revsets for this: 您可以为此使用revsets:
hg log -r "p1(merge())"
merge()
gets all the merge commits and p1()
gets the first parent of those commits. merge()
获取所有合并提交,而p1()
获取这些提交的第一个父级。
Use hg help revsets
to get more information on revsets. 使用
hg help revsets
可获得有关修订集的更多信息。
>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
Instead of extremely degenerated case from gist, I use part of real repository DAG (hg-git repository). 我使用了真正的仓库DAG(hg-git仓库)的一部分,而不是从要旨中极其退化的情况。 I hope, the selection is sufficiently indicative for the problem being solved.
我希望所选内容足以说明要解决的问题。
Needed revset (in plain English) will be
所需的revset(以简单的英语显示)为
"Range A:B without second parent and it's ancestors for mergesets"
“范围A:B,没有第二个父级,并且是合并集的祖先”
In revset functional language (TBT!)
使用修订功能语言(TBT!)
-r "410::426 - (p2(merge()) or ancestors(p2(merge())))"
In case of the full range of changesets as source more readable form will be something like
如果以变更集的全部范围为源,则更具可读性的格式将类似于
hg log -r "!(p2(merge()) or ancestors(p2(merge())))"
Edit 1 编辑1
I tested revset, rethought about methodology (instead of excluding I want only add needed to empty set), nearest iteration for my use-case for now (have bugs, can't find solution) is 我测试了revset,重新考虑了方法(而不是排除我只想向空集添加内容 ),目前我的用例最近的迭代(有错误,找不到解决方案)是
(p1(ancestors(p1(426))) or p1(426) or 426) and 410::426
which (still) include some unwanted revisions (仍然)包括一些不需要的修订
hg log --follow-first
seems to do roughly the same thing, with a few provisions: hg log --follow-first
似乎做大致相同的事情,但有一些规定:
It's deprecated (with no explanation that I can find). 不推荐使用(我找不到任何解释)。
I can't figure out how to get it to display anything other than just the straight-line history from the current changeset (eg display history following the first parent from two divergent heads (the equivalent of git log --first-parent branch-a branch-b
), although this may be just because of my lack of knowledge of Mercurial. 除了当前更改
git log --first-parent branch-a branch-b
的直线历史记录之外,我无法弄清楚如何显示它(例如,显示历史记录遵循两个发散头中的第一个父项(相当于git log --first-parent branch-a branch-b
),尽管这可能仅仅是因为我缺乏对Mercurial的了解。
It shows empty branch lines with hg log -G
: 它显示带有
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
The above example may not seem too bad, but see https://gist.github.com/MaxNanasy/5184202 for an example in which this behavior renders unwieldy output. 上面的示例可能看起来还不错,但是请参见https://gist.github.com/MaxNanasy/5184202 ,该示例将显示异常行为。
This issue may not matter much if issue #2 is insurmountable, because then hg log
without -G
would be the only useful way to use --follow-first
AFAICT. 如果问题#2是无法克服的,那么此问题可能不会有太大关系,因为不带
-G
hg log
将是使用--follow-first
AFAICT的唯一有用方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.