diff tests/test-commit-interactive-curses.t @ 28542:71e12fc53b80

ui: add new config flag for interface selection This patch introduces a new config flag ui.interface to select the interface for interactive commands. It currently only applies to chunks selection. The config can be overridden on a per feature basis with the flag ui.interface.<feature>. features for the moment can only be 'chunkselector', moving forward we expect to have 'histedit' and other commands there. If an incorrect value is given to ui.interface we print a warning and use the default interface: text. If HGPLAIN is specified we also use the default interface: text. Note that we fail quickly if a feature does not handle all the interfaces that we permit in ui.interface; in future, we could design a fallback path (e.g. blackpearl to curses, curses to text), but let's leave that until we need it.
author Simon Farnsworth <simonfar@fb.com>
date Mon, 14 Mar 2016 15:01:27 +0000
parents 505a10b504ed
children f7874de435c5
line wrap: on
line diff
--- a/tests/test-commit-interactive-curses.t	Fri Mar 11 10:30:08 2016 +0000
+++ b/tests/test-commit-interactive-curses.t	Mon Mar 14 15:01:27 2016 +0000
@@ -1,5 +1,6 @@
 Set up a repo
 
+  $ cp $HGRCPATH $HGRCPATH.pretest
   $ cat <<EOF >> $HGRCPATH
   > [ui]
   > interactive = true
@@ -223,3 +224,90 @@
   hello world
 
 
+Check ui.interface logic for the chunkselector
+
+The default interface is text
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ chunkselectorinterface() {
+  > python <<EOF
+  > from mercurial import hg, ui, parsers;\
+  > repo = hg.repository(ui.ui(), ".");\
+  > print repo.ui.interface("chunkselector")
+  > EOF
+  > }
+  $ chunkselectorinterface
+  text
+
+If only the default is set, we'll use that for the feature, too
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = curses
+  > EOF
+  $ chunkselectorinterface
+  curses
+
+It is possible to override the default interface with a feature specific
+interface
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = text
+  > interface.chunkselector = curses
+  > EOF
+
+  $ chunkselectorinterface
+  curses
+
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = curses
+  > interface.chunkselector = text
+  > EOF
+
+  $ chunkselectorinterface
+  text
+
+If a bad interface name is given, we use the default value (with a nice
+error message to suggest that the configuration needs to be fixed)
+
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = blah
+  > EOF
+  $ chunkselectorinterface
+  invalid value for ui.interface: blah (using text)
+  text
+
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = curses
+  > interface.chunkselector = blah
+  > EOF
+  $ chunkselectorinterface
+  invalid value for ui.interface.chunkselector: blah (using curses)
+  curses
+
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = blah
+  > interface.chunkselector = curses
+  > EOF
+  $ chunkselectorinterface
+  invalid value for ui.interface: blah
+  curses
+
+  $ cp $HGRCPATH.pretest $HGRCPATH
+  $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > interface = blah
+  > interface.chunkselector = blah
+  > EOF
+  $ chunkselectorinterface
+  invalid value for ui.interface: blah
+  invalid value for ui.interface.chunkselector: blah (using text)
+  text