hg diff seems to traverse unnecessary dirs
Jeff Squyres
jsquyres at cisco.com
Wed Jul 23 07:23:38 CDT 2008
Greetings, and thanks for Mercurial! A bunch of us use it in the Open
MPI project in conjunction with the master SVN repository for side
development (https://svn.open-mpi.org/trac/ompi/wiki/UsingMercurial,
if you care).
I noticed a peculiar behavior this morning (using hg v1.0.1): it seems
like "hg diff" traverses into directories that it shouldn't need to.
I have not dived into the hg source code at all; this is mainly from a
"least astonishment" user perspective.
I was testing Open MPI's "make dist" this morning and had made a test
tarball. I expanded that tarball in the same tree as my Mercurial
repository+checkout and started running "configure" in that tree. So
it looked like this:
# My hg repo and checkout tree
$HOME/hg/romio-1.0.7/
# Where I expanded my test tarball (not tracked by hg)
$HOME/hg/romio-1.0.7/openmpi-1.4a1hg37ea0dd213fb/
I then was checking my work in the main tree and ran "hg diff" on a
specific subdirectory. I was surprised to see the following:
-----
[4:34] svbu-mpi:~/hg/romio-1.0.7 % hg di ompi/mca/io/romio/
abort: No such file or directory: /home/jsquyres/hg/romio-1.0.7/./
openmpi-1.4a1hg37ea0dd213fb/confdir.3997
[4:34] svbu-mpi:~/hg/romio-1.0.7 %
-----
I can guess what happened: configure runs lots of tests in short-lived
subdirectories. It creates a subdir, runs a test, and then whacks the
subdir. So if hg scans a directory, it might see a subdirectory but
by the time it tries to traverse into that subdirectory, it could be
gone.
But I asked hg to traverse into a specific subdirectory (ompi/mca/io/
romio) -- why did it look elsewhere? Indeed, the openmpi-v1.4* tree
is not tracked by Mercurial at all -- why did an "hg diff" traverse so
deep into it at all? The "least astonishment" factor here is that I
thought it would be safe to run "hg diff" on the tree, even though I
was actively changing files in a not-tracked-by-Mercurial
subdirectory. Put simply: it surprised me that activity in an area
not tracked by Mercurial caused a Mercurial command to fail.
Open MPI is a goodly-sized code base (Mercurial tracks around 4500
files); several Mercurial operations take a few seconds, even on a
local/fast file system. I always wondered why that was, especially
when you run what should be a small operation (e.g., "hg diff" on ompi/
mca/io/romio is a pretty small subtree out of the overall code base;
"svn diff" on the same tree is nearly instantaneous). Could this
"traversing unneeded directories" behavior be contributing to the
"slow" operations?
--
Jeff Squyres
Cisco Systems
More information about the Mercurial
mailing list