After installing TortoiseHg awhile back, I noticed that attempting to open 
certain network folders resulted in a hang in explorer and I would have to kill 
it with Task Manager.  It appears the problem is in find_root, or actually in 
find_root's call to os.path.isdir.  Lifting find_root directly from the 
TortoiseHg sources, adding some print statements, and making it run 
independently gives me the following little test program:

----- begin find_root.py ----
import os.path
import sys

def find_root(path):
    p = os.path.isdir(path) and path or os.path.dirname(path)
    while not os.path.isdir(os.path.join(p, ".hg")):
        oldp = p
        print "Getting dirname of '" + p + "'"
        p = os.path.dirname(p)
        print "Got '" + p + "'"
        if p == oldp:
            return None
    print "Returning with p='" + p + "'"
    return p

print "Finding root of '" + sys.argv[1] + "'"
find_root(sys.argv[1])

----- end find_root.py -----

In the following example, I have full access to some of the shares on \\mynode, 
but do not have even read access to the root (that's key, as other systems 
where I do have access to the root path do not illustrate the problem).  So I 
run the test program like so:

C:\work>python find_root.py \\mynode\foo\bar
Finding root of '\\mynode\foo\bar'
Getting dirname of '\\mynode\foo\bar'
Got '\\mynode\foo'
Getting dirname of '\\mynode\foo'
Got '\\mynode'

at which point it hangs.  The hang can be further narrowed to the call to 
os.path.isdir with the following test program:

---- begin check_isdir.py -----
import os.path
import sys

hgpath = os.path.join(sys.argv[1], ".hg")
print "Checking whether '" + hgpath + "' is a directory."
if os.path.isdir(hgpath):
    print "Yes, it is"
----- end check_isdir.py -----


C:\work>python check_isdir.py \\mynode
Checking whether '\\mynode\.hg' is a directory.

and here we hang again.  So, to summarize, calling 
os.path.isdir("\\mynode\.hg") when I do not have read access to the root of 
\\mynode causes a hang.  This may well be a Python bug as it's actually getting 
hung in os.stat, which is called by os.path.isdir.  

I reproduced this with Python 2.6.1 on Windows XP.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to