status: add a config knob for setting default of --terse
authorAugie Fackler <augie@google.com>
Mon, 14 May 2018 22:01:27 -0400
changeset 38100 18424aeece7f
parent 38099 5a87bf0bd343
child 38101 6acf41bb8d40
status: add a config knob for setting default of --terse I want --terse=u basically 100% of the time, but there's not a good way to do that before this patch. I'm very unhappy with how the default value for --terse looks rigt now, but it does *work*. The alternative would be to define an "optional string" flag type using fancyopts.customopt and then use that, leaving the default as None. Does anyone have a strong preference for that, or a better idea? Differential Revision: https://phab.mercurial-scm.org/D3627
mercurial/commands.py
mercurial/configitems.py
mercurial/help/config.txt
tests/test-status-terse.t
--- a/mercurial/commands.py	Sat May 19 16:50:30 2018 -0400
+++ b/mercurial/commands.py	Mon May 14 22:01:27 2018 -0400
@@ -4809,6 +4809,8 @@
     service = server.createservice(ui, repo, opts)
     return server.runservice(opts, initfn=service.init, runfn=service.run)
 
+_NOTTERSE = 'nothing'
+
 @command('^status|st',
     [('A', 'all', None, _('show status of all files')),
     ('m', 'modified', None, _('show only modified files')),
@@ -4819,7 +4821,7 @@
     ('u', 'unknown', None, _('show only unknown (not tracked) files')),
     ('i', 'ignored', None, _('show only ignored files')),
     ('n', 'no-status', None, _('hide status prefix')),
-    ('t', 'terse', '', _('show the terse output (EXPERIMENTAL)')),
+    ('t', 'terse', _NOTTERSE, _('show the terse output (EXPERIMENTAL)')),
     ('C', 'copies', None, _('show source of copied files')),
     ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
     ('', 'rev', [], _('show difference from revision'), _('REV')),
@@ -4917,6 +4919,11 @@
     revs = opts.get('rev')
     change = opts.get('change')
     terse = opts.get('terse')
+    if terse is _NOTTERSE:
+        if revs:
+            terse = ''
+        else:
+            terse = ui.config('commands', 'status.terse')
 
     if revs and change:
         msg = _('cannot specify --rev and --change at the same time')
--- a/mercurial/configitems.py	Sat May 19 16:50:30 2018 -0400
+++ b/mercurial/configitems.py	Mon May 14 22:01:27 2018 -0400
@@ -193,6 +193,9 @@
 coreconfigitem('commands', 'status.skipstates',
     default=[],
 )
+coreconfigitem('commands', 'status.terse',
+    default='',
+)
 coreconfigitem('commands', 'status.verbose',
     default=False,
 )
--- a/mercurial/help/config.txt	Sat May 19 16:50:30 2018 -0400
+++ b/mercurial/help/config.txt	Mon May 14 22:01:27 2018 -0400
@@ -442,6 +442,10 @@
     Make paths in :hg:`status` output relative to the current directory.
     (default: False)
 
+``status.terse``
+    Default value for the --terse flag, which condenes status output.
+    (default: empty)
+
 ``update.check``
     Determines what level of checking :hg:`update` will perform before moving
     to a destination revision. Valid values are ``abort``, ``none``,
--- a/tests/test-status-terse.t	Sat May 19 16:50:30 2018 -0400
+++ b/tests/test-status-terse.t	Mon May 14 22:01:27 2018 -0400
@@ -183,3 +183,55 @@
   $ hg status --terse marduic --rev 0 --rev 1
   abort: cannot use --terse with --rev
   [255]
+
+Config item to set the default terseness
+  $ cat <<EOF >> $HGRCPATH
+  > [commands]
+  > status.terse = u
+  > EOF
+  $ hg status -mu
+  M x/aa
+  M x/bb
+  ? a
+  ? b
+  ? x/l/
+  ? x/m/
+  ? x/n/
+  ? y/
+
+Command line flag overrides the default
+  $ hg status --terse=
+  M x/aa
+  M x/bb
+  ? a
+  ? b
+  ? x/l/aa
+  ? x/l/u/a/bb
+  ? x/l/u/bb
+  ? x/m/aa
+  ? x/n/aa
+  ? y/l
+  ? y/m
+  $ hg status --terse=mardu
+  M x/aa
+  M x/bb
+  ? a
+  ? b
+  ? x/l/
+  ? x/m/
+  ? x/n/
+  ? y/
+
+Specifying --rev should still work, with the terseness disabled.
+  $ hg status --rev 0
+  M x/aa
+  M x/bb
+  ? a
+  ? b
+  ? x/l/aa
+  ? x/l/u/a/bb
+  ? x/l/u/bb
+  ? x/m/aa
+  ? x/n/aa
+  ? y/l
+  ? y/m