创建一个新分支,做了很多更改,如何查看更改的文件列表?
因此创建了一个新分支,我们对代码库进行了一些重大更改。
现在我们要合并,但在此之前我想获取分支中更改的所有文件的列表。
如何获取文件列表?我尝试过:
hg status --change REV
但我不确定这是否是我想要的,因为我希望在此分支中更改所有文件,而不是分支中的特定修订版。
顺便说一句,我如何查看修订号?
So there was a new branch created where we made some breaking changes to the codebase.
Now we are going to merge, but before that I want to get a list of all the files that were changed in the branch.
How can I get a list of files? I tried:
hg status --change REV
But i'm not sure if that is what I want, since I want all files changed in this branch and not a specific revision in the branch.
BTW, how can I view the revision numbers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试
获取分支上第一个和最后一个变更集之间的更改(
hg status
将隐式使用min(branch('your-branch'))
和>max(branch('your-branch'))
当你给它一系列的修改时,像这样)。由于您将进行合并,因此您应该真正查看一下
default
分支和your-branch
之间发生了什么变化。这会向您显示已完成的修改,并过滤掉由于与default
合并而在分支上完成的任何修改。如果您的历史记录如下所示,这是必要的:
您已经将
default
多次合并到您的分支中。将default
合并到您的分支中是正常的,因为您希望定期集成该分支中的最新内容,以避免分支彼此相距太远。但是,如果在
default
上引入了一个新文件,然后合并到B
中,那么您并不想在hg status
中看到它> 输出。如果您这样做,您将会看到它,因为该文件不存在于
a
中,但存在于y
中。如果这样做,那么您将不会在输出中看到该文件,假设它存在于两个头中。
您在评论中写道,您正在使用 Kiln 存储库。当他们说“分支”时,他们的意思是“克隆”,但上面的内容仍然可以根据您的情况进行调整。所有变更集都将位于
默认
命名分支上,但这没关系。在“branch”存储库的本地克隆中运行以下命令:
这将当前提示标记为
mybranch
的头部。然后从主存储库中提取所有变更集:然后将 new 提示标记为主存储库的提示:
您现在可以运行
以查看
main
和 <代码>我的分支。如果你想查看你在分支本身上做了什么,使用::mybranch
部分将选择作为mybranch
祖先的变更集 - 这是你的所有新工作,加上你分支之前的旧历史。我们使用- ::main
删除旧历史记录。在旧版本的 Mercurial 中,您可以使用hg log -r -r mybranch:0 -P main
。Try with
to get the changes between the first and the last changeset on the branch (
hg status
will implicitly usemin(branch('your-branch'))
andmax(branch('your-branch'))
when you give it a range of revisions like this).Since you'll be merging, you should really look at
to see what is changed between the
default
branch andyour-branch
. This shows you the modifications done, and filters out any modifications done on the branch due to merges withdefault
.This is necessary in case your history looks like this:
where you've already merged
default
into your branch a couple of times. Mergingdefault
into your branch is normal since you want to regularly integrate the latest stuff from that branch to avoid the branches drifting too far away from each other.But if a new file was introduced on
default
and later merged up intoB
, then you don't really want to see that in thehg status
output. You will see it if you dosince the file was not present in
a
, but is present iny
. If you dothen you wont see the file in the output, assuming that it's present in both heads.
You write in a comment that you're working Kiln repository. They mean "clone" when they say "branch", but the above can still be adapted for your case. All changesets will be on the
default
named branch, but that's okay.Run the following command in your local clone of the "branch" repository:
This marks the current tip as the head of
mybranch
. Then pull all the changesets from the main repository:You then mark the new tip as the tip of the main repository:
You can now run
to see the changes between
main
andmy-branch
. If you want to see what you did on the branch itself, the useThe
::mybranch
part will select changesets that are ancestors ofmybranch
— this is all your new work, plus old history from before you branched. We remove the old history with- ::main
. In older versions of Mercurial, you would usehg log -r -r mybranch:0 -P main
.在这种情况下,我更喜欢从新签出的存储库副本进行测试合并。这样做的好处是我可以看到合并会产生多少冲突,并且我可以保留合并结果,因为我是在它自己的副本中进行的。
In cases like this, I prefer to do a test merge from a newly checked-out copy of the repo. This has the advantage that I can see how many conflicts the merge will produce, and I can keep the merge result because I did it in its own copy.
要查看修订号,请启用 graphlog 扩展 并运行:
这将为您提供一个漂亮的 ASCII 图表。这可以方便地快速查看图表,但我建议使用 TortoiseHg 作为跨平台日志查看器:
< img src="https://i.sstatic.net/yUCER.png" alt="TortoiseHg 2.0 工作台">
To view the revision numbers, enable the graphlog extension and run:
This gives you a nice ASCII graph. This can be handy to quickly look at the graph, but I recommend using TortoiseHg for a cross-platform log viewer:
我必须将默认分支合并到我的分支中才能获得一些修复,现在上面的命令还显示由于合并而更改的文件(此文件在默认分支中再次合并后发生了更改)。
因此,为了仅获取正确的文件,我使用如下方法:
如果文件名中有空格,则可以这样做:
并且为了回答您的最后一个问题,修订版本可以这样显示:
提示:我使用 hg-别名:
I had to merge the default branch into my branch to get some fixes, now the commands above shows also files changed because of merges (this files changed after the merge again in the default branch).
Therefore, to get only the correct files I use something like this:
if you have spaces in file names, you can do it this way:
And to answer your last question, revisions can be shown this way:
TIP: I use a hg-alias for this:
使用mercurial,如果您想获取当前分支中更改的所有文件的列表(更改集的更改),您可以使用以下命令: :
结果示例:
命令说明:
显示整个存储库或文件的修订历史记录,并输出 diffstat 样式的更改摘要
显示当前分支名称
搜索文本模式,在本例中为“|”
空格分隔符表示记录中的每个字段并在新行中打印每个字段
对所有打印行进行排序并删除重复项
With mercurial, if you want to get the list of all the files changed in your current branch (changes done of your changeset) you can use these commands: :
Example result:
Explanation of the commands:
Show revision history of entire repository or files and output diffstat-style summary of changes
Show the current branch name
Search for a text pattern, in this case, it is "|"
Space separator denotes each field in a record and prints each one in a new line
Sort all the printed lines and delete duplicates