Patchwork [2,of,5] gendoc: use real ui in place of stdout

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 29, 2015, 3:59 p.m.
Message ID <52e2b23458b3249308d7.1443542373@mimosa>
Download mbox | patch
Permalink /patch/10684/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 29, 2015, 3:59 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1443364477 -32400
#      Sun Sep 27 23:34:37 2015 +0900
# Node ID 52e2b23458b3249308d7ab277d861d452e1570ae
# Parent  54b6badfbf790114379de2f18e213b1146af11b2
gendoc: use real ui in place of stdout

ui attributes will be required by a help function, so a file object can't be
used as a fake ui.

Patch

diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -14,6 +14,7 @@  from mercurial.commands import table, gl
 from mercurial.i18n import gettext, _
 from mercurial.help import helptable, loaddoc
 from mercurial import extensions
+from mercurial import ui as uimod
 
 def get_desc(docstr):
     if not docstr:
@@ -198,7 +199,8 @@  if __name__ == "__main__":
     if len(sys.argv) > 1:
         doc = sys.argv[1]
 
+    ui = uimod.ui()
     if doc == 'hg.1.gendoc':
-        showdoc(sys.stdout)
+        showdoc(ui)
     else:
-        showtopic(sys.stdout, sys.argv[1])
+        showtopic(ui, sys.argv[1])