# HG changeset patch # User Patrick Mezard # Date 1322847392 -3600 # Node ID 2ad4e9b44d8b7e367e4a2363e0a8ea73b7b7dd45 # Parent 2ad5b8937d0d648d2cfeb0998ed12e2ce8c2e6d9 convert: simplify getargmax() with propertycache diff -r 2ad5b8937d0d -r 2ad4e9b44d8b hgext/convert/common.py --- a/hgext/convert/common.py Fri Dec 02 17:38:07 2011 +0100 +++ b/hgext/convert/common.py Fri Dec 02 18:36:32 2011 +0100 @@ -11,6 +11,8 @@ from mercurial import util from mercurial.i18n import _ +propertycache = util.propertycache + def encodeargs(args): def encodearg(s): lines = base64.encodestring(s) @@ -321,14 +323,12 @@ self.checkexit(status, ''.join(output)) return output - def getargmax(self): - if '_argmax' in self.__dict__: - return self._argmax - + @propertycache + def argmax(self): # POSIX requires at least 4096 bytes for ARG_MAX - self._argmax = 4096 + argmax = 4096 try: - self._argmax = os.sysconf("SC_ARG_MAX") + argmax = os.sysconf("SC_ARG_MAX") except: pass @@ -339,13 +339,11 @@ # Since ARG_MAX is for command line _and_ environment, lower our limit # (and make happy Windows shells while doing this). - - self._argmax = self._argmax / 2 - 1 - return self._argmax + return argmax / 2 - 1 def limit_arglist(self, arglist, cmd, closestdin, *args, **kwargs): cmdlen = len(self._cmdline(cmd, closestdin, *args, **kwargs)) - limit = self.getargmax() - cmdlen + limit = self.argmax - cmdlen bytes = 0 fl = [] for fn in arglist: