Custom revision properties in Mercurial?

后端 未结 2 1145
孤独总比滥情好
孤独总比滥情好 2021-01-22 15:06

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 fo

相关标签:
2条回答
  • 2021-01-22 15:16

    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.

    0 讨论(0)
  • 2021-01-22 15:22

    This could be a job for:

    • a pre-commit hook in Mercurial (not a precommit hook which runs before the internal commit occurs, when the list of files to commit is already known. But "pre-commit", a generic hook which runs before the commit begin)
    • a git pre-commit hook (but you need to add your file with the updated weather information to the list of files to be committed)

    In both cases, said hooks would get the information you need and update one specific file in charge of keeping that property.

    0 讨论(0)
提交回复
热议问题