comparison mercurial/cmdutil.py @ 36538:d7a23d6184a2

cmdutil: reorder optional arguments passed to makefileobj() **props will be passed directly to templater.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 18 Feb 2018 10:58:15 +0900
parents 165cf86365ff
children aa3294027936
comparison
equal deleted inserted replaced
36537:165cf86365ff 36538:d7a23d6184a2
952 return self 952 return self
953 953
954 def __exit__(self, exc_type, exc_value, exc_tb): 954 def __exit__(self, exc_type, exc_value, exc_tb):
955 pass 955 pass
956 956
957 def makefileobj(ctx, pat, total=None, 957 def makefileobj(ctx, pat, mode='wb', modemap=None, **props):
958 seqno=None, revwidth=None, mode='wb', modemap=None,
959 pathname=None):
960
961 writable = mode not in ('r', 'rb') 958 writable = mode not in ('r', 'rb')
962 959
963 if isstdiofilename(pat): 960 if isstdiofilename(pat):
964 repo = ctx.repo() 961 repo = ctx.repo()
965 if writable: 962 if writable:
966 fp = repo.ui.fout 963 fp = repo.ui.fout
967 else: 964 else:
968 fp = repo.ui.fin 965 fp = repo.ui.fin
969 return _unclosablefile(fp) 966 return _unclosablefile(fp)
970 fn = makefilename(ctx, pat, total, seqno, revwidth, pathname) 967 fn = makefilename(ctx, pat, **props)
971 if modemap is not None: 968 if modemap is not None:
972 mode = modemap.get(fn, mode) 969 mode = modemap.get(fn, mode)
973 if mode == 'wb': 970 if mode == 'wb':
974 modemap[fn] = 'ab' 971 modemap[fn] = 'ab'
975 return open(fn, mode) 972 return open(fn, mode)
1540 1537
1541 for seqno, rev in enumerate(revs, 1): 1538 for seqno, rev in enumerate(revs, 1):
1542 ctx = repo[rev] 1539 ctx = repo[rev]
1543 fo = None 1540 fo = None
1544 if not fp and fntemplate: 1541 if not fp and fntemplate:
1545 fo = makefileobj(ctx, fntemplate, 1542 fo = makefileobj(ctx, fntemplate, mode='wb', modemap=filemode,
1546 total=total, seqno=seqno, revwidth=revwidth, 1543 total=total, seqno=seqno, revwidth=revwidth)
1547 mode='wb', modemap=filemode)
1548 dest = fo.name 1544 dest = fo.name
1549 def write(s, **kw): 1545 def write(s, **kw):
1550 fo.write(s) 1546 fo.write(s)
1551 if not dest.startswith('<'): 1547 if not dest.startswith('<'):
1552 repo.ui.note("%s\n" % dest) 1548 repo.ui.note("%s\n" % dest)