A hacker's view of .hg

Bob Hood bhood2 at comcast.net
Sat Jul 7 19:33:07 UTC 2018


I recently discovered a pretty nice FLOSS shell system for Windows.  Being a 
UN*X geek, I tend to do a lot of my work from the command line, and for years, 
used TCC LE as a result. However, the newest version of Visual Studio has kind 
of broken TCC LE for me, so in searching for a replacement, I came across 
Cmder[1], and kind of fell in love. :)

As you can imagine, most of the customization efforts on projects like this 
are for git.  The Mercurial support that Cmder has is horribly inefficient, 
with the prompt code that displays the branch and working copy status taking 
between 5 and 10 seconds to complete on my working copy each time the prompt 
was being generated.  They were using some horrendous command that generated 
tons of output just to determine if there were changes pending in the working 
copy.  I refactored that code to use "id" instead, since it provides both the 
branch name and an indication of the status of pending changes within the 
working copy.  (I have issued a pull request on the main project for these 
changes.)

This reduced the huge time overhead down to about 1 second on my repository.  
However, when I went into a git working copy, and the info response for its 
branch and status within Cmder was just about instant.  Certainly, 1 second is 
better than 10, but even that 1 second gets a bit tiresome when you have many 
things to do from the command line.

So, my question here has to do with the internals of the .hg folder.  I see 
that there is a "branch" file inside it that contains the value of the active 
branch in the working copy, so reading that directly (instead of trying to 
parse it from "hg id") would be very fast.  However, is there some 
corresponding indicator within the .hg folder that holds the state of the 
working copy with regard to pending changes (i.e., if it's "dirty" or 
"clean")?  Reading something like that directly would hopefully also be /much/ 
faster than waiting for the output of the "id" command.

Thanks in advance for any insights, or alternative approaches.

(btw, I'm using the hg.exe that comes with TortoiseHG, and it is v4.6.1)


[1] https://github.com/cmderdev/cmder

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial/attachments/20180707/b0ff3752/attachment.html>


More information about the Mercurial mailing list