Mercurial > hg
diff mercurial/logcmdutil.py @ 42504:a68350a7fc55
log: pass getcopies() function instead of getrenamed() to displayer (API)
This reduces the duplication between the two displayer functions (and
between them and scmutil.getcopiesfn()). It's still more code than two
patches ago, but there's less duplication.
Differential Revision: https://phab.mercurial-scm.org/D6546
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 19 Jun 2019 10:19:32 -0700 |
parents | c929f612afac |
children | 2372284d9457 |
line wrap: on
line diff
--- a/mercurial/logcmdutil.py Wed Jun 19 09:59:45 2019 -0700 +++ b/mercurial/logcmdutil.py Wed Jun 19 10:19:32 2019 -0700 @@ -862,7 +862,7 @@ return templ.renderdefault(props) return formatnode -def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, props=None): +def displaygraph(ui, repo, dag, displayer, edgefn, getcopies=None, props=None): props = props or {} formatnode = _graphnodeformatter(ui, displayer) state = graphmod.asciistate() @@ -890,13 +890,7 @@ for rev, type, ctx, parents in dag: char = formatnode(repo, ctx) - copies = None - if getrenamed: - copies = [] - for fn in ctx.files(): - rename = getrenamed(fn, ctx.rev()) - if rename: - copies.append((fn, rename)) + copies = getcopies(ctx) if getcopies else None edges = edgefn(type, char, state, rev, parents) firstedge = next(edges) width = firstedge[2] @@ -915,16 +909,10 @@ revdag = graphmod.dagwalker(repo, revs) displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges, getrenamed) -def displayrevs(ui, repo, revs, displayer, getrenamed): +def displayrevs(ui, repo, revs, displayer, getcopies): for rev in revs: ctx = repo[rev] - copies = None - if getrenamed is not None: - copies = [] - for fn in ctx.files(): - rename = getrenamed(fn, rev) - if rename: - copies.append((fn, rename)) + copies = getcopies(ctx) if getcopies else None displayer.show(ctx, copies=copies) displayer.flush(ctx) displayer.close()