区分 Hg 中的两个版本
我正在尝试查看项目的两个版本之间的差异。我最初想到的方式是:
- 创建新存储库
- 将第一个版本提交到存储库
- 用第二个版本覆盖第一个版本,将
- 两个版本提交到存储库
hg diff
这不起作用,因为当第二个版本覆盖时第一个版本 Mercurial 假定每个文件都已更改。实际上,只有几个文件被更改,我想看看每个文件中具体更改了什么。
WinDiff 为我提供了已更改文件的列表,但仅此而已,所以我真的很想使用 Hg 来获取详细信息。
编辑:我正在使用 Eclipse。我具体要做的是创建一个新的 Java 项目,使用 Eclipse 的导入功能导入我想要的源文件,然后将该项目提交到我的存储库。然后,我再次使用 import 将版本 2 导入到同一个项目中,以便覆盖第一个版本中的文件。我留下的文件名称相同,但都是版本 2 文件。然后我将新文件提交到存储库。
我的 Mercurial 版本是 1.8.3。执行上述步骤只给我一个变更集。
另外,在创建 diff 时,有没有办法指定仅 diff Java 文件,而不是文本或属性等?
I am trying to view the differences between two versions of a project. The way I initially thought to do it:
- Create new repository
- Commit first version to repository
- Overwrite first version with second version, commit to repository
hg diff
the two versions
This did not work, because when the second version overwrote the first version Mercurial assumed every single file was changed. In reality only a few files are changed, and I want to see what specifically was changed in each file.
WinDiff gives me a list of the files that were changed but that is it, so I would really like to use Hg to get the specifics.
EDIT: I am using Eclipse. What I specifically am doing is creating a new Java project, using Eclipse's import feature to import the source files I want, and then commit that project to my repository. I then use import again to import version 2 into the same project so that the files from the first are overwritten. I am left with files that are named the same but that are version 2 files. I then commit the new files to the repository.
My Mercurial version is 1.8.3. Doing the steps above gives me just one changeset.
Also, when creating the diff is there a way to specify to only diff Java files, not text or properties, etc.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的程序是健全的,只要记住像 Lasse 在评论中指出的那样使用
hg addremove
即可。因此,完整的过程是:hg add
和hg commit
.hg
之外的所有文件hg addremove
和hg commit
hg diff
两个版本hg addremove
步骤甚至会检测以下文件:两个版本之间已重命名。你还写:是的,您可以使用
--include
标志来实现此目的:Your procedure is sound, just remember to use
hg addremove
like Lasse pointed out in the comments. So the full procedure is:hg add
andhg commit
.hg
hg addremove
andhg commit
hg diff
the two versionsThe
hg addremove
step will even detect files that have been renamed between the two versions. You also write:Yes, you can use the
--include
flag for this:我不明白为什么你不能在项目的原始存储库上直接使用 Mercurial。
要查看项目的 REV1 和 REV2 之间 Java 文件发生了哪些变化:
I don't get it why your can't directly use Mercurial on the original repository of your project.
To see what are the changes to Java files between REV1 and REV2 of your project:
要在 Eclipse 中比较文件的两个版本:
To diff two versions of a file in eclipse: