disrstate._check(link|exec) modifies repo dir mtime

Dorian Taylor dorian.taylor.lists at gmail.com
Sat Oct 1 18:35:40 UTC 2016


Greetings,

I’m currently writing a small program to help with the general hygiene of my workspace, and among one of the tasks is to check and see if I have any hg (and/or git) repositories left uncommitted.

I was trundling along just fine with my plan, when to my surprise, a call to `hg status` (or rather commands.status) modifies the mtime of the repository directory, ostensibly by dropping temporary files into it to probe for various properties of the file system. (I was intending to use those particular mtimes for forensic purposes.)

Now, for future runs I can easily get the mtime of $REPO before I retrieve the status and subsequently utime it back to its original value, or otherwise overwrite util.checkwhatever to just return True (though I’d rather not do that because I will probably release this program), so I think this issue raises a design question:

I traced the code to here: https://selenic.com/hg/file/tip/mercurial/dirstate.py#l220

(A similar idiom also appears in https://selenic.com/hg/file/tip/mercurial/scmutil.py#l507 but it doesn’t appear to be executed via `hg status`)

I’m curious as to why, in particular in dirstate.py, _checklink and _checkexec test against the $REPO, but _checkcase tests against $REPO/.hg.

Perhaps framed another way: is there a reason why all this testing can’t go on in $REPO/.hg?


--
Dorian Taylor
Make things. Make sense.
http://doriantaylor.com



More information about the Mercurial mailing list