Mercurial > hg
comparison mercurial/hgweb/hgweb_mod.py @ 5915:d0576d065993
Prefer i in d over d.has_key(i)
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Sun, 20 Jan 2008 14:39:25 +0100 |
parents | a0e20a5eba3c |
children | f39110afc039 |
comparison
equal
deleted
inserted
replaced
5914:8e7796a990c5 | 5915:d0576d065993 |
---|---|
151 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME | 151 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME |
152 | 152 |
153 req.url = req.env['SCRIPT_NAME'] | 153 req.url = req.env['SCRIPT_NAME'] |
154 if not req.url.endswith('/'): | 154 if not req.url.endswith('/'): |
155 req.url += '/' | 155 req.url += '/' |
156 if req.env.has_key('REPO_NAME'): | 156 if 'REPO_NAME' in req.env: |
157 req.url += req.env['REPO_NAME'] + '/' | 157 req.url += req.env['REPO_NAME'] + '/' |
158 | 158 |
159 if req.env.get('PATH_INFO'): | 159 if req.env.get('PATH_INFO'): |
160 parts = req.env.get('PATH_INFO').strip('/').split('/') | 160 parts = req.env.get('PATH_INFO').strip('/').split('/') |
161 repo_parts = req.env.get('REPO_NAME', '').split('/') | 161 repo_parts = req.env.get('REPO_NAME', '').split('/') |
265 def motd(**map): | 265 def motd(**map): |
266 yield self.config("web", "motd", "") | 266 yield self.config("web", "motd", "") |
267 | 267 |
268 def sessionvars(**map): | 268 def sessionvars(**map): |
269 fields = [] | 269 fields = [] |
270 if req.form.has_key('style'): | 270 if 'style' in req.form: |
271 style = req.form['style'][0] | 271 style = req.form['style'][0] |
272 if style != self.config('web', 'style', ''): | 272 if style != self.config('web', 'style', ''): |
273 fields.append(('style', style)) | 273 fields.append(('style', style)) |
274 | 274 |
275 separator = req.url[-1] == '?' and ';' or '?' | 275 separator = req.url[-1] == '?' and ';' or '?' |
278 separator = ';' | 278 separator = ';' |
279 | 279 |
280 # figure out which style to use | 280 # figure out which style to use |
281 | 281 |
282 style = self.config("web", "style", "") | 282 style = self.config("web", "style", "") |
283 if req.form.has_key('style'): | 283 if 'style' in req.form: |
284 style = req.form['style'][0] | 284 style = req.form['style'][0] |
285 mapfile = style_map(self.templatepath, style) | 285 mapfile = style_map(self.templatepath, style) |
286 | 286 |
287 if not self.reponame: | 287 if not self.reponame: |
288 self.reponame = (self.config("web", "name") | 288 self.reponame = (self.config("web", "name") |
861 def cleanpath(self, path): | 861 def cleanpath(self, path): |
862 path = path.lstrip('/') | 862 path = path.lstrip('/') |
863 return util.canonpath(self.repo.root, '', path) | 863 return util.canonpath(self.repo.root, '', path) |
864 | 864 |
865 def changectx(self, req): | 865 def changectx(self, req): |
866 if req.form.has_key('node'): | 866 if 'node' in req.form: |
867 changeid = req.form['node'][0] | 867 changeid = req.form['node'][0] |
868 elif req.form.has_key('manifest'): | 868 elif 'manifest' in req.form: |
869 changeid = req.form['manifest'][0] | 869 changeid = req.form['manifest'][0] |
870 else: | 870 else: |
871 changeid = self.repo.changelog.count() - 1 | 871 changeid = self.repo.changelog.count() - 1 |
872 | 872 |
873 try: | 873 try: |
879 | 879 |
880 return ctx | 880 return ctx |
881 | 881 |
882 def filectx(self, req): | 882 def filectx(self, req): |
883 path = self.cleanpath(req.form['file'][0]) | 883 path = self.cleanpath(req.form['file'][0]) |
884 if req.form.has_key('node'): | 884 if 'node' in req.form: |
885 changeid = req.form['node'][0] | 885 changeid = req.form['node'][0] |
886 else: | 886 else: |
887 changeid = req.form['filenode'][0] | 887 changeid = req.form['filenode'][0] |
888 try: | 888 try: |
889 ctx = self.repo.changectx(changeid) | 889 ctx = self.repo.changectx(changeid) |