comparison mercurial/cmdutil.py @ 14291:1a791993ce59

cmdutil: make_file to makefileobj
author Matt Mackall <mpm@selenic.com>
date Tue, 10 May 2011 16:08:47 -0500
parents 86e70956da4f
children 2daa5179e73f
comparison
equal deleted inserted replaced
14290:86e70956da4f 14291:1a791993ce59
232 return ''.join(newname) 232 return ''.join(newname)
233 except KeyError, inst: 233 except KeyError, inst:
234 raise util.Abort(_("invalid format spec '%%%s' in output filename") % 234 raise util.Abort(_("invalid format spec '%%%s' in output filename") %
235 inst.args[0]) 235 inst.args[0])
236 236
237 def make_file(repo, pat, node=None, 237 def makefileobj(repo, pat, node=None, total=None,
238 total=None, seqno=None, revwidth=None, mode='wb', pathname=None): 238 seqno=None, revwidth=None, mode='wb', pathname=None):
239 239
240 writable = mode not in ('r', 'rb') 240 writable = mode not in ('r', 'rb')
241 241
242 if not pat or pat == '-': 242 if not pat or pat == '-':
243 fp = writable and sys.stdout or sys.stdin 243 fp = writable and sys.stdout or sys.stdin
539 parents.reverse() 539 parents.reverse()
540 prev = (parents and parents[0]) or nullid 540 prev = (parents and parents[0]) or nullid
541 541
542 shouldclose = False 542 shouldclose = False
543 if not fp: 543 if not fp:
544 fp = make_file(repo, template, node, total=total, seqno=seqno, 544 fp = makefileobj(repo, template, node, total=total, seqno=seqno,
545 revwidth=revwidth, mode='ab') 545 revwidth=revwidth, mode='ab')
546 if fp != template: 546 if fp != template:
547 shouldclose = True 547 shouldclose = True
548 if fp != sys.stdout and hasattr(fp, 'name'): 548 if fp != sys.stdout and hasattr(fp, 'name'):
549 repo.ui.note("%s\n" % fp.name) 549 repo.ui.note("%s\n" % fp.name)
550 550