Show More
@@ -438,6 +438,19 b' def makefilename(repo, pat, node, desc=N' | |||||
438 | raise error.Abort(_("invalid format spec '%%%s' in output filename") % |
|
438 | raise error.Abort(_("invalid format spec '%%%s' in output filename") % | |
439 | inst.args[0]) |
|
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 | def makefileobj(repo, pat, node=None, desc=None, total=None, |
|
454 | def makefileobj(repo, pat, node=None, desc=None, total=None, | |
442 | seqno=None, revwidth=None, mode='wb', modemap=None, |
|
455 | seqno=None, revwidth=None, mode='wb', modemap=None, | |
443 | pathname=None): |
|
456 | pathname=None): | |
@@ -454,17 +467,7 b' def makefileobj(repo, pat, node=None, de' | |||||
454 | else: |
|
467 | else: | |
455 | # if this fp can't be duped properly, return |
|
468 | # if this fp can't be duped properly, return | |
456 | # a dummy object that can be closed |
|
469 | # a dummy object that can be closed | |
457 | class wrappedfileobj(object): |
|
470 | return _unclosablefile(fp) | |
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) |
|
|||
468 | if util.safehasattr(pat, 'write') and writable: |
|
471 | if util.safehasattr(pat, 'write') and writable: | |
469 | return pat |
|
472 | return pat | |
470 | if util.safehasattr(pat, 'read') and 'r' in mode: |
|
473 | if util.safehasattr(pat, 'read') and 'r' in mode: |
General Comments 0
You need to be logged in to leave comments.
Login now