##// END OF EJS Templates
convert: simplify getargmax() with propertycache
Patrick Mezard -
r15606:2ad4e9b4 default
parent child Browse files
Show More
@@ -11,6 +11,8 b' import cPickle as pickle'
11 11 from mercurial import util
12 12 from mercurial.i18n import _
13 13
14 propertycache = util.propertycache
15
14 16 def encodeargs(args):
15 17 def encodearg(s):
16 18 lines = base64.encodestring(s)
@@ -321,14 +323,12 b' class commandline(object):'
321 323 self.checkexit(status, ''.join(output))
322 324 return output
323 325
324 def getargmax(self):
325 if '_argmax' in self.__dict__:
326 return self._argmax
327
326 @propertycache
327 def argmax(self):
328 328 # POSIX requires at least 4096 bytes for ARG_MAX
329 self._argmax = 4096
329 argmax = 4096
330 330 try:
331 self._argmax = os.sysconf("SC_ARG_MAX")
331 argmax = os.sysconf("SC_ARG_MAX")
332 332 except:
333 333 pass
334 334
@@ -339,13 +339,11 b' class commandline(object):'
339 339
340 340 # Since ARG_MAX is for command line _and_ environment, lower our limit
341 341 # (and make happy Windows shells while doing this).
342
343 self._argmax = self._argmax / 2 - 1
344 return self._argmax
342 return argmax / 2 - 1
345 343
346 344 def limit_arglist(self, arglist, cmd, closestdin, *args, **kwargs):
347 345 cmdlen = len(self._cmdline(cmd, closestdin, *args, **kwargs))
348 limit = self.getargmax() - cmdlen
346 limit = self.argmax - cmdlen
349 347 bytes = 0
350 348 fl = []
351 349 for fn in arglist:
General Comments 0
You need to be logged in to leave comments. Login now