跟上Niall的非常有用的答案,上面,我意识到我需要一个工具来维护这个[路径]部分。我结束了这是怎么回事(这由M. Foord使用configobj。
#!/usr/bin/env python
from __future__ import print_function
import os
from configobj import ConfigObj
hgweb_path = os.path.join(os.path.expanduser("~"), "Library", "Preferences", "hgweb.config")
projects = os.path.join(os.path.expanduser("~"), "projects")
config = ConfigObj(hgweb_path)
paths = []
def add_mercurial(arg, dirname, names):
if '.hg' in names:
paths.append(dirname[len(projects) + 1:])
os.path.walk(projects, add_mercurial, None)
config['paths'] = {}
for path in paths:
config['paths']["projects/" + path] = os.path.join(projects, path)
config.write()
此脚本由OS X中的等价物的cron每15分钟运行,并确保我的hgweb永远不会过时的。
你试过用'hgwebdir'呢? – Amber 2010-08-10 23:18:53