##// END OF EJS Templates
formatter: add context manager interface for convenience...
Yuya Nishihara -
r29882:307b20e5 default
parent child Browse files
Show More
@@ -3963,15 +3963,11 b' def files(ui, repo, *pats, **opts):'
3963 end = '\n'
3963 end = '\n'
3964 if opts.get('print0'):
3964 if opts.get('print0'):
3965 end = '\0'
3965 end = '\0'
3966 fm = ui.formatter('files', opts)
3967 fmt = '%s' + end
3966 fmt = '%s' + end
3968
3967
3969 m = scmutil.match(ctx, pats, opts)
3968 m = scmutil.match(ctx, pats, opts)
3970 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3969 with ui.formatter('files', opts) as fm:
3971
3970 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3972 fm.end()
3973
3974 return ret
3975
3971
3976 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3972 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3977 def forget(ui, repo, *pats, **opts):
3973 def forget(ui, repo, *pats, **opts):
@@ -52,6 +52,11 b' class baseformatter(object):'
52 self._item = None
52 self._item = None
53 # function to convert node to string suitable for this output
53 # function to convert node to string suitable for this output
54 self.hexfunc = hex
54 self.hexfunc = hex
55 def __enter__(self):
56 return self
57 def __exit__(self, exctype, excvalue, traceback):
58 if exctype is None:
59 self.end()
55 def __nonzero__(self):
60 def __nonzero__(self):
56 '''return False if we're not doing real templating so we can
61 '''return False if we're not doing real templating so we can
57 skip extra work'''
62 skip extra work'''
General Comments 0
You need to be logged in to leave comments. Login now