contrib/dumprevlog
author Mads Kiilerich <madski@unity3d.com>
Tue, 08 Nov 2016 18:37:33 +0100
changeset 30431 8c0c75aa3ff4
parent 29166 6359b80f15fb
child 35964 a915465a731e
permissions -rwxr-xr-x
bdiff: give slight preference to longest matches in the middle of the B side We already have a slight preference for matches close to the middle on the A side. Now, do the same on the B side. j is iterating the b range backwards and we thus accept a new j if the previous match was in the upper half. This makes the test-bhalf diff "correct". It obviously also gives more preference to balanced recursion than to appending to sequences. That is kind of correct, but will also unfortunately make some bundles bigger. No doubt, we can also create examples where it will make them smaller ... The bundle size for 4.0 (hg bundle --base null -r 4.0 x.hg) happens to go from 22803824 to 22806817 bytes - an 0.01% increase.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
29166
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
     5
from __future__ import absolute_import, print_function
29165
a212ca70205c py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 14233
diff changeset
     6
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
import sys
29165
a212ca70205c py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 14233
diff changeset
     8
from mercurial import (
a212ca70205c py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 14233
diff changeset
     9
    node,
a212ca70205c py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 14233
diff changeset
    10
    revlog,
a212ca70205c py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 14233
diff changeset
    11
    util,
a212ca70205c py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 14233
diff changeset
    12
)
6466
9c426da6b03b contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents: 6433
diff changeset
    13
9c426da6b03b contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents: 6433
diff changeset
    14
for fp in (sys.stdin, sys.stdout, sys.stderr):
14233
659f34b833b9 rename util.set_binary to setbinary
Adrian Buehlmann <adrian@cadifra.com>
parents: 7361
diff changeset
    15
    util.setbinary(fp)
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
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
    18
    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
    19
    r = revlog.revlog(binopen, f)
29166
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    20
    print("file:", f)
6750
fb42030d79d6 add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents: 6466
diff changeset
    21
    for i in r:
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    22
        n = r.node(i)
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    23
        p = r.parents(n)
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    24
        d = r.revision(n)
29166
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    25
        print("node:", node.hex(n))
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    26
        print("linkrev:", r.linkrev(i))
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    27
        print("parents:", node.hex(p[0]), node.hex(p[1]))
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    28
        print("length:", len(d))
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    29
        print("-start-")
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    30
        print(d)
6359b80f15fb py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29165
diff changeset
    31
        print("-end-")