contrib/dumprevlog
author Denis Laxalde <denis.laxalde@logilab.fr>
Wed, 05 Jul 2017 13:54:53 +0200
changeset 33284 b2670290eab4
parent 29166 6359b80f15fb
child 35964 a915465a731e
permissions -rwxr-xr-x
followlines: join merge parents line ranges in blockdescendants() (issue5595) In blockdescendants(), we had an assertion when line range of a merge changeset was not consistent depending on which parent was considered for computation. For instance, this might occur when file content (in lookup range) is significantly different between parent branches of the merge as demonstrated in added tests (where we almost completely rewrite the "baz" file while also introducing similarities with its content in the other branch we later merge to). Now, in such case, we combine line ranges from all parents by storing the envelope of both line ranges. This is conservative (the line range is extended, possibly unnecessarily) but at least this should avoid missing descendants with changes in a range that would fall in that of one parent but not in another one (the case of "baz: narrow change (2->2+)" changeset in tests).
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-")