Mercurial - 查看需要手动合并的文件列表?
是否有一个 Mercurial 命令可以在 hg pull
之后使用来查看在进行 hg merge< 时需要手动合并的所有文件的列表(即:有冲突的文件) /代码>?
Is there a Mercurial command you can use after an hg pull
to see a list of all files that will be need to be manually merged (ie: that have conflicts) when doing an hg merge
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
hg resolve --list
来自文档:
2012 年 1 月 5 日编辑:
(今天我收到了对此答案的赞成票,所以我重新审视了它。我发现我误解了这个问题。)
问题是“我已经执行了从远程存储库拉取并且尚未执行合并,我可以看看执行合并时会产生什么冲突吗?”
我上面的回答显然是错误的。阅读链接的文档后,我认为没有内置方法可以执行此操作。但是,有一种方法可以在不破坏您的工作源代码树的情况下做到这一点。
假设您已将存储库A从某个远程源克隆到本地系统上的存储库B,即
hg clone http://hg.example.com/A B
。完成此操作后,您对本地存储库 B 进行更改,这至少涉及一次提交。与此同时,对存储库A进行了更改,因此当您进行拉取时,您会收到一条消息,指示已添加新的变更集并已创建头。此时,您可以执行
hg Heads
来列出合并中涉及的两个变更集。根据此信息,您可以发出状态命令来列出磁头之间的差异。假设您的存储库中的修订号B(根据头列表)为“1”和“2”,那么您可以执行hg status --rev 1:2
查看更改列表。当然,这并不能真正告诉您在进行合并时是否会发生冲突。由于没有命令可以向您显示这一点,因此您必须通过克隆到新存储库并在那里进行合并来“预览”合并。所以,hg 克隆 BC &&光盘C&& hg 合并。如果您对此合并的结果感到满意,您可以执行
hg com -m 'Merging Complete' &&汞推&& cd ../&& rm -rf C
。这是一个有点过程,但如果合并结果是一场灾难,它可以使您当前的源代码树保持干净。您可能还会发现此描述对使用公共存储库很有帮助。
hg resolve --list
From the documentation:
Edit 5 January 2012:
(I received an up vote for this answer today so I revisited it. I discovered that I misunderstood the question.)
The question is "I have performed a pull from a remote repository and have not yet performed a merge. Can I see what conflicts will be created upon performing the merge?"
My answer above is clearly wrong. After reading through the linked documentation, I do not think there is a built-in method for doing this. However, there is a way to do it without ruining your working source tree.
Let's assume you have cloned repository A from some remote source to repository B on your local system, i.e.
hg clone http://hg.example.com/A B
. After doing so, you make changes to your local repository, B, that involve at least one commit. In the meantime, changes have been made to repository A so that when you do a pull you get a message indicated new changesets have been added and heads have been created.At this point, you can do
hg heads
to list the two changesets that will be involved in a merge. From this information, you can issue a status command to list the differences between the heads. Assuming the revision numbers in your repository B, according to the heads list, are "1" and "2", then you can dohg status --rev 1:2
to see a list of the changes.Of course, this doesn't really tell you if conflicts will occur when you do a merge. Since there isn't a command that will show you this, you will have to "preview" the merge by cloning to a new repository and doing the merge there. So,
hg clone B C && cd C && hg merge
. If you are satisfied with the result of this merge you can dohg com -m 'Merging complete' && hg push && cd ../ && rm -rf C
.It's a bit of a process, but it keeps your current source tree clean if the merge turns out to be a disaster. You might also find this description of working with public repositories helpful.
除非我自己误读,否则上面的答案似乎并没有解决我认为被问到的问题:我的存储库中有两个分支我想合并,我想知道会发生什么冲突(例如,在逐一解决冲突之前。)
为此,我将与
:merge3
工具合并(它会尝试自动合并,但会留下未解决的冲突),然后使用 hg resolve --list 或仅查看 merge 命令的输出来查看冲突。如果您实际上不想最终合并(如果您只是想看看会发生什么冲突),您可以稍后运行
hg update -C
来撤消合并。如果您确实想完成合并,可以对每个文件运行
hg resolve
,或者仅运行hg resolve --all
来逐步执行剩余的所有内容在hg commit
合并变更集之前发生冲突。Unless I'm misreading it myself, the answers above don't seem to address the question that I think is being asked: I have two branches in my repository that I'd like to merge, and I want to know what conflicts will come up (e.g., before stepping through the conflict resolutions one-by-one.)
To do this, I would merge with the
:merge3
tool (which tries to merge automatically, but leaves conflicts unresolved) and then usehg resolve --list
— or just look at the output of merge command — to see the conflicts.If you didn't actually want to merge in the end (if you just want to see what would conflict) you can run
hg update -C
afterwards to undo the merge.If you do want to finish the merge, you can run
hg resolve <filepath>
for each file, or justhg resolve --all
to step through all that remain with conflicts, before youhg commit
the merge changeset.您可以将 hg stat 的 --rev 选项与一对修订版本一起使用,以查看两者之间存在哪些文件差异。请参阅下面的稍微冗长但详细的示例:
首先,我们首先创建一个新存储库:
然后将一个名为
foo.txt
的文件添加到新存储库:现在添加第二个文件,名为
bar.txt
作为修订版 1:返回修订版 0,并在不同的头部添加第三个文件。这样做是为了模拟从在起始版本克隆相同存储库的其他人那里进行拉取:
现在您可以使用 hg stat 查看任何对之间存在哪些文件差异修订版,例如从 rev 0 到 rev 1 的更改将“bar.txt”添加到文件列表:
从 rev 0 到 rev2 的更改将“koko.txt”添加到文件列表:
但更有趣的是,从 rev 1 的更改修订版 2 涉及两个 文件清单更改。 (1) 'koko.txt' 已在修订版 2 中添加,(2) 'bar.txt' 存在于修订版 1 中,但在修订版 2 中缺失,因此显示为“已删除”文件:
You can use the --rev option of hg stat with a pair of revisions to see what file differences exist between the two. See below for a slightly verbose but detailed example:
First we start by making a new repository:
Then add a single file called
foo.txt
to the new repository:Now add a second file, called
bar.txt
as revision 1:Go back to revision 0, and add a third file, on a different head. This is done to simulate a pull from someone else who had cloned the same repository at its starting revision:
Now you can use hg stat to see what file differences exist between any pair of revisions, e.g. the changes from rev 0 to rev 1 added 'bar.txt' to the file list:
The changes from rev 0 to rev2 added 'koko.txt' to the file list:
But more interestingly, the changes from rev 1 to rev 2 involve two file manifest changes. (1) 'koko.txt' was added in rev 2, and (2) 'bar.txt' exists in rev 1 but is missing from rev 2, so it shows as a 'removed' file:
我认为
hg status
就是您正在寻找的。您可能需要阅读 Mercurial:权威指南
http: //hgbook.red-bean.com/read/mercurial-in-daily-use.html
I think
hg status
is what you are looking for.You may want to read this chapter from Mercurial: The Definitive Guide
http://hgbook.red-bean.com/read/mercurial-in-daily-use.html