Mercurial > hg > mercurial-source
comparison tests/test-diff-color.t @ 31889:7fec37746417
color: add a 'ui.color' option to control color behavior
This new option control whether or not color will be used. It mirror the behavior
of '--color'. I usually avoid adding new option to '[ui]' as the section is
already filled with many option. However, I feel like 'color' is central enough
to deserves a spot in this '[ui]' section.
For now the option is not documented so it is still marked as experimental. Once
it get documented and official, we should be able to deprecate the color
extensions.
There is more cleanup to do before that documentation is written, but we need
this option early to made them. Having that option will allow for more cleanup
of the initialisation process and proper separation between color
configuration.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sat, 25 Feb 2017 19:44:23 +0100 |
parents | c84a07530040 |
children | 9a85ea1daf49 |
comparison
equal
deleted
inserted
replaced
31888:53230c5bb273 | 31889:7fec37746417 |
---|---|
1 Setup | 1 Setup |
2 | 2 |
3 $ cat <<EOF >> $HGRCPATH | 3 $ cat <<EOF >> $HGRCPATH |
4 > [ui] | |
5 > color = always | |
4 > [color] | 6 > [color] |
5 > mode = ansi | 7 > mode = ansi |
6 > [extensions] | |
7 > color = | |
8 > EOF | 8 > EOF |
9 $ hg init repo | 9 $ hg init repo |
10 $ cd repo | 10 $ cd repo |
11 $ cat > a <<EOF | 11 $ cat > a <<EOF |
12 > c | 12 > c |
33 > c | 33 > c |
34 > EOF | 34 > EOF |
35 | 35 |
36 default context | 36 default context |
37 | 37 |
38 $ hg diff --nodates --color=always | 38 $ hg diff --nodates |
39 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) | 39 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) |
40 \x1b[0;31;1m--- a/a\x1b[0m (esc) | 40 \x1b[0;31;1m--- a/a\x1b[0m (esc) |
41 \x1b[0;32;1m+++ b/a\x1b[0m (esc) | 41 \x1b[0;32;1m+++ b/a\x1b[0m (esc) |
42 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc) | 42 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc) |
43 c | 43 c |
49 a | 49 a |
50 c | 50 c |
51 | 51 |
52 --unified=2 | 52 --unified=2 |
53 | 53 |
54 $ hg diff --nodates -U 2 --color=always | 54 $ hg diff --nodates -U 2 |
55 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) | 55 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) |
56 \x1b[0;31;1m--- a/a\x1b[0m (esc) | 56 \x1b[0;31;1m--- a/a\x1b[0m (esc) |
57 \x1b[0;32;1m+++ b/a\x1b[0m (esc) | 57 \x1b[0;32;1m+++ b/a\x1b[0m (esc) |
58 \x1b[0;35m@@ -3,5 +3,5 @@\x1b[0m (esc) | 58 \x1b[0;35m@@ -3,5 +3,5 @@\x1b[0m (esc) |
59 a | 59 a |
63 a | 63 a |
64 a | 64 a |
65 | 65 |
66 diffstat | 66 diffstat |
67 | 67 |
68 $ hg diff --stat --color=always | 68 $ hg diff --stat |
69 a | 2 \x1b[0;32m+\x1b[0m\x1b[0;31m-\x1b[0m (esc) | 69 a | 2 \x1b[0;32m+\x1b[0m\x1b[0;31m-\x1b[0m (esc) |
70 1 files changed, 1 insertions(+), 1 deletions(-) | 70 1 files changed, 1 insertions(+), 1 deletions(-) |
71 $ cat <<EOF >> $HGRCPATH | 71 $ cat <<EOF >> $HGRCPATH |
72 > [extensions] | |
72 > record = | 73 > record = |
73 > [ui] | 74 > [ui] |
74 > interactive = true | 75 > interactive = true |
75 > [diff] | 76 > [diff] |
76 > git = True | 77 > git = True |
79 #if execbit | 80 #if execbit |
80 | 81 |
81 record | 82 record |
82 | 83 |
83 $ chmod +x a | 84 $ chmod +x a |
84 $ hg record --color=always -m moda a <<EOF | 85 $ hg record -m moda a <<EOF |
85 > y | 86 > y |
86 > y | 87 > y |
87 > EOF | 88 > EOF |
88 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | 89 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
89 \x1b[0;36;1mold mode 100644\x1b[0m (esc) | 90 \x1b[0;36;1mold mode 100644\x1b[0m (esc) |
109 repository tip rolled back to revision 0 (undo commit) | 110 repository tip rolled back to revision 0 (undo commit) |
110 working directory now based on revision 0 | 111 working directory now based on revision 0 |
111 | 112 |
112 qrecord | 113 qrecord |
113 | 114 |
114 $ hg qrecord --color=always -m moda patch <<EOF | 115 $ hg qrecord -m moda patch <<EOF |
115 > y | 116 > y |
116 > y | 117 > y |
117 > EOF | 118 > EOF |
118 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | 119 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
119 \x1b[0;36;1mold mode 100644\x1b[0m (esc) | 120 \x1b[0;36;1mold mode 100644\x1b[0m (esc) |
149 $ hg add .hgsub | 150 $ hg add .hgsub |
150 $ hg commit -m 'add subrepo sub' | 151 $ hg commit -m 'add subrepo sub' |
151 $ echo aa >> a | 152 $ echo aa >> a |
152 $ echo bb >> sub/b | 153 $ echo bb >> sub/b |
153 | 154 |
154 $ hg diff --color=always -S | 155 $ hg diff -S |
155 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | 156 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
156 \x1b[0;31;1m--- a/a\x1b[0m (esc) | 157 \x1b[0;31;1m--- a/a\x1b[0m (esc) |
157 \x1b[0;32;1m+++ b/a\x1b[0m (esc) | 158 \x1b[0;32;1m+++ b/a\x1b[0m (esc) |
158 \x1b[0;35m@@ -7,3 +7,4 @@\x1b[0m (esc) | 159 \x1b[0;35m@@ -7,3 +7,4 @@\x1b[0m (esc) |
159 a | 160 a |
174 > two tabs | 175 > two tabs |
175 > end tab | 176 > end tab |
176 > mid tab | 177 > mid tab |
177 > all tabs | 178 > all tabs |
178 > EOF | 179 > EOF |
179 $ hg diff --nodates --color=always | 180 $ hg diff --nodates |
180 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | 181 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
181 \x1b[0;31;1m--- a/a\x1b[0m (esc) | 182 \x1b[0;31;1m--- a/a\x1b[0m (esc) |
182 \x1b[0;32;1m+++ b/a\x1b[0m (esc) | 183 \x1b[0;32;1m+++ b/a\x1b[0m (esc) |
183 \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) | 184 \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) |
184 a | 185 a |
190 \x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc) | 191 \x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc) |
191 \x1b[0;32m+mid\x1b[0m \x1b[0;32mtab\x1b[0m (esc) | 192 \x1b[0;32m+mid\x1b[0m \x1b[0;32mtab\x1b[0m (esc) |
192 \x1b[0;32m+\x1b[0m \x1b[0;32mall\x1b[0m \x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc) | 193 \x1b[0;32m+\x1b[0m \x1b[0;32mall\x1b[0m \x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc) |
193 $ echo "[color]" >> $HGRCPATH | 194 $ echo "[color]" >> $HGRCPATH |
194 $ echo "diff.tab = bold magenta" >> $HGRCPATH | 195 $ echo "diff.tab = bold magenta" >> $HGRCPATH |
195 $ hg diff --nodates --color=always | 196 $ hg diff --nodates |
196 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | 197 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
197 \x1b[0;31;1m--- a/a\x1b[0m (esc) | 198 \x1b[0;31;1m--- a/a\x1b[0m (esc) |
198 \x1b[0;32;1m+++ b/a\x1b[0m (esc) | 199 \x1b[0;32;1m+++ b/a\x1b[0m (esc) |
199 \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) | 200 \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) |
200 a | 201 a |