changeset 36198:7bc10d3f68b4

log: factor out function to feed revisions to displayer
author Yuya Nishihara <yuya@tcha.org>
date Sun, 21 Jan 2018 16:15:20 +0900
parents db26e6a0a677
children 2d6e03a28c31
files mercurial/commands.py mercurial/logcmdutil.py
diffstat 2 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Jan 21 16:04:59 2018 +0900
+++ b/mercurial/commands.py	Sun Jan 21 16:15:20 2018 +0900
@@ -3434,22 +3434,10 @@
     displayer = logcmdutil.changesetdisplayer(ui, repo, opts, differ,
                                               buffered=True)
     if opts.get('graph'):
-        logcmdutil.graphlog(ui, repo, revs, displayer, getrenamed)
-        return
-
-    for rev in revs:
-        ctx = repo[rev]
-        copies = None
-        if getrenamed is not None and rev:
-            copies = []
-            for fn in ctx.files():
-                rename = getrenamed(fn, rev)
-                if rename:
-                    copies.append((fn, rename[0]))
-        displayer.show(ctx, copies=copies)
-        displayer.flush(ctx)
-
-    displayer.close()
+        displayfn = logcmdutil.displaygraphrevs
+    else:
+        displayfn = logcmdutil.displayrevs
+    displayfn(ui, repo, revs, displayer, getrenamed)
 
 @command('manifest',
     [('r', 'rev', '', _('revision to display'), _('REV')),
--- a/mercurial/logcmdutil.py	Sun Jan 21 16:04:59 2018 +0900
+++ b/mercurial/logcmdutil.py	Sun Jan 21 16:15:20 2018 +0900
@@ -899,10 +899,24 @@
             lines = []
     displayer.close()
 
-def graphlog(ui, repo, revs, displayer, getrenamed):
+def displaygraphrevs(ui, repo, revs, displayer, getrenamed):
     revdag = graphmod.dagwalker(repo, revs)
     displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges, getrenamed)
 
+def displayrevs(ui, repo, revs, displayer, getrenamed):
+    for rev in revs:
+        ctx = repo[rev]
+        copies = None
+        if getrenamed is not None and rev:
+            copies = []
+            for fn in ctx.files():
+                rename = getrenamed(fn, rev)
+                if rename:
+                    copies.append((fn, rename[0]))
+        displayer.show(ctx, copies=copies)
+        displayer.flush(ctx)
+    displayer.close()
+
 def checkunsupportedgraphflags(pats, opts):
     for op in ["newest_first"]:
         if op in opts and opts[op]: