Patchwork D6546: log: pass getcopies() function instead of getrenamed() to displayer (API)

login
register
mail settings
Submitter phabricator
Date June 19, 2019, 9:56 p.m.
Message ID <6bceab1700664e5665030452077da54d@localhost.localdomain>
Download mbox | patch
Permalink /patch/40615/
State Not Applicable
Headers show

Comments

phabricator - June 19, 2019, 9:56 p.m.
Closed by commit rHGa68350a7fc55: log: pass getcopies() function instead of getrenamed() to displayer (API) (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6546?vs=15596&id=15608

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6546/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6546

AFFECTED FILES
  mercurial/commands.py
  mercurial/logcmdutil.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -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()
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3887,12 +3887,12 @@ 
         # then filter the result by logcmdutil._makerevset() and --limit
         revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
 
-    getrenamed = None
+    getcopies = None
     if opts.get('copies'):
         endrev = None
         if revs:
             endrev = revs.max() + 1
-        getrenamed = scmutil.getrenamedfn(repo, endrev=endrev)
+        getcopies = scmutil.getcopiesfn(repo, endrev=endrev)
 
     ui.pager('log')
     displayer = logcmdutil.changesetdisplayer(ui, repo, opts, differ,
@@ -3901,7 +3901,7 @@ 
         displayfn = logcmdutil.displaygraphrevs
     else:
         displayfn = logcmdutil.displayrevs
-    displayfn(ui, repo, revs, displayer, getrenamed)
+    displayfn(ui, repo, revs, displayer, getcopies)
 
 @command('manifest',
     [('r', 'rev', '', _('revision to display'), _('REV')),