equal
deleted
inserted
replaced
16 from ..i18n import _ |
16 from ..i18n import _ |
17 from ..node import hex, nullid, short |
17 from ..node import hex, nullid, short |
18 |
18 |
19 from .common import ( |
19 from .common import ( |
20 ErrorResponse, |
20 ErrorResponse, |
|
21 HTTP_BAD_REQUEST, |
21 HTTP_NOT_FOUND, |
22 HTTP_NOT_FOUND, |
22 paritygen, |
23 paritygen, |
23 ) |
24 ) |
24 |
25 |
25 from .. import ( |
26 from .. import ( |
314 fctx = repo[changeid][path] |
315 fctx = repo[changeid][path] |
315 except error.RepoError: |
316 except error.RepoError: |
316 fctx = repo.filectx(path, fileid=changeid) |
317 fctx = repo.filectx(path, fileid=changeid) |
317 |
318 |
318 return fctx |
319 return fctx |
|
320 |
|
321 def linerange(req): |
|
322 linerange = req.form.get('linerange') |
|
323 if linerange is None: |
|
324 return None |
|
325 if len(linerange) > 1: |
|
326 raise ErrorResponse(HTTP_BAD_REQUEST, |
|
327 'redundant linerange parameter') |
|
328 try: |
|
329 fromline, toline = map(int, linerange[0].split(':', 1)) |
|
330 except ValueError: |
|
331 raise ErrorResponse(HTTP_BAD_REQUEST, |
|
332 'invalid linerange parameter') |
|
333 try: |
|
334 return util.processlinerange(fromline, toline) |
|
335 except error.ParseError as exc: |
|
336 raise ErrorResponse(HTTP_BAD_REQUEST, str(exc)) |
|
337 |
|
338 def formatlinerange(fromline, toline): |
|
339 return '%d:%d' % (fromline + 1, toline) |
319 |
340 |
320 def commonentry(repo, ctx): |
341 def commonentry(repo, ctx): |
321 node = ctx.node() |
342 node = ctx.node() |
322 return { |
343 return { |
323 'rev': ctx.rev(), |
344 'rev': ctx.rev(), |