[PATCH] revlog, setup: Adds IronPython compatibility changes
Matt Mackall
mpm at selenic.com
Fri May 6 00:45:44 CDT 2011
On Thu, 2011-05-05 at 11:50 -0400, Zachary Gramana wrote:
> # HG changeset patch
> # User Zachary Gramana <zgramana at pottsconsultinggroup.com>
> # Date 1304609612 14400
> # Node ID d096e2af7865730d8f93d123481991c777e6fd64
> # Parent bedad898a28a3e6a25afff650a68e47c347ec1db
> revlog, setup: Adds IronPython compatibility changes
>
> diff -r bedad898a28a -r d096e2af7865 mercurial/revlog.py
> --- a/mercurial/revlog.py Thu May 05 11:33:02 2011 -0400
> +++ b/mercurial/revlog.py Thu May 05 11:33:32 2011 -0400
> @@ -54,6 +54,18 @@
> def offset_type(offset, type):
> return long(long(offset) << 16 | type)
>
> +def ensurestr(text):
> + """take either a buffer of a string, and return a string.
> +
> + IronPython treats all strings as unicode strings. Large
> + strings are passed as buffers. Currently, _sha.update and
> + zlib.compress don't like buffers, so we ensure they get strings.
> + """
> + if type(text) == buffer:
> + return str(text)
> + else:
> + return text
> +
> nullhash = _sha(nullid)
Seems you missed my comment here about util.fakebuffer.
> def hash(text, p1, p2):
> @@ -73,8 +85,8 @@
> l = [p1, p2]
> l.sort()
> s = _sha(l[0])
> - s.update(l[1])
> - s.update(text)
> + s.update(ensurestr(l[1]))
> + s.update(ensurestr(text))
> return s.digest()
>
> def compress(text):
> @@ -99,7 +111,7 @@
> if sum(map(len, p)) < l:
> bin = "".join(p)
> else:
> - bin = _compress(text)
> + bin = _compress(ensurestr(text))
> if bin is None or len(bin) > l:
> if text[0] == '\0':
> return ("", text)
> diff -r bedad898a28a -r d096e2af7865 setup.py
> --- a/setup.py Thu May 05 11:33:02 2011 -0400
> +++ b/setup.py Thu May 05 11:33:32 2011 -0400
> @@ -4,7 +4,7 @@
> # 'python setup.py install', or
> # 'python setup.py --help' for more options
>
> -import sys
> +import sys, os
> if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0,
> 'final'):
> raise SystemExit("Mercurial requires Python 2.4 or later.")
>
> @@ -36,13 +36,22 @@
> raise SystemExit(
> "Couldn't import standard zlib (incomplete Python install).")
>
> +# The base IronPython distribution (as of 2.7.1) doesn't support bz2
> try:
> - import bz2
> + isIronPython = os.path.split(sys.executable)[1] == "ipy.exe"
> except:
> - raise SystemExit(
> - "Couldn't import standard bz2 (incomplete Python install).")
> + pass
> +else:
> + if isIronPython:
> + print "(IronPython detected. Skipping bz2 import.)"
> + else:
> + try:
> + import bz2
> + except:
> + raise SystemExit(
> + "Couldn't import standard bz2 (incomplete Python
> install).")
>
> -import os, subprocess, time
> +import subprocess, time
> import shutil
> import tempfile
> from distutils import log
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list