Patchwork [1,of,2] ui: make terminal size always come from util (issue5395)

login
register
mail settings
Submitter Simon Farnsworth
Date Oct. 7, 2016, 12:07 p.m.
Message ID <5831f8daf49f2eabe5b7.1475842073@simonfar-macbookpro.local>
Download mbox | patch
Permalink /patch/16874/
State Changes Requested
Headers show

Comments

Simon Farnsworth - Oct. 7, 2016, 12:07 p.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1475835159 -7200
#      Fri Oct 07 12:12:39 2016 +0200
# Node ID 5831f8daf49f2eabe5b7e6ba0f3da1fc61b5ed09
# Parent  1779dde4c9ef97cb242f8d501655f236f66e5439
ui: make terminal size always come from util (issue5395)

Everyone uses the ui version of termwidth(), not the util version. Make the
ui version just an alias for the util version

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -814,11 +814,6 @@ 
     def termwidth(self):
         '''how wide is the terminal in columns?
         '''
-        if 'COLUMNS' in os.environ:
-            try:
-                return int(os.environ['COLUMNS'])
-            except ValueError:
-                pass
         return util.termwidth()
 
     def formatted(self):
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -120,13 +120,20 @@ 
 statfiles = getattr(osutil, 'statfiles', platform.statfiles)
 statisexec = platform.statisexec
 statislink = platform.statislink
-termwidth = platform.termwidth
 testpid = platform.testpid
 umask = platform.umask
 unlink = platform.unlink
 unlinkpath = platform.unlinkpath
 username = platform.username
 
+def termwidth():
+    if 'COLUMNS' in os.environ:
+        try:
+            return int(os.environ['COLUMNS'])
+        except ValueError:
+            pass
+    return platform.termwidth()
+
 # Python compatibility
 
 _notset = object()