Mercurial - how to find first commit on specific branch

左心房为你撑大大i 提交于 2019-12-10 15:47:08

问题


I wan't to determine the age of the "foo" branch. As I understand it is impossible to get this info straight. I trying to write command that will find information about first commit on the "foo" branch.

hg log -r "parents(min(branch(foo)))"

This one returns not exactly what I want. Can somebody help me?


回答1:


Does this give you what you need?

hg log -r "branch(default) and 0:" -l 1 --template "{date|isodate}\n"

I think this gives you the date of the first changeset on the named branch.

So, first changeset on branch "testbranch"

% hg log -r "branch(testbranch) and 0:" -l 1
changeset:   107:bd91c8e6fa5f
branch:      testbranch
user:        Nick Pierpoint
date:        Fri May 15 15:16:44 2015 +0100
summary:     test one

... adding the template just to get the date:

% hg log -r "branch(testbranch) and 0:" -l 1 --template "{date|isodate}\n"
2015-05-15 15:16 +0100

Your min also works if you always want to return a single changeset:

% hg log -r "min(branch(testbranch))"
changeset:   107:bd91c8e6fa5f
branch:      testbranch
user:        Nick Pierpoint <nick.pierpoint@uk.bp.com>
date:        Fri May 15 15:16:44 2015 +0100
summary:     test one



回答2:


I should write it without parents:

hg log -r "min(branch(foo))"

Now it does what I need.



来源:https://stackoverflow.com/questions/30258322/mercurial-how-to-find-first-commit-on-specific-branch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!