contrib/showstack.py
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 17 Nov 2017 00:06:45 -0500
changeset 35476 417e8e040102
parent 28522 f2fe7b199bb4
child 35656 c9eb92fb87b7
permissions -rw-r--r--
lfs: verify lfs object content when transferring to and from the remote store This avoids inserting corrupt files into the usercache, and local and remote stores. One down side is that the bad file won't be available locally for forensic purposes after a remote download. I'm thinking about adding an 'incoming' directory to the local lfs store to handle the download, and then move it to the 'objects' directory after it passes verification. That would have the additional benefit of not concatenating each transfer chunk in memory until the full file is transferred. Verification isn't needed when the data is passed back through the revlog interface or when the oid was just calculated, but otherwise it is on by default. The additional overhead should be well worth avoiding problems with file based remote stores, or buggy lfs servers. Having two different verify functions is a little sad, but the full data of the blob is mostly passed around in memory, because that's what the revlog interface wants. The upload function, however, chunks up the data. It would be ideal if that was how the content is always handled, but that's probably a huge project. I don't really like printing the long hash, but `hg debugdata` isn't a public interface, and is the only way to get it. The filelog and revision info is nowhere near this area, so recommending `hg verify` is the easiest thing to do.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26123
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
# showstack.py - extension to dump a Python stack trace on signal
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     2
#
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
28522
f2fe7b199bb4 showstack: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 26123
diff changeset
     5
from __future__ import absolute_import
f2fe7b199bb4 showstack: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 26123
diff changeset
     6
import signal
f2fe7b199bb4 showstack: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 26123
diff changeset
     7
import sys
f2fe7b199bb4 showstack: use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 26123
diff changeset
     8
import traceback
26123
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
def sigshow(*args):
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
    sys.stderr.write("\n")
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
    traceback.print_stack(args[1], limit=10, file=sys.stderr)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
    sys.stderr.write("----\n")
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
def extsetup(ui):
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
    signal.signal(signal.SIGQUIT, sigshow)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
    try:
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
        signal.signal(signal.SIGINFO, sigshow)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    19
    except AttributeError:
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
        pass