tests/artifacts/scripts/generate-churning-bundle.py
author Raphaël Gomès <rgomes@octobus.net>
Thu, 21 Mar 2024 12:26:46 +0100
changeset 51515 16d93adddce7
parent 51277 d7155949535e
permissions -rwxr-xr-x
branching: merge stable into default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45830
c102b704edb5 global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43110
diff changeset
     1
#!/usr/bin/env python3
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
# generate-branchy-bundle - generate a branch for a "large" branchy repository
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     5
# Copyright 2018 Octobus, contact@octobus.net
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     6
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     7
# This software may be used and distributed according to the terms of the
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     8
# GNU General Public License version 2 or any later version.
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     9
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    10
# This script generates a repository suitable for testing delta computation
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    11
# strategies.
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    12
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    13
# The repository update a single "large" file with many updates. One fixed part
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    14
# of the files always get updated while the rest of the lines get updated over
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    15
# time. This update happens over many topological branches, some getting merged
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    16
# back.
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    17
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    18
# Running with `chg` in your path and `CHGHG` set is recommended for speed.
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    19
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    20
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    21
import hashlib
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
import os
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    23
import shutil
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
import subprocess
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    25
import sys
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    26
import tempfile
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    27
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    28
BUNDLE_NAME = 'big-file-churn.hg'
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    29
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    30
# constants for generating the repository
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    31
NB_CHANGESET = 5000
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    32
PERIOD_MERGING = 8
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    33
PERIOD_BRANCHING = 7
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    34
MOVE_BACK_MIN = 3
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    35
MOVE_BACK_RANGE = 5
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    36
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    37
# constants for generating the large file we keep updating
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    38
#
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    39
# At each revision, the beginning on the file change,
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
# and set of other lines changes too.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
    41
FILENAME = 'SPARSE-REVLOG-TEST-FILE'
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
NB_LINES = 10500
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
ALWAYS_CHANGE_LINES = 500
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
OTHER_CHANGES = 300
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    45
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
    46
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    47
def nextcontent(previous_content):
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    48
    """utility to produce a new file content from the previous one"""
51277
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
    49
    return hashlib.md5(previous_content).hexdigest().encode('ascii')
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    50
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
    51
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    52
def filecontent(iteridx, oldcontent):
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    53
    """generate a new file content
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    54
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    55
    The content is generated according the iteration index and previous
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    56
    content"""
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    57
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    58
    # initial call
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    59
    if iteridx is None:
51277
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
    60
        current = b''
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    61
    else:
51277
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
    62
        current = b"%d" % iteridx
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    63
43110
1fcf79e9943a tests: use range() in generate-churning-module.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43076
diff changeset
    64
    for idx in range(NB_LINES):
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    65
        do_change_line = True
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    66
        if oldcontent is not None and ALWAYS_CHANGE_LINES < idx:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    67
            do_change_line = not ((idx - iteridx) % OTHER_CHANGES)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    68
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    69
        if do_change_line:
51277
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
    70
            to_write = current + b'\n'
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    71
            current = nextcontent(current)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    72
        else:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    73
            to_write = oldcontent[idx]
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    74
        yield to_write
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    75
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
    76
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    77
def updatefile(filename, idx):
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    78
    """update <filename> to be at appropriate content for iteration <idx>"""
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    79
    existing = None
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    80
    if idx is not None:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    81
        with open(filename, 'rb') as old:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    82
            existing = old.readlines()
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    83
    with open(filename, 'wb') as target:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    84
        for line in filecontent(idx, existing):
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    85
            target.write(line)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    86
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
    87
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    88
def hg(command, *args):
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    89
    """call a mercurial command with appropriate config and argument"""
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    90
    env = os.environ.copy()
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    91
    if 'CHGHG' in env:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    92
        full_cmd = ['chg']
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    93
    else:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    94
        full_cmd = ['hg']
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    95
    full_cmd.append('--quiet')
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    96
    full_cmd.append(command)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    97
    if command == 'commit':
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    98
        # reproducible commit metadata
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    99
        full_cmd.extend(['--date', '0 0', '--user', 'test'])
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   100
    elif command == 'merge':
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   101
        # avoid conflicts by picking the local variant
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   102
        full_cmd.extend(['--tool', ':merge-local'])
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   103
    full_cmd.extend(args)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   104
    env['HGRCPATH'] = ''
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   105
    return subprocess.check_call(full_cmd, env=env)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   106
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
   107
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   108
def run(target):
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   109
    tmpdir = tempfile.mkdtemp(prefix='tmp-hg-test-big-file-bundle-')
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   110
    try:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   111
        os.chdir(tmpdir)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   112
        hg('init')
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   113
        updatefile(FILENAME, None)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   114
        hg('commit', '--addremove', '--message', 'initial commit')
43110
1fcf79e9943a tests: use range() in generate-churning-module.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43076
diff changeset
   115
        for idx in range(1, NB_CHANGESET + 1):
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   116
            if sys.stdout.isatty():
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   117
                print("generating commit #%d/%d" % (idx, NB_CHANGESET))
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   118
            if (idx % PERIOD_BRANCHING) == 0:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   119
                move_back = MOVE_BACK_MIN + (idx % MOVE_BACK_RANGE)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   120
                hg('update', ".~%d" % move_back)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   121
            if (idx % PERIOD_MERGING) == 0:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   122
                hg('merge', 'min(head())')
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   123
            updatefile(FILENAME, idx)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   124
            hg('commit', '--message', 'commit #%d' % idx)
41795
b59676077654 test: stabilize bundle generation for test-sparse-revlog.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39491
diff changeset
   125
        hg('bundle', '--all', target, '--config', 'devel.bundle.delta=p1')
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   126
        with open(target, 'rb') as bundle:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   127
            data = bundle.read()
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   128
            digest = hashlib.md5(data).hexdigest()
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   129
        with open(target + '.md5', 'wb') as md5file:
51277
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
   130
            md5file.write(digest.encode('ascii') + b'\n')
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   131
        if sys.stdout.isatty():
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   132
            print('bundle generated at "%s" md5: %s' % (target, digest))
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   133
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   134
    finally:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   135
        shutil.rmtree(tmpdir)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   136
    return 0
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   137
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
   138
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   139
if __name__ == '__main__':
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   140
    orig = os.path.realpath(os.path.dirname(sys.argv[0]))
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   141
    target = os.path.join(orig, os.pardir, 'cache', BUNDLE_NAME)
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
   142
    sys.exit(run(target))