0
  N   ˆl–Ü4ý( ©¤ýÔâ�fã/Üd*bÑ¿‘äÇò 8àû²<óe$ÏÇƒh¹Æa–Ü4ý( ©¤ýÔâ�fã/Üd*bÑ¿Ä      0
  "   ˆÉ�þDóM¶³r…Â² ’FšóÈ…�>ÓÿÇÆ¾Ä ?÷     # debugcommands.py - command processing for debug* commands
#
# Copyright 2005-2016 Olivia Mackall <olivia@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.


import binascii
import codecs
import collections
import contextlib
import difflib
import errno
import glob
import operator
import os
import platform
import random
import re
import socket
import ssl
import stat
import string
import subprocess
import sys
import time

from .i18n import _
from .node import (
    bin,
    hex,
    nullrev,
    short,
)
from .pycompat import (
    getattr,
    open,
)
from . import (
    bundle2,
    bundlerepo,
    changegroup,
    cmdutil,
    color,
    context,
    copies,
    dagparser,
    dirstateutils,
    encoding,
    error,
    exchange,
    extensions,
    filemerge,
    filesetlang,
    formatter,
    hg,
    httppeer,
    localrepo,
    lock as lockmod,
    logcmdutil,
    mergestate as mergestatemod,
    metadata,
    obsolete,
    obsutil,
    pathutil,
    phases,
    policy,
    pvec,
    pycompat,
    registrar,
    repair,
    repoview,
    requirements,
    revlog,
    revlogutils,
    revset,
    revsetlang,
    scmutil,
    setdiscovery,
    simplemerge,
    sshpeer,
    sslutil,
    streamclone,
    strip,
    tags as tagsmod,
    templater,
    treediscovery,
    upgrade,
    url as urlmod,
    util,
    vfs as vfsmod,
    wireprotoframing,
    wireprotoserver,
)
from .interfaces import repository
from .utils import (
    cborutil,
    compression,
    dateutil,
    procutil,
    stringutil,
    urlutil,
)

from .revlogutils import (
    constants as revlog_constants,
    debug as revlog_debug,
    deltas as deltautil,
    nodemap,
    rewrite,
    sidedata,
)

release = lockmod.release

table = {}
table.update(strip.command._table)
command = registrar.command(table)


@command(b'debugancestor', [], _(b'[INDEX] REV1 REV2'), optionalrepo=True)
def debugancestor(ui, repo, *args):
    """find the ancestor revision of two revisions in a given index"""
    if len(args) == 3:
        index, rev1, rev2 = args
        r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index)
        lookup = r.lookup
    elif len(args) == 2:
        if not repo:
            raise error.Abort(
                _(b'there is no Mercurial repository here (.hg not found)')
            )
        rev1, rev2 = args
        r = repo.changelog
        lookup = repo.lookup
    else:
        raise error.Abort(_(b'either two or three arguments required'))
    a = r.ancestor(lookup(rev1), lookup(rev2))
    ui.write(b'%d:%s\n' % (r.rev(a), hex(a)))


@command(b'debugantivirusrunning', [])
def debugantivirusrunning(ui, repo):
    """attempt to trigger an antivirus scanner to see if one is active"""
    with repo.cachevfs.open('eicar-test-file.com', b'wb') as f:
        f.write(
            util.b85decode(
                # This is a base85-armored version of the EICAR test file. See
                # https://en.wikipedia.org/wiki/EICAR_test_file for details.
                b'ST#=}P$fV?P+K%yP+C|uG$>GBDK|qyDK~v2MM*<JQY}+dK~6+LQba95P'
                b'E<)&Nm5l)EmTEQR4qnHOhq9iNGnJx'
            )
        )
    # Give an AV engine time to scan the file.
    time.sleep(2)
    util.unlink(repo.cachevfs.join('eicar-test-file.com'))


@command(b'debugapplystreamclonebundle', [], b'FILE')
def debugapplystreamclonebundle(ui, repo, fname):
    """apply a stream clone bundle file"""
    f = hg.openpath(ui, fname)
    gen = exchange.readbundle(ui, f, fname)
    gen.apply(repo)


@command(
    b'debugbuilddag',
    [
        (
            b'm',
            b'mergeable-file',
            None,
            _(b'add single file mergeable changes'),
        ),
        (
            b'o',
            b'overwritten-file',
            None,
            _(b'add single file all revs overwrite'),
        ),
        (b'n