Pull requests

#3 Declined
powerman powerman
gward gward

fast modified/unknown support for hg

  1. Alex Efros

Don't mind it's Perl script, it works very fast (actually, faster than git commands executed by vcprompt on small repositories, and slower than git in about 3 times on large repository with 500 subdirs and 9500 files - but it still fast enough and run in 0.06 sec on my system, which is 2 times faster than hg st).

Comments (4)

  1. Alex Efros author

    I've received your comment by email, but didn't see it in bitbucket interface right now (it should be at https://bitbucket.org/powerman/vcprompt/changeset/72c3065ce547#comment-24712), so I'll reply here.

    1) I would vastly prefer for this to be in C rather than Perl. vcprompt is supposed to be fast and lightweight, and spawning subprocesses is to be avoided if it all possible.

    Understood, but I'm not a C developer, and I'm afraid if I'll rewrite my script in C I'll make a lot of bugs. It's fast enough now, so I don't think this is a real issue.

    2) funny indentation in src/hg.c: 4 spaces please

    Sorry, fixed.

    3) your interpretation of .hgignore is too limited, since .hgignore can contain more than just regexes. "man hgignore" for the gory details. I'm not sure if there is a good way to do this ... short of actually calling Mercurial.

    Yeah, I've already noticed this. I'll try to improve it next time I'll have spare time for this project (honestly, I'm already tired of rewriting my .hgignore files into format understood by my script :)).

    4) … You only need to walk the filesystem when the user asks for unknown files, which is an optimization that Mercurial makes too. I think there should be an alternate code path to checkdir() when the user doesn't ask for unknown files.

    Agreed. Looks like script should take some param. Looks trivial, but I'm too sleepy now, so - later.

  2. Richard Quirk

    It's a nice idea, but sadly falls a bit short - dirstate only gets updated by hg stat or similar. So running touch src/hg.c will give you a false dirty state as the mtimes do not match in dirstate and on disc. Also, mercurial only seems to track user permissions, so chmod x+g src/hg.c will be dirty too, but not for hg status - you'd need a 0700 mode mask. I came across these issues as I was rewriting this in C. I thought about using a C implementation as a first pass, then if things "look dirty" spawn off hg id or whatever to do the actual check.

  3. Greg Ward repo owner

    Sorry, I'm not going to take this. Like it says in README.txt:

    • Performance matters! I wrote vcprompt so that people wouldn't have to spawn and initialize and entire Python or Perl interpreter every time they execute a new shell command. Using system() to turn around and spawn external commands -- especially ones that involve a relatively large runtime penalty like Python scripts -- misses the point of vcprompt.

    A C implementation that is 95% correct would be perfectly acceptable. (100% correct would be quite difficult and slow.)