使用 Mercurial,如果经常提交中间状态,如何与固定修订版进行比较?

发布于 2024-09-08 07:38:14 字数 988 浏览 2 评论 0原文

使用 Mercurial,假设我执行了 hg pullhg up,现在本地存储库和工作目录都是最新的。

如果我经常提交,比如 1 天后,然后 2 天后,并且想要与现在的修订版本进行比较,该怎么办?

否则,差异始终与先前提交的版本进行比较。

我可以立即使用铅笔和纸写下修订号,例如 4117,然后在 1 天后、2 天后以及我确信之前的任何时间将其推送到远程中央存储库,执行

hg vdiff -r 4117      

(使用 vdiffdiff)。但是,除了记住这个“神奇的数字”4117,有没有办法让 Mercurial 以某种方式记住这个数字呢?这样,hg vdiff 可以查看针对已提交代码的微小更改之间的差异,但在推送到远程存储库之前有一个显示所有更改的差异。

(或者,如果有命令显示自上次拉取以来的修订号,它也应该显示 4117,所以在 bash 上我们可以执行类似 hg vdiff -r `hg --what -is-last-pull` )

更新:hg out --patch 是否显示将推送到远程存储库的内容的差异?如果是这样,也许它可以达到目的,而无需关心“神奇数字”。但是如何使用 kdiff3 或任何其他差异工具显示补丁差异?另外,似乎我们可以执行 hg out ,如果我们看到 4118、4119、4120,那么我们就知道是否执行 hg vdiff -r ___ 我们应该使用 (4118 - 1) 是 4117。

更新 2: 实际上,hg out --patch 显示了本地存储库和远程存储库之间的差异,因此它很接近,但不完全是与工作目录和本地或远程存储库之间的差异相同。

Using Mercurial, say if I do an hg pull and hg up and now the local repo and working directory are both up to date.

What if I commit often, say 1 day later, and then 2 days later, and want to diff with the revision as of right now?

Otherwise, the diff is always comparing to the previous committed version.

I can use pencil and paper and write down the revision number right now, say, 4117, and then 1 day later, 2 days later, and any time before I am sure and push to the remote central repo, do an

hg vdiff -r 4117      

(either using vdiff or diff). But instead of remembering this "magic number" 4117, is there a way to make Mercurial somehow remember this number? That way, hg vdiff is to see the difference between minor changes against committed code, but there is a diff that shows all changes before pushing to the remote repo.

(or, if there is command that shows the revision number since your last pull, which should also show 4117, so on bash we can do something like hg vdiff -r `hg --what-is-last-pull` )

Update: does hg out --patch show the diff of what would be pushed to the remote repo? If so, maybe it serves the purpose without caring the "magic number". But how to show the patch diff using kdiff3 or any other diff tools? Also, it seems we can do hg out and if we see 4118, 4119, 4120, then we know if we do hg vdiff -r ___ we should use (4118 - 1) which is 4117.

Update 2: actually, hg out --patch shows the diff between local repo and the remote repo, so it is close, but not exactly the same as the diff between working directory and the local or remote repo.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

盛夏尉蓝 2024-09-15 07:38:14

如果您想标记修订版本,可以使用书签扩展。它与 Mercurial 一起发货。文档可在此处获取

对于您的情况,

hg pull -u
hg bookmarks lastpull
..hack..hack..
hg ci -m new-hack
hg diff -r lastpull:tip
hg bookmarks -d lastpull

If you want to mark a revision you can use bookmarks extensions. It is shipped with mercurial. Documentationis available here

In your case,

hg pull -u
hg bookmarks lastpull
..hack..hack..
hg ci -m new-hack
hg diff -r lastpull:tip
hg bookmarks -d lastpull
给不了的爱 2024-09-15 07:38:14

使用多个克隆来完成此操作。当您从远程存储库克隆时,最初使用 clone -U 创建一个根本没有工作目录文件的克隆。然后在本地再次克隆,例如:

$ hg clone my-local-clone-with-no-working-files my-working-clone

my-working-clone 中进行提交和工作,然后您可以随时检查 my-local-clone- 中的 tip with-no-working-files 来查看您从服务器中提取的最后一个内容是什么。如果你想变得更奇特,你可以为以下内容创建一个 shell 别名:

hg diff -r $(hg -R $(hg root)/../my-local-clone-with-no-working-files id -i -r tip)

它将比较你运行它的存储库的工作目录(my-working-clone)与你上次从服务器拉取的内容的提示。

这不需要额外的磁盘空间,这是没有价值的,因为本地克隆在幕后使用硬链接,my-local-clone-with-no-working-files没有工作目录文件。

Do it with multiple clones. When you clone from the remote repo initially use clone -U to create a clone that has no working directory files at all. Then clone again locally, for example:

$ hg clone my-local-clone-with-no-working-files my-working-clone

Do your commits and work in my-working-clone and then at any time you can check the tip in my-local-clone-with-no-working-files to see what the last thing you pulled from the server was. If you want to get fancy you could create a shell alias for:

hg diff -r $(hg -R $(hg root)/../my-local-clone-with-no-working-files id -i -r tip)

which will compare the working directory of the repo in which you run it (my-working-clone) with the tip of whatever you last pulled from the server.

It's worth nothing that this takes no extra disk space because local clones use hardlinks under the covers the the my-local-clone-with-no-working-files has no working directory files.

才能让你更想念 2024-09-15 07:38:14

您可以用本地标签替换笔和纸:hg tag -l -r <纸上的修订号>标记名。请注意 -l,它使标签成为本地标签,这意味着它不会通过推和拉来传输。您还可以通过hg tag -l --remove tagname删除此标签。

You can replace pen and paper with a local tag: hg tag -l -r <revision number on paper> tagname. Notice the -l, which makes the tag local, which means it does not get transferred by push and pull. You can also remove this tag by hg tag -l --remove tagname.

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