Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 362:22b0d520dadd
Change responsibilities when calling "show_timestamps()".
The formatter will be closed by the caller how because he does instantiate.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 18 Feb 2019 00:19:53 +0100 |
| parents | a75cb8203117 |
| children | cdd94f12d93d |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 31 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- 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):
