如何获取 Mercurial 中未提交更改的年龄?

发布于 2024-10-13 23:02:33 字数 257 浏览 3 评论 0原文

前几天我看到一个非常简洁的命令行提示符。一个人正在使用 ZSH 并定制了他的提示来显示自他上次提交以来已经过去了多长时间。我认为这非常棒,并且想做类似的事情。

问题是他使用的是 git,而我更喜欢 Mercurial。

获取自上次提交以来已经过去了多长时间很容易,但会产生误导。如果我提交更改,花一个小时做其他事情,然后返回我的代码库,它会说距离我上次提交已经过去一个小时了。因此,我正在查找自更改开始以来的时间。这是否可以通过 shell 实现,还是必须是一个插件?

I saw a pretty neat command line prompt the other day. A guy was using ZSH and customized his prompt to display how long it had been since his last commit. I think this is pretty awesome and would like to do something similar.

The catch is that he was using git, and I prefer Mercurial.

Getting how long it's been since the last commit is easy enough, but misleading. If I commit changes, do something else for an hour, then come back to my codebase, it will say it's been an hour since my last commit. So I'm looking for the time it's been since the changes were started. Is this even possible through the shell or would it have to be a plugin?

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

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

发布评论

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

评论(2

杀手六號 2024-10-20 23:02:33

我期待 Steve Losh 的 hg-prompt (http://stevelosh.com/projects/hg-prompt/< /a>) 可以修改为您想要的。它是完全可定制的,所以如果它是一个定义明确的可编程任务,它可能会卡在那里。

不过,我已经读过你的问题几次了,但仍然不清楚你到底想要什么。

你说“定制他的提示以显示自他上次提交以来已经过去了多长时间”。进而
“想做类似的事情。”然而,“获取自上次提交以来已经过去了多长时间很容易,但会产生误导。”?

那么我不明白你所说的“所以我正在寻找自更改开始以来的时间”是什么意思。

I expect Steve Losh's hg-prompt (http://stevelosh.com/projects/hg-prompt/) could be modified to do what you want. It's quite customizable, so if it is a well defined programmable task, it could be stuck in there.

However, I've read your question a couple of times, and am still not clear what you want exactly.

You said "customized his prompt to display how long it had been since his last commit." and then
"would like to do something similar." However "Getting how long it's been since the last commit is easy enough, but misleading."?

I then don't understand what you mean by "So I'm looking for the time it's been since the changes were started."

初相遇 2024-10-20 23:02:33

您可以获取具有未提交更改的文件列表,并获取最早的修改日期。但是,如果您在上次提交后一分钟更改了文件,但五分钟前更改了同一文件,则只有最近的更改才算在内。

我有一个提示钩子,可以显示已修改文件的数量、当前修订号、分支和标记名称,但每次显示 shell 提示符时都需要花费大量时间来执行。但目前无法提供任何相关细节。

You could get a list of files that have uncommitted changes, and get the earliest modified date. However, if you changed a file one minute since your last commit, but then changed that same file five minutes ago, only the most recent change would count.

I have a prompt hook that shows me the number of modified files, the current revision number, branch and tag name, but it takes a noticeable amount of time to execute each time the shell prompt is shown. Can't provide any details about it right now though.

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