Show More
@@ -19,6 +19,8 | |||
|
19 | 19 | |
|
20 | 20 | # Modified by Benoit Boissinot: |
|
21 | 21 | # - fix for digest auth (inspired from urllib2.py @ Python v2.4) |
|
22 | # Modified by Dirkjan Ochtman: | |
|
23 | # - import md5 function from a local util module | |
|
22 | 24 | |
|
23 | 25 | """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. |
|
24 | 26 | |
@@ -450,7 +452,7 def error_handler(url): | |||
|
450 | 452 | keepalive_handler.close_all() |
|
451 | 453 | |
|
452 | 454 | def continuity(url): |
|
453 | import md5 | |
|
455 | from util import md5 | |
|
454 | 456 | format = '%25s: %s' |
|
455 | 457 | |
|
456 | 458 | # first fetch the file with the normal http handler |
@@ -6,7 +6,7 | |||
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 |
import bdiff, mpatch, re, struct, util |
|
|
9 | import bdiff, mpatch, re, struct, util | |
|
10 | 10 | |
|
11 | 11 | def splitnewlines(text): |
|
12 | 12 | '''like str.splitlines, but only split on newlines.''' |
@@ -80,7 +80,7 def unidiff(a, ad, b, bd, fn1, fn2, r=No | |||
|
80 | 80 | if not opts.text and (util.binary(a) or util.binary(b)): |
|
81 | 81 | def h(v): |
|
82 | 82 | # md5 is used instead of sha1 because md5 is supposedly faster |
|
83 |
return md5 |
|
|
83 | return util.md5(v).digest() | |
|
84 | 84 | if a and b and len(a) == len(b) and h(a) == h(b): |
|
85 | 85 | return "" |
|
86 | 86 | l = ['Binary file %s has changed\n' % fn1] |
@@ -9,7 +9,7 | |||
|
9 | 9 | from i18n import _ |
|
10 | 10 | from node import hex, nullid, short |
|
11 | 11 | import base85, cmdutil, mdiff, util, context, revlog, diffhelpers, copies |
|
12 |
import cStringIO, email.Parser, os, popen2, re, |
|
|
12 | import cStringIO, email.Parser, os, popen2, re, errno | |
|
13 | 13 | import sys, tempfile, zlib |
|
14 | 14 | |
|
15 | 15 | class PatchError(Exception): |
@@ -1120,7 +1120,7 def b85diff(to, tn): | |||
|
1120 | 1120 | if not text: |
|
1121 | 1121 | return '0' * 40 |
|
1122 | 1122 | l = len(text) |
|
1123 |
s = |
|
|
1123 | s = util.sha1('blob %d\0' % l) | |
|
1124 | 1124 | s.update(text) |
|
1125 | 1125 | return s.hexdigest() |
|
1126 | 1126 |
@@ -13,13 +13,13 of the GNU General Public License, incor | |||
|
13 | 13 | from node import bin, hex, nullid, nullrev, short |
|
14 | 14 | from i18n import _ |
|
15 | 15 | import changegroup, errno, ancestor, mdiff |
|
16 |
import |
|
|
16 | import struct, util, zlib | |
|
17 | 17 | |
|
18 | 18 | _pack = struct.pack |
|
19 | 19 | _unpack = struct.unpack |
|
20 | 20 | _compress = zlib.compress |
|
21 | 21 | _decompress = zlib.decompress |
|
22 |
_sha = |
|
|
22 | _sha = util.sha1 | |
|
23 | 23 | |
|
24 | 24 | # revlog flags |
|
25 | 25 | REVLOGV0 = 0 |
@@ -17,12 +17,38 import cStringIO, errno, getpass, re, sh | |||
|
17 | 17 | import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil |
|
18 | 18 | import urlparse |
|
19 | 19 | |
|
20 | # Python compatibility | |
|
21 | ||
|
20 | 22 | try: |
|
21 | 23 | set = set |
|
22 | 24 | frozenset = frozenset |
|
23 | 25 | except NameError: |
|
24 | 26 | from sets import Set as set, ImmutableSet as frozenset |
|
25 | 27 | |
|
28 | _md5 = None | |
|
29 | def md5(s): | |
|
30 | global _md5 | |
|
31 | if _md5 is None: | |
|
32 | try: | |
|
33 | import hashlib | |
|
34 | _md5 = hashlib.md5 | |
|
35 | except ImportError: | |
|
36 | import md5 | |
|
37 | _md5 = md5.md5 | |
|
38 | return _md5(s) | |
|
39 | ||
|
40 | _sha1 = None | |
|
41 | def sha1(s): | |
|
42 | global _sha1 | |
|
43 | if _sha1 is None: | |
|
44 | try: | |
|
45 | import hashlib | |
|
46 | _sha1 = hashlib.sha1 | |
|
47 | except ImportError: | |
|
48 | import sha | |
|
49 | _sha1 = sha.sha | |
|
50 | return _sha1(s) | |
|
51 | ||
|
26 | 52 | try: |
|
27 | 53 | _encoding = os.environ.get("HGENCODING") |
|
28 | 54 | if sys.platform == 'darwin' and not _encoding: |
@@ -7,7 +7,11 | |||
|
7 | 7 | # GPL-compatible. |
|
8 | 8 | |
|
9 | 9 | import sys |
|
10 | import md5 | |
|
10 | ||
|
11 | try: | |
|
12 | from hashlib import md5 | |
|
13 | except ImportError: | |
|
14 | from md5 import md5 | |
|
11 | 15 | |
|
12 | 16 | for filename in sys.argv[1:]: |
|
13 | 17 | try: |
@@ -16,7 +20,7 for filename in sys.argv[1:]: | |||
|
16 | 20 | sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) |
|
17 | 21 | sys.exit(1) |
|
18 | 22 | |
|
19 |
m = md5 |
|
|
23 | m = md5() | |
|
20 | 24 | try: |
|
21 | 25 | while 1: |
|
22 | 26 | data = fp.read(8192) |
General Comments 0
You need to be logged in to leave comments.
Login now