Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb.py @ 1141:033c968d7c66
Use ConfigParser only in hgwebdir.__init__()
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 29 Aug 2005 07:28:39 +0200 |
parents | 04d52b446e5e |
children | 74d184a40a2e |
comparison
equal
deleted
inserted
replaced
1140:04d52b446e5e | 1141:033c968d7c66 |
---|---|
920 httpd.serve_forever() | 920 httpd.serve_forever() |
921 | 921 |
922 # This is a stopgap | 922 # This is a stopgap |
923 class hgwebdir: | 923 class hgwebdir: |
924 def __init__(self, config): | 924 def __init__(self, config): |
925 self.cp = ConfigParser.SafeConfigParser() | 925 cp = ConfigParser.SafeConfigParser() |
926 self.cp.read(config) | 926 cp.read(config) |
927 self.repos = cp.items("paths") | |
928 self.repos.sort() | |
927 | 929 |
928 def run(self): | 930 def run(self): |
929 def header(**map): | 931 def header(**map): |
930 yield tmpl("header", **map) | 932 yield tmpl("header", **map) |
931 | 933 |
937 tmpl = templater(m, common_filters, | 939 tmpl = templater(m, common_filters, |
938 {"header": header, "footer": footer}) | 940 {"header": header, "footer": footer}) |
939 | 941 |
940 def entries(**map): | 942 def entries(**map): |
941 parity = 0 | 943 parity = 0 |
942 repos = self.cp.items("paths") | 944 for name, path in self.repos: |
943 repos.sort() | |
944 for name, path in repos: | |
945 u = ui() | 945 u = ui() |
946 u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) | 946 u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) |
947 get = u.config | 947 get = u.config |
948 | 948 |
949 url = os.environ["REQUEST_URI"] + "/" + name | 949 url = os.environ["REQUEST_URI"] + "/" + name |
966 virtual = "" | 966 virtual = "" |
967 | 967 |
968 virtual = virtual.strip('/') | 968 virtual = virtual.strip('/') |
969 | 969 |
970 if len(virtual): | 970 if len(virtual): |
971 if self.cp.has_option("paths", virtual): | 971 real = dict(self.repos).get(virtual) |
972 real = self.cp.get("paths", virtual) | 972 if real: |
973 h = hgweb(real) | 973 h = hgweb(real) |
974 h.run() | 974 h.run() |
975 return | 975 return |
976 else: | 976 else: |
977 write(tmpl("notfound", repo = virtual)) | 977 write(tmpl("notfound", repo = virtual)) |