Mercurial > hg
changeset 36205:976e1cfb2f64
cmdutil: pass ctx to makefileobj() in place of repo/node pair (API)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 02 Apr 2015 23:28:16 +0900 |
parents | 33ed8b511185 |
children | 9ddc884e9a32 |
files | hgext/largefiles/overrides.py mercurial/cmdutil.py mercurial/commands.py mercurial/subrepo.py |
diffstat | 4 files changed, 6 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Thu Apr 02 23:32:28 2015 +0900 +++ b/hgext/largefiles/overrides.py Thu Apr 02 23:28:16 2015 +0900 @@ -1359,8 +1359,7 @@ m.visitdir = lfvisitdirfn for f in ctx.walk(m): - with cmdutil.makefileobj(repo, opts.get('output'), ctx.node(), - pathname=f) as fp: + with cmdutil.makefileobj(ctx, opts.get('output'), pathname=f) as fp: lf = lfutil.splitstandin(f) if lf is None or origmatchfn(f): # duplicating unreachable code from commands.cat
--- a/mercurial/cmdutil.py Thu Apr 02 23:32:28 2015 +0900 +++ b/mercurial/cmdutil.py Thu Apr 02 23:28:16 2015 +0900 @@ -956,19 +956,19 @@ def __exit__(self, exc_type, exc_value, exc_tb): pass -def makefileobj(repo, pat, node, desc=None, total=None, +def makefileobj(ctx, pat, desc=None, total=None, seqno=None, revwidth=None, mode='wb', modemap=None, pathname=None): writable = mode not in ('r', 'rb') if isstdiofilename(pat): + repo = ctx.repo() if writable: fp = repo.ui.fout else: fp = repo.ui.fin return _unclosablefile(fp) - ctx = repo[node] fn = makefilename(ctx, pat, desc, total, seqno, revwidth, pathname) if modemap is not None: mode = modemap.get(fn, mode) @@ -1546,7 +1546,7 @@ if not fp and fntemplate: desc_lines = ctx.description().rstrip().split('\n') desc = desc_lines[0] #Commit always has a first line. - fo = makefileobj(repo, fntemplate, ctx.node(), desc=desc, + fo = makefileobj(ctx, fntemplate, desc=desc, total=total, seqno=seqno, revwidth=revwidth, mode='wb', modemap=filemode) dest = fo.name
--- a/mercurial/commands.py Thu Apr 02 23:32:28 2015 +0900 +++ b/mercurial/commands.py Thu Apr 02 23:28:16 2015 +0900 @@ -486,7 +486,7 @@ if dest == '-': if kind == 'files': raise error.Abort(_('cannot archive plain files to stdout')) - dest = cmdutil.makefileobj(repo, dest, node) + dest = cmdutil.makefileobj(ctx, dest) if not prefix: prefix = os.path.basename(repo.root) + '-%h'
--- a/mercurial/subrepo.py Thu Apr 02 23:32:28 2015 +0900 +++ b/mercurial/subrepo.py Thu Apr 02 23:28:16 2015 +0900 @@ -1642,8 +1642,7 @@ # TODO: add support for non-plain formatter (see cmdutil.cat()) for f in match.files(): output = self._gitcommand(["show", "%s:%s" % (rev, f)]) - fp = cmdutil.makefileobj(self._subparent, fntemplate, - self._ctx.node(), + fp = cmdutil.makefileobj(self._ctx, fntemplate, pathname=self.wvfs.reljoin(prefix, f)) fp.write(output) fp.close()