Show More
@@ -0,0 +1,70 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | mkdir repo | |||
|
4 | cd repo | |||
|
5 | hg init | |||
|
6 | echo foo > bar | |||
|
7 | hg add bar | |||
|
8 | hg commit -m "test" -d "0 0" | |||
|
9 | hg tip | |||
|
10 | ||||
|
11 | cat > request.py <<EOF | |||
|
12 | from mercurial import dispatch | |||
|
13 | from mercurial.hgweb.hgweb_mod import hgweb | |||
|
14 | from mercurial.hgweb.request import _wsgirequest | |||
|
15 | from mercurial.ui import ui | |||
|
16 | from mercurial import hg | |||
|
17 | from StringIO import StringIO | |||
|
18 | import sys | |||
|
19 | ||||
|
20 | class FileLike(object): | |||
|
21 | def __init__(self, real): | |||
|
22 | self.real = real | |||
|
23 | def fileno(self): | |||
|
24 | print >> sys.__stdout__, 'FILENO' | |||
|
25 | return self.real.fileno() | |||
|
26 | def read(self): | |||
|
27 | print >> sys.__stdout__, 'READ' | |||
|
28 | return self.real.read() | |||
|
29 | def readline(self): | |||
|
30 | print >> sys.__stdout__, 'READLINE' | |||
|
31 | return self.real.readline() | |||
|
32 | def isatty(self): | |||
|
33 | print >> sys.__stdout__, 'ISATTY' | |||
|
34 | return False | |||
|
35 | ||||
|
36 | sys.stdin = FileLike(sys.stdin) | |||
|
37 | errors = StringIO() | |||
|
38 | input = StringIO() | |||
|
39 | output = StringIO() | |||
|
40 | ||||
|
41 | def startrsp(headers, data): | |||
|
42 | print '---- HEADERS' | |||
|
43 | print headers | |||
|
44 | print '---- DATA' | |||
|
45 | print data | |||
|
46 | return output.write | |||
|
47 | ||||
|
48 | env = { | |||
|
49 | 'wsgi.version': (1, 0), | |||
|
50 | 'wsgi.url_scheme': 'http', | |||
|
51 | 'wsgi.errors': errors, | |||
|
52 | 'wsgi.input': input, | |||
|
53 | 'wsgi.multithread': False, | |||
|
54 | 'wsgi.multiprocess': False, | |||
|
55 | 'wsgi.run_once': False, | |||
|
56 | 'REQUEST_METHOD': 'GET', | |||
|
57 | 'SCRIPT_NAME': '', | |||
|
58 | 'PATH_INFO': '', | |||
|
59 | 'QUERY_STRING': '', | |||
|
60 | 'SERVER_NAME': '127.0.0.1', | |||
|
61 | 'SERVER_PORT': '20059', | |||
|
62 | 'SERVER_PROTOCOL': 'HTTP/1.0' | |||
|
63 | } | |||
|
64 | ||||
|
65 | _wsgirequest(hgweb('.'), env, startrsp) | |||
|
66 | print '---- ERRORS' | |||
|
67 | print errors.getvalue() | |||
|
68 | EOF | |||
|
69 | ||||
|
70 | python request.py |
@@ -0,0 +1,12 b'' | |||||
|
1 | changeset: 0:61c9426e69fe | |||
|
2 | tag: tip | |||
|
3 | user: test | |||
|
4 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
5 | summary: test | |||
|
6 | ||||
|
7 | ---- HEADERS | |||
|
8 | 200 Script output follows | |||
|
9 | ---- DATA | |||
|
10 | [('content-type', 'text/html; charset=ascii')] | |||
|
11 | ---- ERRORS | |||
|
12 |
@@ -211,9 +211,11 b' class ui(object):' | |||||
211 | if name is None or name in ('quiet', 'verbose', 'debug'): |
|
211 | if name is None or name in ('quiet', 'verbose', 'debug'): | |
212 | self.verbosity_constraints() |
|
212 | self.verbosity_constraints() | |
213 | if name is None or name == 'interactive': |
|
213 | if name is None or name == 'interactive': | |
214 |
|
|
214 | interactive = self.configbool("ui", "interactive", None) | |
215 |
if |
|
215 | if interactive is None and self.interactive: | |
216 | self.interactive = self.isatty() |
|
216 | self.interactive = self.isatty() | |
|
217 | else: | |||
|
218 | self.interactive = interactive | |||
217 | if name is None or name == 'report_untrusted': |
|
219 | if name is None or name == 'report_untrusted': | |
218 | self.report_untrusted = ( |
|
220 | self.report_untrusted = ( | |
219 | self.configbool("ui", "report_untrusted", True)) |
|
221 | self.configbool("ui", "report_untrusted", True)) | |
@@ -391,7 +393,7 b' class ui(object):' | |||||
391 | try: sys.stderr.flush() |
|
393 | try: sys.stderr.flush() | |
392 | except: pass |
|
394 | except: pass | |
393 |
|
395 | |||
394 | def readline(self, prompt=''): |
|
396 | def _readline(self, prompt=''): | |
395 | if self.isatty(): |
|
397 | if self.isatty(): | |
396 | try: |
|
398 | try: | |
397 | # magically add command line editing support, where |
|
399 | # magically add command line editing support, where | |
@@ -406,7 +408,7 b' class ui(object):' | |||||
406 | def prompt(self, msg, pat=None, default="y", matchflags=0): |
|
408 | def prompt(self, msg, pat=None, default="y", matchflags=0): | |
407 | if not self.interactive: return default |
|
409 | if not self.interactive: return default | |
408 | try: |
|
410 | try: | |
409 | r = self.readline(msg + ' ') |
|
411 | r = self._readline(msg + ' ') | |
410 | if not pat or re.match(pat, r, matchflags): |
|
412 | if not pat or re.match(pat, r, matchflags): | |
411 | return r |
|
413 | return r | |
412 | else: |
|
414 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now