[PATCH 3 of 4] log: factor out function to feed revisions to displayer

Yuya Nishihara yuya at tcha.org
Sun Feb 11 20:04:59 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1516518920 -32400
#      Sun Jan 21 16:15:20 2018 +0900
# Node ID e5ba72e0361bb859b1688ab1bc620c6ca870d951
# Parent  cd8ada5bfb23a9143a022ee0002a8fdba5fb9f0d
log: factor out function to feed revisions to displayer

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3434,22 +3434,10 @@ def log(ui, repo, *pats, **opts):
     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')),
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -899,10 +899,24 @@ def displaygraph(ui, repo, dag, displaye
             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]:


More information about the Mercurial-devel mailing list