Mercurial 中的自定义修订属性?
我可以为我的 hg 存储库设置自定义属性,以便我可以存储/检索每个修订版的值吗?例如,提交时东京的天气等。
对于 git 来说也是如此吗?
Can I setup a custom property for my hg repository so that I could store/retrieve its value for each revision? Like, weather in Tokyo at the time of commit, etc.
Same for git?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Mercurial 没有像 Subversion 那样内置管理属性的方式。不过,它确实有一些基础设施。您必须编写扩展并决定是否希望元数据位于历史记录内部还是外部:
历史记录外部的元数据:
书签扩展将是一个很好的起点,因为它已经向您展示了如何管理历史元数据以及如何在推拉时移动此类数据。
历史中的元数据:
当数据成为历史记录的一部分时,您的扩展的事情就会变得更简单。 移植扩展是一个扩展示例,它通过内部提交函数的
extra
字典参数。恐怕我不了解 Git。
Mercurial has not built-in way of managing properties in the way that Subversion has. It does have some infrastructure for it, though. You'll have to write an extension and decide if you want the meta data to live inside or outside the history:
Meta data outside of history:
The bookmarks extension would be a good starting point since it already shows you how to manage out-of-history meta data and how to move such data around on push and pull.
Meta data in the history:
When the data is part of the history, things are simpler for your extension. The transplant extension is an example of an extension that embeds extra meta data into changesets via the
extra
dictionary argument to the internal commit function.I'm afraid I don't know about Git.
这可能是一个工作:
在这两种情况下,所述挂钩都会获取您需要的信息并更新负责保留该属性的特定文件。
This could be a job for:
In both cases, said hooks would get the information you need and update one specific file in charge of keeping that property.