contrib/undumprevlog
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 12 May 2018 18:44:03 -0700
changeset 38460 7f738edc4a27
parent 37120 a8a902d7176e
child 39947 a063b84ce064
permissions -rwxr-xr-x
packaging: dynamically define make targets We currently have make boilerplate for each instance of a distro's release. This is redundant, annoying to maintain, and prone to errors. This commit defines variables holding available releases for various distros. We then iterate through the list and dynamically define make targets. Differential Revision: https://phab.mercurial-scm.org/D3761
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
# 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
33872
5d9890d8ca77 undumprevlog: update to valid Python 3 syntax
Augie Fackler <raf@durin42.com>
parents: 31248
diff changeset
     6
from __future__ import absolute_import, print_function
29167
4f76c0c490b3 py3: make contrib/undumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 23310
diff changeset
     7
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
import sys
29167
4f76c0c490b3 py3: make contrib/undumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 23310
diff changeset
     9
from mercurial import (
4f76c0c490b3 py3: make contrib/undumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 23310
diff changeset
    10
    node,
4f76c0c490b3 py3: make contrib/undumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 23310
diff changeset
    11
    revlog,
4f76c0c490b3 py3: make contrib/undumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 23310
diff changeset
    12
    transaction,
31248
8d3e8c8c9049 vfs: use 'vfs' module directly in 'contrib/undumprevlog'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31216
diff changeset
    13
    vfs as vfsmod,
29167
4f76c0c490b3 py3: make contrib/undumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 23310
diff changeset
    14
)
37120
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 33872
diff changeset
    15
from mercurial.utils import (
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 33872
diff changeset
    16
    procutil,
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 33872
diff changeset
    17
)
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
6466
9c426da6b03b contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents: 6433
diff changeset
    19
for fp in (sys.stdin, sys.stdout, sys.stderr):
37120
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 33872
diff changeset
    20
    procutil.setbinary(fp)
6466
9c426da6b03b contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents: 6433
diff changeset
    21
31248
8d3e8c8c9049 vfs: use 'vfs' module directly in 'contrib/undumprevlog'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31216
diff changeset
    22
opener = vfsmod.vfs('.', False)
23310
5bd1f6572db0 transaction: pass a vfs map to the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 19022
diff changeset
    23
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
    24
                             "undump.journal")
19022
cba222f01056 tests: run check-code on Python files without .py extension
Mads Kiilerich <madski@unity3d.com>
parents: 14233
diff changeset
    25
while True:
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
    l = sys.stdin.readline()
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    27
    if not l:
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    28
        break
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    29
    if l.startswith("file:"):
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    30
        f = l[6:-1]
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
        r = revlog.revlog(opener, f)
33872
5d9890d8ca77 undumprevlog: update to valid Python 3 syntax
Augie Fackler <raf@durin42.com>
parents: 31248
diff changeset
    32
        print(f)
6433
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
    elif l.startswith("node:"):
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
        n = node.bin(l[6:-1])
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
    elif l.startswith("linkrev:"):
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
        lr = int(l[9:-1])
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    37
    elif l.startswith("parents:"):
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
        p = l[9:-1].split()
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
        p1 = node.bin(p[0])
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
        p2 = node.bin(p[1])
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
    elif l.startswith("length:"):
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
        length = int(l[8:-1])
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
        sys.stdin.readline() # start marker
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
        d = sys.stdin.read(length)
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
        sys.stdin.readline() # end marker
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    46
        r.addrevision(d, tr, lr, p1, p2)
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    47
ec5d77eb3431 add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    48
tr.close()