Mercurial > hg
annotate tests/dumbhttp.py @ 26228:0fd20a71abdb
extdiff: add a --patch argument for diffing changeset deltas
One of the things I missed the most when transitioning from versioned MQ to
evolve was the loss of being able to check that rebase conflicts were properly
resolved by:
$ hg ci --mq -m "before"
$ hg rebase -s qbase -d tip
$ hg bcompare --mq
The old csets stay in the tree with evolve, but a straight diff includes all of
the other changes that were pulled in, obscuring the code that was rebased.
Diffing deltas can be confusing, but unless radical changes were made during the
resolve, it is very clear when individual hunks are added, dropped or modified.
Unlike the MQ technique, this can only compare a single pair of csets/patches at
a time. Like the MQ method, this also highlights changes in the commit comment
and other metadata.
I originally tried monkey patching from the evolve extension, but that is too
complicated given that it depends on the order the two different extensions are
loaded. This functionality is also useful when comparing grafts however, so
implementing it in the core is more than just convenience.
The --change argument doesn't make much sense for this, but it isn't harmful so
I didn't bother blocking it. The -I/-X options are ignored because of a
limitation of cmdutil.export(). We'll fix that next.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 09 Sep 2015 21:07:38 -0400 |
parents | 6eab50a34fed |
children | 0bb8c405a7c7 |
rev | line source |
---|---|
22959
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
2 |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
3 """ |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
4 Small and dumb HTTP server for use in tests. |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
5 """ |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
6 |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
7 from optparse import OptionParser |
23136
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
8 import BaseHTTPServer, SimpleHTTPServer, signal, sys |
22959
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
9 |
23136
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
10 from mercurial import cmdutil |
22959
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
11 |
23136
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
12 class simplehttpservice(object): |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
13 def __init__(self, host, port): |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
14 self.address = (host, port) |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
15 def init(self): |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
16 self.httpd = BaseHTTPServer.HTTPServer( |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
17 self.address, SimpleHTTPServer.SimpleHTTPRequestHandler) |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
18 def run(self): |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
19 self.httpd.serve_forever() |
22959
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
20 |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
21 if __name__ == '__main__': |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
22 parser = OptionParser() |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
23 parser.add_option('-p', '--port', dest='port', type='int', default=8000, |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
24 help='TCP port to listen on', metavar='PORT') |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
25 parser.add_option('-H', '--host', dest='host', default='localhost', |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
26 help='hostname or IP to listen on', metavar='HOST') |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
27 parser.add_option('--pid', dest='pid', |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
28 help='file name where the PID of the server is stored') |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
29 parser.add_option('-f', '--foreground', dest='foreground', |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
30 action='store_true', |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
31 help='do not start the HTTP server in the background') |
23136
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
32 parser.add_option('--daemon-pipefds') |
22959
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
33 |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
34 (options, args) = parser.parse_args() |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
35 |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
36 signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0)) |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
37 |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
38 if options.foreground and options.pid: |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
39 parser.error("options --pid and --foreground are mutually exclusive") |
10116463b0b1
tests: pull common http server setup out of individual tests
Mike Hommey <mh@glandium.org>
parents:
diff
changeset
|
40 |
23136
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
41 opts = {'pid_file': options.pid, |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
42 'daemon': not options.foreground, |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
43 'daemon_pipefds': options.daemon_pipefds} |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
44 service = simplehttpservice(options.host, options.port) |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
45 cmdutil.service(opts, initfn=service.init, runfn=service.run, |
6eab50a34fed
tests: have dumbhttp.py use cmdutil.service() to wait for child to listen()
Yuya Nishihara <yuya@tcha.org>
parents:
22959
diff
changeset
|
46 runargs=[sys.executable, __file__] + sys.argv[1:]) |