# HG changeset patch # User Matt Mackall # Date 2011-10-31 20:41:39 # Node ID d7bfbc92a1c0b5d878febf44e1a1f1dc83b1259a # Parent a5a6a9b7f3b92225512d277505bd49e2a32cd2b8 util: add a doctest for empty sha() calls diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -443,7 +443,7 @@ def mkstemp(repo, prefix): '''Returns a file descriptor and a filename corresponding to a temporary file in the repo's largefiles store.''' path = repo.join(longname) - util.makedirs(repo.join(path)) + util.makedirs(path) return tempfile.mkstemp(prefix=prefix, dir=path) class storeprotonotcapable(Exception): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -74,6 +74,16 @@ username = platform.username # Python compatibility def sha1(s=''): + ''' + Low-overhead wrapper around Python's SHA support + + >>> f = _fastsha1 + >>> a = sha1() + >>> a = f() + >>> a.hexdigest() + 'da39a3ee5e6b4b0d3255bfef95601890afd80709' + ''' + return _fastsha1(s) _notset = object() diff --git a/tests/test-doctest.py b/tests/test-doctest.py --- a/tests/test-doctest.py +++ b/tests/test-doctest.py @@ -4,6 +4,9 @@ if 'TERM' in os.environ: del os.environ['TERM'] import doctest +import mercurial.util +doctest.testmod(mercurial.util) + import mercurial.changelog doctest.testmod(mercurial.changelog) @@ -22,9 +25,6 @@ doctest.testmod(mercurial.ui) import mercurial.url doctest.testmod(mercurial.url) -import mercurial.util -doctest.testmod(mercurial.util) - import mercurial.encoding doctest.testmod(mercurial.encoding)