[PATCH 4 of 5 V2] ui: echo prompt choice only if formatted output is acceptable
Yuya Nishihara
yuya at tcha.org
Fri Oct 10 10:09:20 CDT 2014
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1412950877 -32400
# Fri Oct 10 23:21:17 2014 +0900
# Node ID 6dcb36c1781c7afbdcee20c793be20e90854e391
# Parent 80977d0b038a9a42a9b6819e77b80d343c1f711e
ui: echo prompt choice only if formatted output is acceptable
9ab18a912c44 is nice for test output, but it also affects command-server
clients or scripts that have to parse the output. So enables it only if
formatted output is acceptable.
This should cover most of command-server clients but chg.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -684,7 +684,8 @@ class ui(object):
r = default
# sometimes self.interactive disagrees with isatty,
# show response provided on stdin when simulating
- if not self._isatty(self.fin):
+ # but not for commandserver and other scripting
+ if not self._isatty(self.fin) and self.formatted():
self.write(r, "\n")
return r
except EOFError:
diff --git a/tests/test-diff-color.t b/tests/test-diff-color.t
--- a/tests/test-diff-color.t
+++ b/tests/test-diff-color.t
@@ -69,6 +69,7 @@ diffstat
$ cat <<EOF >> $HGRCPATH
> record =
> [ui]
+ > formatted = true
> interactive = true
> [diff]
> git = True
diff --git a/tests/test-issue3084.t b/tests/test-issue3084.t
--- a/tests/test-issue3084.t
+++ b/tests/test-issue3084.t
@@ -2,6 +2,8 @@
$ cat <<EOF >> $HGRCPATH
> [extensions]
> largefiles =
+ > [ui]
+ > formatted = true
> EOF
Create the repository outside $HOME since largefiles write to
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -6,6 +6,7 @@
> record =
> transplant =
> [ui]
+ > formatted = true
> interactive = true
> EOF
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -3,6 +3,7 @@ directory (and ".hg/largefiles/dirstate"
$ cat >> $HGRCPATH <<EOF
> [ui]
+ > formatted = true
> merge = internal:fail
> [extensions]
> largefiles =
diff --git a/tests/test-merge-prompt.t b/tests/test-merge-prompt.t
--- a/tests/test-merge-prompt.t
+++ b/tests/test-merge-prompt.t
@@ -65,6 +65,7 @@ Interactive merge:
$ cat <<EOF >> $HGRCPATH
> [ui]
+ > formatted = true
> interactive = true
> EOF
diff --git a/tests/test-mq-qrefresh-interactive.t b/tests/test-mq-qrefresh-interactive.t
--- a/tests/test-mq-qrefresh-interactive.t
+++ b/tests/test-mq-qrefresh-interactive.t
@@ -2,6 +2,7 @@ Create configuration
$ cat <<EOF >> $HGRCPATH
> [ui]
+ > formatted = true
> interactive = true
> EOF
diff --git a/tests/test-mq-subrepo.t b/tests/test-mq-subrepo.t
--- a/tests/test-mq-subrepo.t
+++ b/tests/test-mq-subrepo.t
@@ -284,6 +284,7 @@ handle subrepos safely on qrecord
$ mkrepo repo-2499-qrecord
$ cat <<EOF >> .hg/hgrc
> [ui]
+ > formatted = true
> interactive = true
> EOF
$ testadd qrecord -m0 0.diff <<EOF
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -67,7 +67,8 @@ Mercurial-patchbomb/.* -> Mercurial-patc
+a
- $ hg --config ui.interactive=1 email --confirm -n -f quux -t foo -c bar -r tip<<EOF
+ $ hg --config ui.formatted=1 --config ui.interactive=1 \
+ > email --confirm -n -f quux -t foo -c bar -r tip <<EOF
> n
> EOF
this patch series consists of 1 patches.
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -2,6 +2,7 @@ Create configuration
$ cat <<EOF >> $HGRCPATH
> [ui]
+ > formatted = true
> interactive = true
> EOF
diff --git a/tests/test-record.t b/tests/test-record.t
--- a/tests/test-record.t
+++ b/tests/test-record.t
@@ -2,6 +2,7 @@ Set up a repo
$ cat <<EOF >> $HGRCPATH
> [ui]
+ > formatted = true
> interactive = true
> [extensions]
> record =
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -499,7 +499,8 @@ test interactive transplant
|/
o 0:17ab29e464c6
- $ hg transplant -q --config ui.interactive=true -s ../t <<EOF
+ $ hg transplant -q --config ui.formatted=true --config ui.interactive=true \
+ > -s ../t <<EOF
> p
> y
> n
@@ -531,7 +532,8 @@ test interactive transplant
|/
o 17ab29e464c6
- $ hg transplant -q --config ui.interactive=true -s ../t <<EOF
+ $ hg transplant -q --config ui.formatted=true --config ui.interactive=true \
+ > -s ../t <<EOF
> x
> ?
> y
More information about the Mercurial-devel
mailing list