# HG changeset patch # User Yuya Nishihara # Date 1427984896 -32400 # Node ID 976e1cfb2f64e59e4f56ed17b7bef80bb3c3eadf # Parent 33ed8b511185d4e419011b2126ab82d7615047d2 cmdutil: pass ctx to makefileobj() in place of repo/node pair (API) diff -r 33ed8b511185 -r 976e1cfb2f64 hgext/largefiles/overrides.py --- 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 diff -r 33ed8b511185 -r 976e1cfb2f64 mercurial/cmdutil.py --- 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 diff -r 33ed8b511185 -r 976e1cfb2f64 mercurial/commands.py --- 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' diff -r 33ed8b511185 -r 976e1cfb2f64 mercurial/subrepo.py --- 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()