comparison mercurial/commands.py @ 29070:29a7d591ff42

ui: add new config option for help text width Before this patch, when printing help text using `hg help`, or `hg log -h`, the output will wrap at 78 chars even if the user has a bigger terminal width and there is no config option to change it, making the experience different from the commonly used `man` tool. This patch introduces a new config option `ui.textwidth`, which replaces the hardcoded number. It's set to 78 by default to maintain compatibility. When set to 0, `hg help` will behave more like `man`.
author Jun Wu <quark@fb.com>
date Wed, 04 May 2016 18:18:24 +0100
parents fc88a942fe8d
children fe50341de1ff
comparison
equal deleted inserted replaced
29069:e2a1648a6ce7 29070:29a7d591ff42
4565 topic. 4565 topic.
4566 4566
4567 Returns 0 if successful. 4567 Returns 0 if successful.
4568 """ 4568 """
4569 4569
4570 textwidth = min(ui.termwidth(), 80) - 2 4570 textwidth = ui.configint('ui', 'textwidth', 78)
4571 termwidth = ui.termwidth() - 2
4572 if textwidth <= 0 or termwidth < textwidth:
4573 textwidth = termwidth
4571 4574
4572 keep = opts.get('system') or [] 4575 keep = opts.get('system') or []
4573 if len(keep) == 0: 4576 if len(keep) == 0:
4574 if sys.platform.startswith('win'): 4577 if sys.platform.startswith('win'):
4575 keep.append('windows') 4578 keep.append('windows')