hgweb.cgi
author Patrick Mezard <pmezard@gmail.com>
Thu, 19 Aug 2010 22:51:09 +0200
branchstable
changeset 11991 50523b4407f6
parent 11503 227b9f13db13
child 15475 85cba926cb59
permissions -rw-r--r--
win32: correctly break hardlinks on network drives (issue761) win32.nlinks() was often returning 1 instead of the correct hardlinks count when reading from network drives. This made commit or push to a repository on a network share to fail breaking the hardlinks in the datastore, possibly causing integrity errors in repositories linked locally on the remote side. Here is what the MSDN says about GetFileInformationByHandle(): Depending on the underlying network features of the operating system and the type of server connected to, the GetFileInformationByHandle function may fail, return partial information, or full information for the given file. In practice, we never got the correct hardlinks count when reading from and to many combinations of Window XP, 2003, Vista and 7, via network drives or RDP shares. It always returned 1 instead. The only setup returning an accurate links count was a samba on Debian. To avoid this, Mercurial now breaks the hardlinks unconditionally when writing to a network drive.

#!/usr/bin/env python
#
# An example hgweb CGI script, edit as necessary
# See also http://mercurial.selenic.com/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/path/to/repo/or/config"

# Uncomment and adjust if Mercurial is not installed system-wide:
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)