[PATCH] largefiles: Use sha1sum.py since OS X has generic shasum utility
mpm at selenic.com
Tue Oct 25 10:51:09 CDT 2011
On Mon, 2011-10-24 at 20:35 -0400, Greg Ward wrote:
> On Mon, Oct 24, 2011 at 2:15 PM, Lee Cantey <lcantey at gmail.com> wrote:
> > # HG changeset patch
> > # User Lee Cantey <lcantey at gmail.com>
> > # Date 1319479837 25200
> > # Branch stable
> > # Node ID 17323a5ee76870b1b48e7308511c34c98825f35a
> > # Parent 8b8dd13295dbd733cc03ebb3c2af2f33d24d5428
> > largefiles: Use sha1sum.py since OS X has generic shasum utility.
> > diff -r 8b8dd13295db -r 17323a5ee768 tests/sha1sum.py
> > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> > +++ b/tests/sha1sum.py Mon Oct 24 11:10:37 2011 -0700
> > @@ -0,0 +1,42 @@
> > +#!/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.
> > +
> > +import sys, os
> > +
> > +try:
> > + from hashlib import sha1
> > +except ImportError:
> > + from sha import sha as sha1
> It looks like you just photocopied tests/md5sum.py and called it
> tests/sha1sum.py. It would be ever so much nicer to refactor, e.g.
> * rename md5sum.py to hash.py
> * make it take two args, hash algorithm and filename
> * update existing callers in tests/
> * make test-largefiles.t use it
As far as I'm aware, we only need one hash function for tests and it
needn't be cryptographically strong. I'll change the largefiles test to
use the existing md5sum.py.
> Obviously the first three steps have to be a single changeset. And
> there's more than one way to do it; that's just the first thing that
> popped into my head.
> > Also switch to from echo -n to printf
Hmm, this should have been caught by check-code. I'll look into that
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel