Mercurial - 查看需要手动合并的文件列表?

发布于 2024-10-14 16:46:56 字数 121 浏览 1 评论 0原文

是否有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酷遇一生 2024-10-21 16:46:56

hg resolve --list

来自文档

具有未解决冲突的合并通常是使用internal:merge 配置设置或diff3 等命令行合并工具进行非交互式合并的结果。在运行 hg merge 之后、运行 hg commit 之前,resolve 命令用于管理合并中涉及的文件(即工作目录必须有两个父目录)。

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:

Merges with unresolved conflicts are often the result of non-interactive merging using the internal:merge configuration setting, or a command-line merge tool like diff3. The resolve command is used to manage the files involved in a merge, after hg merge has been run, and before hg commit is run (i.e. the working directory must have two parents).

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 do hg 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 do hg 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.

与酒说心事 2024-10-21 16:46:56

除非我自己误读,否则上面的答案似乎并没有解决我认为被问到的问题:我的存储库中有两个分支我想合并,我想知道会发生什么冲突(例如,在逐一解决冲突之前。)

为此,我将与 :merge3 工具合并(它会尝试自动合并,但会留下未解决的冲突),然后使用 hg resolve --list 或仅查看 merge 命令的输出来查看冲突。

hg merge <otherbranch> --tool :merge3
hg resolve -l

如果您实际上不想最终合并(如果您只是想看看会发生什么冲突),您可以稍后运行 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 use hg resolve --list — or just look at the output of merge command — to see the conflicts.

hg merge <otherbranch> --tool :merge3
hg resolve -l

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 just hg resolve --all to step through all that remain with conflicts, before you hg commit the merge changeset.

眼眸 2024-10-21 16:46:56

您可以将 hg stat--rev 选项与一对修订版本一起使用,以查看两者之间存在哪些文件差异。请参阅下面的稍微冗长但详细的示例:

首先,我们首先创建一个新存储库:

[gkeramidas /tmp]$ hg init foo
[gkeramidas /tmp]$ cd foo

然后将一个名为 foo.txt 的文件添加到新存储库:

[gkeramidas /tmp/foo]$ echo foo > foo.txt
[gkeramidas /tmp/foo]$ hg commit -Am 'add foo'
adding foo.txt
[gkeramidas /tmp/foo]$ hg glog
@  0[tip]   b7ac7bd864b7   2011-01-30 18:11 -0800   gkeramidas
     add foo

现在添加第二个文件,名为 bar.txt 作为修订版 1:

[gkeramidas /tmp/foo]$ echo bar > bar.txt
[gkeramidas /tmp/foo]$ hg commit -Am 'add bar'
adding bar.txt

返回修订版 0,并在不同的头部添加第三个文件。这样做是为了模拟从在起始版本克隆相同存储库的其他人那里进行拉取:

[gkeramidas /tmp/foo]$ hg up -C 0
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[gkeramidas /tmp/foo]$ echo koko > koko.txt
[gkeramidas /tmp/foo]$ hg commit -Am 'add koko'
adding koko.txt
created new head
[gkeramidas /tmp/foo]$ hg glog
@  2[tip]:0   e5d80abdcb06   2011-01-30 18:12 -0800   gkeramidas
|    add koko
|
| o  1   a2d0d0e66ce4   2011-01-30 18:12 -0800   gkeramidas
|/     add bar
|
o  0   b7ac7bd864b7   2011-01-30 18:11 -0800   gkeramidas
     add foo

现在您可以使用 hg stat 查看任何对之间存在哪些文件差异修订版,例如从 rev 0 到 rev 1 的更改将“bar.txt”添加到文件列表:

[gkeramidas /tmp/foo]$ hg stat --rev 0:1
A bar.txt

从 rev 0 到 rev2 的更改将“koko.txt”添加到文件列表:

[gkeramidas /tmp/foo]$ hg stat --rev 0:2
A koko.txt

但更有趣的是,从 rev 1 的更改修订版 2 涉及两个 文件清单更改。 (1) 'koko.txt' 已在修订版 2 中添加,(2) 'bar.txt' 存在于修订版 1 中,但在修订版 2 中缺失,因此显示为“已删除”文件:

[gkeramidas /tmp/foo]$ hg stat --rev 1:2
A koko.txt
R bar.txt

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:

[gkeramidas /tmp]$ hg init foo
[gkeramidas /tmp]$ cd foo

Then add a single file called foo.txt to the new repository:

[gkeramidas /tmp/foo]$ echo foo > foo.txt
[gkeramidas /tmp/foo]$ hg commit -Am 'add foo'
adding foo.txt
[gkeramidas /tmp/foo]$ hg glog
@  0[tip]   b7ac7bd864b7   2011-01-30 18:11 -0800   gkeramidas
     add foo

Now add a second file, called bar.txt as revision 1:

[gkeramidas /tmp/foo]$ echo bar > bar.txt
[gkeramidas /tmp/foo]$ hg commit -Am 'add bar'
adding bar.txt

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:

[gkeramidas /tmp/foo]$ hg up -C 0
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[gkeramidas /tmp/foo]$ echo koko > koko.txt
[gkeramidas /tmp/foo]$ hg commit -Am 'add koko'
adding koko.txt
created new head
[gkeramidas /tmp/foo]$ hg glog
@  2[tip]:0   e5d80abdcb06   2011-01-30 18:12 -0800   gkeramidas
|    add koko
|
| o  1   a2d0d0e66ce4   2011-01-30 18:12 -0800   gkeramidas
|/     add bar
|
o  0   b7ac7bd864b7   2011-01-30 18:11 -0800   gkeramidas
     add foo

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:

[gkeramidas /tmp/foo]$ hg stat --rev 0:1
A bar.txt

The changes from rev 0 to rev2 added 'koko.txt' to the file list:

[gkeramidas /tmp/foo]$ hg stat --rev 0:2
A koko.txt

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:

[gkeramidas /tmp/foo]$ hg stat --rev 1:2
A koko.txt
R bar.txt
苏璃陌 2024-10-21 16:46:56

我认为 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文