Mercurial > hg
annotate contrib/undumprevlog @ 26134:e0a6908f066f
hgweb: establish class for holding per request context
Currently, hgweb applications have many instance variables holding
mutated state. This is somewhat problematic because multiple threads
may race accessing or changing this state.
This patch starts a series that will add more thread safety to
hgweb applications. It will do this by moving mutated state out
of hgweb and into per-request instances of the newly established
"requestcontext" class.
Our new class currently behaves like a proxy to hgweb instances. This
should change once all state is captured in it instead of hgweb. The
effectiveness of this proxy is demonstrated by passing instances of
it - not hgweb instances/self - to various functions.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 22 Aug 2015 14:59:36 -0700 |
parents | 5bd1f6572db0 |
children | 4f76c0c490b3 |
rev | line source |
---|---|
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # Undump a dump from dumprevlog |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # $ hg init |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # $ undumprevlog < repo.dump |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
6 import sys |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
6466
diff
changeset
|
7 from mercurial import revlog, node, scmutil, util, transaction |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 |
6466
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
9 for fp in (sys.stdin, sys.stdout, sys.stderr): |
14233
659f34b833b9
rename util.set_binary to setbinary
Adrian Buehlmann <adrian@cadifra.com>
parents:
13970
diff
changeset
|
10 util.setbinary(fp) |
6466
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
11 |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
6466
diff
changeset
|
12 opener = scmutil.opener('.', False) |
23310
5bd1f6572db0
transaction: pass a vfs map to the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
19022
diff
changeset
|
13 tr = transaction.transaction(sys.stderr.write, opener, {'store': opener}, |
5bd1f6572db0
transaction: pass a vfs map to the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
19022
diff
changeset
|
14 "undump.journal") |
19022
cba222f01056
tests: run check-code on Python files without .py extension
Mads Kiilerich <madski@unity3d.com>
parents:
14233
diff
changeset
|
15 while True: |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 l = sys.stdin.readline() |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
17 if not l: |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 break |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 if l.startswith("file:"): |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
20 f = l[6:-1] |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 r = revlog.revlog(opener, f) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 print f |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
23 elif l.startswith("node:"): |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 n = node.bin(l[6:-1]) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
25 elif l.startswith("linkrev:"): |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
26 lr = int(l[9:-1]) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
27 elif l.startswith("parents:"): |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
28 p = l[9:-1].split() |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 p1 = node.bin(p[0]) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
30 p2 = node.bin(p[1]) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 elif l.startswith("length:"): |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
32 length = int(l[8:-1]) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 sys.stdin.readline() # start marker |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 d = sys.stdin.read(length) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
35 sys.stdin.readline() # end marker |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 r.addrevision(d, tr, lr, p1, p2) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 tr.close() |