Mercurial > hg
annotate contrib/dumprevlog @ 13026:53391819f195
check-code: catch Python 'is' comparing number or string literals
The Python 'is' operator compares object identity, so it should
definitely not be applied to string or number literals, which Python
implementations are free to represent with a temporary object.
This should catch the following kinds of bogus expressions (examples):
x is 'foo' x is not 'foo'
x is "bar" x is not "bar"
x is 42 x is not 42
x is -36 x is not -36
As originally proposed by Martin Geisler, amended with catching
negative numbers.
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sun, 21 Nov 2010 11:52:27 +0100 |
parents | 9fe97eea5510 |
children | 659f34b833b9 |
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 # Dump revlogs as raw data stream |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 import sys |
6466
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
6 from mercurial import revlog, node, util |
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
7 |
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
8 for fp in (sys.stdin, sys.stdout, sys.stderr): |
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
9 util.set_binary(fp) |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
10 |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
11 for f in sys.argv[1:]: |
6466
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
12 binopen = lambda fn: open(fn, 'rb') |
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
13 r = revlog.revlog(binopen, f) |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
14 print "file:", f |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6466
diff
changeset
|
15 for i in r: |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 n = r.node(i) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
17 p = r.parents(n) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 d = r.revision(n) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 print "node:", node.hex(n) |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
20 print "linkrev:", r.linkrev(i) |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 print "parents:", node.hex(p[0]), node.hex(p[1]) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 print "length:", len(d) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
23 print "-start-" |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 print d |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
25 print "-end-" |