# HG changeset patch # User Franz Glasner # Date 1550445593 -3600 # Node ID 22b0d520dadd540cdb0464c25f8dd31b87bd5b8e # Parent a75cb8203117eced121fec74ad8746f4a0b75a73 Change responsibilities when calling "show_timestamps()". The formatter will be closed by the caller how because he does instantiate. diff -r a75cb8203117 -r 22b0d520dadd extensions/timestamps.py --- a/extensions/timestamps.py Mon Feb 18 00:13:00 2019 +0100 +++ b/extensions/timestamps.py Mon Feb 18 00:19:53 2019 +0100 @@ -182,8 +182,8 @@ elif opts.get("restore"): restore_timestamps(ui, repo, ctx, tsconfig=opts.get("tsconfig")) elif opts.get("show"): - fm = ui.formatter("timestamps", opts) - show_timestamps(ui, repo, ctx, fm, tsconfig=opts.get("tsconfig")) + with ui.formatter("timestamps", opts) as fm: + show_timestamps(ui, repo, ctx, fm, tsconfig=opts.get("tsconfig")) else: raise error.Abort(_("must give a command:" "--save or --restore, --show or --import")) @@ -264,7 +264,7 @@ _restore_timestamps(repo, ctx, matcher, ts, ui=ui) -def show_timestamps(ui, repo, ctx, fm, +def show_timestamps(ui, repo, ctx, formatter, tsconfig=None): def _tsv(v): @@ -283,30 +283,34 @@ else: files = iter(ts.files()) ui.pager("timestamps") - with fm: - for f in files: - fm.startitem() - fm.condwrite(not ui.debugflag and ui.verbose and f == "/version/", - "version", - " version=%d\n", - _tsv(ts[f])) - fm.condwrite(not ui.debugflag and ui.verbose and f == "/encoding/", - "encoding", - " encoding=%s\n", - _tsv(ts[f])) - fm.condwrite(not ui.debugflag and ui.verbose and f.startswith("/comment-"), - "comment", - " %s\n", - _tsv(ts[f])) - fm.condwrite(not ui.debugflag and ui.verbose and f.startswith("/-"), - "", - " \n") - fm.condwrite(ui.debugflag or not f.startswith("/"), - "match date file", - " %s %s\t%s\n", - '*' if matcher(f) else ' ', - _tsv(ts[f]), - f) + for f in files: + formatter.startitem() + formatter.condwrite( + not ui.debugflag and ui.verbose and f == "/version/", + "version", + " version=%d\n", + _tsv(ts[f])) + formatter.condwrite( + not ui.debugflag and ui.verbose and f == "/encoding/", + "encoding", + " encoding=%s\n", + _tsv(ts[f])) + formatter.condwrite( + not ui.debugflag and ui.verbose and f.startswith("/comment-"), + "comment", + " %s\n", + _tsv(ts[f])) + formatter.condwrite( + not ui.debugflag and ui.verbose and f.startswith("/-"), + "", + " \n") + formatter.condwrite( + ui.debugflag or not f.startswith("/"), + "match date file", + " %s %s\t%s\n", + '*' if matcher(f) else ' ', + _tsv(ts[f]), + f) def gen_matcher_from_tsconfig(repo, ctx, tsconfig=None, ui=None):