##// END OF EJS Templates
util: don't mess with builtins to emulate buffer()
Matt Mackall -
r15657:d976b1ef default
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from i18n import _
9 import mdiff, parsers, error, revlog
9 import mdiff, parsers, error, revlog, util
10 10 import array, struct
11 11
12 12 class manifestdict(dict):
@@ -164,7 +164,7 b' class manifest(revlog.revlog):'
164 164 dline = [""]
165 165 start = 0
166 166 # zero copy representation of addlist as a buffer
167 addbuf = buffer(addlist)
167 addbuf = util.buffer(addlist)
168 168
169 169 # start with a readonly loop that finds the offset of
170 170 # each line and creates the deltas
@@ -196,7 +196,7 b' class manifest(revlog.revlog):'
196 196 # apply the delta to the addlist, and get a delta for addrevision
197 197 cachedelta = (self.rev(p1), addlistdelta(addlist, delta))
198 198 arraytext = addlist
199 text = buffer(arraytext)
199 text = util.buffer(arraytext)
200 200
201 201 n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
202 202 self._mancache = (n, map, arraytext)
@@ -318,7 +318,7 b' def patchtext(bin):'
318 318 def patch(a, bin):
319 319 if len(a) == 0:
320 320 # skip over trivial delta header
321 return buffer(bin, 12)
321 return util.buffer(bin, 12)
322 322 return mpatch.patches(a, [bin])
323 323
324 324 # similar to difflib.SequenceMatcher.get_matching_blocks
@@ -104,18 +104,15 b" def _fastsha1(s=''):"
104 104 _fastsha1 = sha1 = _sha1
105 105 return _sha1(s)
106 106
107 import __builtin__
108
107 try:
108 buffer = buffer
109 except NameError:
109 110 if sys.version_info[0] < 3:
110 def fakebuffer(sliceable, offset=0):
111 def buffer(sliceable, offset=0):
111 112 return sliceable[offset:]
112 113 else:
113 def fakebuffer(sliceable, offset=0):
114 def buffer(sliceable, offset=0):
114 115 return memoryview(sliceable)[offset:]
115 try:
116 buffer
117 except NameError:
118 __builtin__.buffer = fakebuffer
119 116
120 117 import subprocess
121 118 closefds = os.name == 'posix'
General Comments 0
You need to be logged in to leave comments. Login now