質問

I'm writing a mercurial extension and I need to store a small amount of metadata. This is a dumb example, but enough to get something like this to work:

$ hg myextension --set a=2
$ hg myextension --get a
2

This data does not need to be copied if the repo is cloned, although if that's easy it would be cool to do that.

What is the proper way to do this in a mercurial extension? Is there a folder under .hg that I can just create arbitrary files in or something like that?

役に立ちましたか?

解決

There is no built-in mechanism for this — each extension decides how to best store the data. Extensions usually store their data in a file or directory named after themselves, so you could use

.hg/myextension/

as your root. You can use repo.opener to open files inside that directory:

fp = repo.opener('myextension/state.json')
data = json.load(fp)
fp.close()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top