Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 4250:ca639faa38a2
Merge with crew-stable.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 19 Mar 2007 19:16:35 -0300 |
parents | 51e52db6b40d a80502f47552 |
children | 12e4d9524951 |
comparison
equal
deleted
inserted
replaced
4249:7663780b55a7 | 4250:ca639faa38a2 |
---|---|
177 for key, row in rows: | 177 for key, row in rows: |
178 row['parity'] = parity | 178 row['parity'] = parity |
179 parity = 1 - parity | 179 parity = 1 - parity |
180 yield row | 180 yield row |
181 | 181 |
182 virtual = req.env.get("PATH_INFO", "").strip('/') | 182 try: |
183 if virtual.startswith('static/'): | 183 virtual = req.env.get("PATH_INFO", "").strip('/') |
184 static = os.path.join(templater.templatepath(), 'static') | 184 if virtual.startswith('static/'): |
185 fname = virtual[7:] | 185 static = os.path.join(templater.templatepath(), 'static') |
186 req.write(staticfile(static, fname, req) or | 186 fname = virtual[7:] |
187 tmpl('error', error='%r not found' % fname)) | 187 req.write(staticfile(static, fname, req) or |
188 elif virtual: | 188 tmpl('error', error='%r not found' % fname)) |
189 while virtual: | 189 elif virtual: |
190 real = dict(self.repos).get(virtual) | 190 while virtual: |
191 real = dict(self.repos).get(virtual) | |
192 if real: | |
193 break | |
194 up = virtual.rfind('/') | |
195 if up < 0: | |
196 break | |
197 virtual = virtual[:up] | |
191 if real: | 198 if real: |
192 break | 199 req.env['REPO_NAME'] = virtual |
193 up = virtual.rfind('/') | 200 try: |
194 if up < 0: | 201 repo = hg.repository(parentui, real) |
195 break | 202 hgweb(repo).run_wsgi(req) |
196 virtual = virtual[:up] | 203 except IOError, inst: |
197 if real: | 204 req.write(tmpl("error", error=inst.strerror)) |
198 req.env['REPO_NAME'] = virtual | 205 except hg.RepoError, inst: |
199 try: | 206 req.write(tmpl("error", error=str(inst))) |
200 repo = hg.repository(parentui, real) | 207 else: |
201 hgweb(repo).run_wsgi(req) | 208 req.write(tmpl("notfound", repo=virtual)) |
202 except IOError, inst: | |
203 req.write(tmpl("error", error=inst.strerror)) | |
204 except hg.RepoError, inst: | |
205 req.write(tmpl("error", error=str(inst))) | |
206 else: | 209 else: |
207 req.write(tmpl("notfound", repo=virtual)) | 210 if req.form.has_key('static'): |
208 else: | 211 static = os.path.join(templater.templatepath(), "static") |
209 if req.form.has_key('static'): | 212 fname = req.form['static'][0] |
210 static = os.path.join(templater.templatepath(), "static") | 213 req.write(staticfile(static, fname, req) |
211 fname = req.form['static'][0] | 214 or tmpl("error", error="%r not found" % fname)) |
212 req.write(staticfile(static, fname, req) | 215 else: |
213 or tmpl("error", error="%r not found" % fname)) | 216 sortable = ["name", "description", "contact", "lastchange"] |
214 else: | 217 sortcolumn, descending = self.repos_sorted |
215 sortable = ["name", "description", "contact", "lastchange"] | 218 if req.form.has_key('sort'): |
216 sortcolumn, descending = self.repos_sorted | 219 sortcolumn = req.form['sort'][0] |
217 if req.form.has_key('sort'): | 220 descending = sortcolumn.startswith('-') |
218 sortcolumn = req.form['sort'][0] | 221 if descending: |
219 descending = sortcolumn.startswith('-') | 222 sortcolumn = sortcolumn[1:] |
220 if descending: | 223 if sortcolumn not in sortable: |
221 sortcolumn = sortcolumn[1:] | 224 sortcolumn = "" |
222 if sortcolumn not in sortable: | 225 |
223 sortcolumn = "" | 226 sort = [("sort_%s" % column, |
224 | 227 "%s%s" % ((not descending and column == sortcolumn) |
225 sort = [("sort_%s" % column, | 228 and "-" or "", column)) |
226 "%s%s" % ((not descending and column == sortcolumn) | 229 for column in sortable] |
227 and "-" or "", column)) | 230 req.write(tmpl("index", entries=entries, |
228 for column in sortable] | 231 sortcolumn=sortcolumn, descending=descending, |
229 req.write(tmpl("index", entries=entries, | 232 **dict(sort))) |
230 sortcolumn=sortcolumn, descending=descending, | 233 finally: |
231 **dict(sort))) | 234 tmpl = None |