tests/md5sum.py
author Boris Feld <boris.feld@octobus.net>
Thu, 19 Oct 2017 12:35:47 +0200
changeset 35049 b81ad5b78a81
parent 33892 904bc1dc2694
child 43076 2372284d9457
permissions -rwxr-xr-x
obsfate: makes successorsetverb takes the markers as argument Right now, successorsetverb only needs successors to compute the verb. But we will want use additional information (effect-flags and operation) in the near future to compute a better verb. Add the markers parameter now so extensions (like Evolve) could wrap the function and start experimenting around better obsfate verbs. As successorsetverb now takes both successorset and markers parameters, rename it to obsfateverb, successorsetandmarkersverb was too long. Differential Revision: https://phab.mercurial-scm.org/D1191

#!/usr/bin/env python
#
# Based on python's Tools/scripts/md5sum.py
#
# This software may be used and distributed according to the terms
# of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is
# GPL-compatible.

from __future__ import absolute_import

import hashlib
import os
import sys

try:
    import msvcrt
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
    pass

for filename in sys.argv[1:]:
    try:
        fp = open(filename, 'rb')
    except IOError as msg:
        sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg))
        sys.exit(1)

    m = hashlib.md5()
    try:
        for data in iter(lambda: fp.read(8192), b''):
            m.update(data)
    except IOError as msg:
        sys.stderr.write('%s: I/O error: %s\n' % (filename, msg))
        sys.exit(1)
    sys.stdout.write('%s  %s\n' % (m.hexdigest(), filename))

sys.exit(0)