##// END OF EJS Templates
cmdutil: reimplement file wrapper that disables close()...
Yuya Nishihara -
r27418:2ce4661a default
parent child Browse files
Show More
@@ -438,6 +438,19 b' def makefilename(repo, pat, node, desc=N'
438 438 raise error.Abort(_("invalid format spec '%%%s' in output filename") %
439 439 inst.args[0])
440 440
441 class _unclosablefile(object):
442 def __init__(self, fp):
443 self._fp = fp
444
445 def close(self):
446 pass
447
448 def __iter__(self):
449 return iter(self._fp)
450
451 def __getattr__(self, attr):
452 return getattr(self._fp, attr)
453
441 454 def makefileobj(repo, pat, node=None, desc=None, total=None,
442 455 seqno=None, revwidth=None, mode='wb', modemap=None,
443 456 pathname=None):
@@ -454,17 +467,7 b' def makefileobj(repo, pat, node=None, de'
454 467 else:
455 468 # if this fp can't be duped properly, return
456 469 # a dummy object that can be closed
457 class wrappedfileobj(object):
458 noop = lambda x: None
459 def __init__(self, f):
460 self.f = f
461 def __getattr__(self, attr):
462 if attr == 'close':
463 return self.noop
464 else:
465 return getattr(self.f, attr)
466
467 return wrappedfileobj(fp)
470 return _unclosablefile(fp)
468 471 if util.safehasattr(pat, 'write') and writable:
469 472 return pat
470 473 if util.safehasattr(pat, 'read') and 'r' in mode:
General Comments 0
You need to be logged in to leave comments. Login now