2

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
ulu
  • 5,872
  • 4
  • 42
  • 51

2 Answers2

5

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
  • Writing an extension is a great idea, however, I'm not ready to spend my time on it. I'll go the custom file way. Thanks anyway! – ulu Jan 05 '11 at 15:57
1

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks it was really profound, but I was asking about a different thing. What I'm looking for is some natively managed mechanism, so that I don't have to add another file to keep these props. For example, you can write svn propset weather '...' with SVN. Something like that.. – ulu Jan 03 '11 at 14:31
  • @ulu: no, Git (and I suspect Mercurial) don't manage metadata like svn manages properties. You need *one* file to include what you want to manage. – VonC Jan 03 '11 at 14:53
  • *VonC* is right, Mercurial has no SVN-like properties support too. The Mercurial way is to keep meta data in plain files. The hidden file `.hgtags` is a built-in example. Similarly you could set up a hidden file named `.props` - it won't clutter your workspace in the regular view. Though, AFAIK, it should be possible to write an extension which adds additional fields to a commit message (next to *author*, *date*, ...). – Oben Sonne Jan 03 '11 at 19:13