How to expand some version keywords in Mercurial?

左心房为你撑大大i 提交于 2019-12-23 09:38:27

问题


In CVS I could put $LOG$ into the source file and when the file is checked in $LOG$ will be expanded into true logs in the file.

But how to implement this in Mercurial? Of course I mean the other keyword such as the latest checkin date and time.


回答1:


For most of the problems keyword expansion solves it creates a whole heap more; isn't recommended in Mercurial CVS/RCS-like Keyword Substitution - Why You Don't Need It however it is documented how to do it with expansions if you really need to.

I'm not the only one to advise against keyword expansion, although there are times it can be useful one really needs to think hard before doing it.




回答2:


Use the built-in keyword extension.

A couple of important things:

  1. ONLY add the specific files you need keyword expansion to the filename pattern in hgrc [keyword].
  2. The expansion is LOCAL. When your changeset is pushed to another repo, unless that repo also has the same keyword setup, keyword is NOT expanded.

I agree that it should be avoided whenever possible. When it is not possible to avoid is that you need to distribute a few selected files (for example, API headers) to other people (for example, API users), such that there's no way they can use hg to find out the version info.



来源:https://stackoverflow.com/questions/3032251/how-to-expand-some-version-keywords-in-mercurial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!