comparison hgext/mq.py @ 14168:135e244776f0

prevent transient leaks of file handle by using new helper functions These leaks may occur in environments that don't employ a reference counting GC, i.e. PyPy. This implies: - changing opener(...).read() calls to opener.read(...) - changing opener(...).write() calls to opener.write(...) - changing open(...).read(...) to util.readfile(...) - changing open(...).write(...) to util.writefile(...)
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 02 May 2011 10:11:18 +0200
parents 3c616f512a5b
children bab267e7fc1a
comparison
equal deleted inserted replaced
14167:0e4753807c93 14168:135e244776f0
289 n, name = entry 289 n, name = entry
290 yield statusentry(bin(n), name) 290 yield statusentry(bin(n), name)
291 elif l.strip(): 291 elif l.strip():
292 self.ui.warn(_('malformated mq status line: %s\n') % entry) 292 self.ui.warn(_('malformated mq status line: %s\n') % entry)
293 # else we ignore empty lines 293 # else we ignore empty lines
294 lines = self.opener(self.status_path).read().splitlines() 294 lines = self.opener.read(self.status_path).splitlines()
295 return list(parselines(lines)) 295 return list(parselines(lines))
296 return [] 296 return []
297 297
298 @util.propertycache 298 @util.propertycache
299 def full_series(self): 299 def full_series(self):
300 if os.path.exists(self.join(self.series_path)): 300 if os.path.exists(self.join(self.series_path)):
301 return self.opener(self.series_path).read().splitlines() 301 return self.opener.read(self.series_path).splitlines()
302 return [] 302 return []
303 303
304 @util.propertycache 304 @util.propertycache
305 def series(self): 305 def series(self):
306 self.parse_series() 306 self.parse_series()
410 410
411 def active(self): 411 def active(self):
412 if self.active_guards is None: 412 if self.active_guards is None:
413 self.active_guards = [] 413 self.active_guards = []
414 try: 414 try:
415 guards = self.opener(self.guards_path).read().split() 415 guards = self.opener.read(self.guards_path).split()
416 except IOError, err: 416 except IOError, err:
417 if err.errno != errno.ENOENT: 417 if err.errno != errno.ENOENT:
418 raise 418 raise
419 guards = [] 419 guards = []
420 for i, guard in enumerate(guards): 420 for i, guard in enumerate(guards):