##// END OF EJS Templates
color: don't blow up if configured with unknown color (just warn).
Greg Ward -
r8945:7b3d837c default
parent child Browse files
Show More
@@ -1,266 +1,275 b''
1 # color.py color output for the status and qseries commands
1 # color.py color output for the status and qseries commands
2 #
2 #
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
4 #
4 #
5 # This program is free software; you can redistribute it and/or modify it
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
8 # option) any later version.
9 #
9 #
10 # This program is distributed in the hope that it will be useful, but
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
13 # Public License for more details.
14 #
14 #
15 # You should have received a copy of the GNU General Public License along
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
18
19 '''colorize output from some commands
19 '''colorize output from some commands
20
20
21 This extension modifies the status command to add color to its output
21 This extension modifies the status command to add color to its output
22 to reflect file status, the qseries command to add color to reflect
22 to reflect file status, the qseries command to add color to reflect
23 patch status (applied, unapplied, missing), and to diff-related
23 patch status (applied, unapplied, missing), and to diff-related
24 commands to highlight additions, removals, diff headers, and trailing
24 commands to highlight additions, removals, diff headers, and trailing
25 whitespace.
25 whitespace.
26
26
27 Other effects in addition to color, like bold and underlined text, are
27 Other effects in addition to color, like bold and underlined text, are
28 also available. Effects are rendered with the ECMA-48 SGR control
28 also available. Effects are rendered with the ECMA-48 SGR control
29 function (aka ANSI escape codes). This module also provides the
29 function (aka ANSI escape codes). This module also provides the
30 render_text function, which can be used to add effects to any text.
30 render_text function, which can be used to add effects to any text.
31
31
32 Default effects may be overridden from the .hgrc file:
32 Default effects may be overridden from the .hgrc file:
33
33
34 [color]
34 [color]
35 status.modified = blue bold underline red_background
35 status.modified = blue bold underline red_background
36 status.added = green bold
36 status.added = green bold
37 status.removed = red bold blue_background
37 status.removed = red bold blue_background
38 status.deleted = cyan bold underline
38 status.deleted = cyan bold underline
39 status.unknown = magenta bold underline
39 status.unknown = magenta bold underline
40 status.ignored = black bold
40 status.ignored = black bold
41
41
42 # 'none' turns off all effects
42 # 'none' turns off all effects
43 status.clean = none
43 status.clean = none
44 status.copied = none
44 status.copied = none
45
45
46 qseries.applied = blue bold underline
46 qseries.applied = blue bold underline
47 qseries.unapplied = black bold
47 qseries.unapplied = black bold
48 qseries.missing = red bold
48 qseries.missing = red bold
49
49
50 diff.diffline = bold
50 diff.diffline = bold
51 diff.extended = cyan bold
51 diff.extended = cyan bold
52 diff.file_a = red bold
52 diff.file_a = red bold
53 diff.file_b = green bold
53 diff.file_b = green bold
54 diff.hunk = magenta
54 diff.hunk = magenta
55 diff.deleted = red
55 diff.deleted = red
56 diff.inserted = green
56 diff.inserted = green
57 diff.changed = white
57 diff.changed = white
58 diff.trailingwhitespace = bold red_background
58 diff.trailingwhitespace = bold red_background
59 '''
59 '''
60
60
61 import os, sys
61 import os, sys
62
62
63 from mercurial import cmdutil, commands, extensions
63 from mercurial import cmdutil, commands, extensions
64 from mercurial.i18n import _
64 from mercurial.i18n import _
65
65
66 # start and stop parameters for effects
66 # start and stop parameters for effects
67 _effect_params = {'none': 0,
67 _effect_params = {'none': 0,
68 'black': 30,
68 'black': 30,
69 'red': 31,
69 'red': 31,
70 'green': 32,
70 'green': 32,
71 'yellow': 33,
71 'yellow': 33,
72 'blue': 34,
72 'blue': 34,
73 'magenta': 35,
73 'magenta': 35,
74 'cyan': 36,
74 'cyan': 36,
75 'white': 37,
75 'white': 37,
76 'bold': 1,
76 'bold': 1,
77 'italic': 3,
77 'italic': 3,
78 'underline': 4,
78 'underline': 4,
79 'inverse': 7,
79 'inverse': 7,
80 'black_background': 40,
80 'black_background': 40,
81 'red_background': 41,
81 'red_background': 41,
82 'green_background': 42,
82 'green_background': 42,
83 'yellow_background': 43,
83 'yellow_background': 43,
84 'blue_background': 44,
84 'blue_background': 44,
85 'purple_background': 45,
85 'purple_background': 45,
86 'cyan_background': 46,
86 'cyan_background': 46,
87 'white_background': 47}
87 'white_background': 47}
88
88
89 def render_effects(text, effects):
89 def render_effects(text, effects):
90 'Wrap text in commands to turn on each effect.'
90 'Wrap text in commands to turn on each effect.'
91 start = [str(_effect_params[e]) for e in ['none'] + effects]
91 start = [str(_effect_params[e]) for e in ['none'] + effects]
92 start = '\033[' + ';'.join(start) + 'm'
92 start = '\033[' + ';'.join(start) + 'm'
93 stop = '\033[' + str(_effect_params['none']) + 'm'
93 stop = '\033[' + str(_effect_params['none']) + 'm'
94 return ''.join([start, text, stop])
94 return ''.join([start, text, stop])
95
95
96 def colorstatus(orig, ui, repo, *pats, **opts):
96 def colorstatus(orig, ui, repo, *pats, **opts):
97 '''run the status command with colored output'''
97 '''run the status command with colored output'''
98
98
99 delimiter = opts['print0'] and '\0' or '\n'
99 delimiter = opts['print0'] and '\0' or '\n'
100
100
101 nostatus = opts.get('no_status')
101 nostatus = opts.get('no_status')
102 opts['no_status'] = False
102 opts['no_status'] = False
103 # run status and capture its output
103 # run status and capture its output
104 ui.pushbuffer()
104 ui.pushbuffer()
105 retval = orig(ui, repo, *pats, **opts)
105 retval = orig(ui, repo, *pats, **opts)
106 # filter out empty strings
106 # filter out empty strings
107 lines_with_status = [ line for line in ui.popbuffer().split(delimiter) if line ]
107 lines_with_status = [ line for line in ui.popbuffer().split(delimiter) if line ]
108
108
109 if nostatus:
109 if nostatus:
110 lines = [l[2:] for l in lines_with_status]
110 lines = [l[2:] for l in lines_with_status]
111 else:
111 else:
112 lines = lines_with_status
112 lines = lines_with_status
113
113
114 # apply color to output and display it
114 # apply color to output and display it
115 for i in xrange(len(lines)):
115 for i in xrange(len(lines)):
116 status = _status_abbreviations[lines_with_status[i][0]]
116 status = _status_abbreviations[lines_with_status[i][0]]
117 effects = _status_effects[status]
117 effects = _status_effects[status]
118 if effects:
118 if effects:
119 lines[i] = render_effects(lines[i], effects)
119 lines[i] = render_effects(lines[i], effects)
120 ui.write(lines[i] + delimiter)
120 ui.write(lines[i] + delimiter)
121 return retval
121 return retval
122
122
123 _status_abbreviations = { 'M': 'modified',
123 _status_abbreviations = { 'M': 'modified',
124 'A': 'added',
124 'A': 'added',
125 'R': 'removed',
125 'R': 'removed',
126 '!': 'deleted',
126 '!': 'deleted',
127 '?': 'unknown',
127 '?': 'unknown',
128 'I': 'ignored',
128 'I': 'ignored',
129 'C': 'clean',
129 'C': 'clean',
130 ' ': 'copied', }
130 ' ': 'copied', }
131
131
132 _status_effects = { 'modified': ['blue', 'bold'],
132 _status_effects = { 'modified': ['blue', 'bold'],
133 'added': ['green', 'bold'],
133 'added': ['green', 'bold'],
134 'removed': ['red', 'bold'],
134 'removed': ['red', 'bold'],
135 'deleted': ['cyan', 'bold', 'underline'],
135 'deleted': ['cyan', 'bold', 'underline'],
136 'unknown': ['magenta', 'bold', 'underline'],
136 'unknown': ['magenta', 'bold', 'underline'],
137 'ignored': ['black', 'bold'],
137 'ignored': ['black', 'bold'],
138 'clean': ['none'],
138 'clean': ['none'],
139 'copied': ['none'], }
139 'copied': ['none'], }
140
140
141 def colorqseries(orig, ui, repo, *dummy, **opts):
141 def colorqseries(orig, ui, repo, *dummy, **opts):
142 '''run the qseries command with colored output'''
142 '''run the qseries command with colored output'''
143 ui.pushbuffer()
143 ui.pushbuffer()
144 retval = orig(ui, repo, **opts)
144 retval = orig(ui, repo, **opts)
145 patches = ui.popbuffer().splitlines()
145 patches = ui.popbuffer().splitlines()
146 for patch in patches:
146 for patch in patches:
147 patchname = patch
147 patchname = patch
148 if opts['summary']:
148 if opts['summary']:
149 patchname = patchname.split(': ')[0]
149 patchname = patchname.split(': ')[0]
150 if ui.verbose:
150 if ui.verbose:
151 patchname = patchname.split(' ', 2)[-1]
151 patchname = patchname.split(' ', 2)[-1]
152
152
153 if opts['missing']:
153 if opts['missing']:
154 effects = _patch_effects['missing']
154 effects = _patch_effects['missing']
155 # Determine if patch is applied.
155 # Determine if patch is applied.
156 elif [ applied for applied in repo.mq.applied
156 elif [ applied for applied in repo.mq.applied
157 if patchname == applied.name ]:
157 if patchname == applied.name ]:
158 effects = _patch_effects['applied']
158 effects = _patch_effects['applied']
159 else:
159 else:
160 effects = _patch_effects['unapplied']
160 effects = _patch_effects['unapplied']
161 ui.write(render_effects(patch, effects) + '\n')
161 ui.write(render_effects(patch, effects) + '\n')
162 return retval
162 return retval
163
163
164 _patch_effects = { 'applied': ['blue', 'bold', 'underline'],
164 _patch_effects = { 'applied': ['blue', 'bold', 'underline'],
165 'missing': ['red', 'bold'],
165 'missing': ['red', 'bold'],
166 'unapplied': ['black', 'bold'], }
166 'unapplied': ['black', 'bold'], }
167
167
168 def colorwrap(orig, s):
168 def colorwrap(orig, s):
169 '''wrap ui.write for colored diff output'''
169 '''wrap ui.write for colored diff output'''
170 lines = s.split('\n')
170 lines = s.split('\n')
171 for i, line in enumerate(lines):
171 for i, line in enumerate(lines):
172 stripline = line
172 stripline = line
173 if line and line[0] in '+-':
173 if line and line[0] in '+-':
174 # highlight trailing whitespace, but only in changed lines
174 # highlight trailing whitespace, but only in changed lines
175 stripline = line.rstrip()
175 stripline = line.rstrip()
176 for prefix, style in _diff_prefixes:
176 for prefix, style in _diff_prefixes:
177 if stripline.startswith(prefix):
177 if stripline.startswith(prefix):
178 lines[i] = render_effects(stripline, _diff_effects[style])
178 lines[i] = render_effects(stripline, _diff_effects[style])
179 break
179 break
180 if line != stripline:
180 if line != stripline:
181 lines[i] += render_effects(
181 lines[i] += render_effects(
182 line[len(stripline):], _diff_effects['trailingwhitespace'])
182 line[len(stripline):], _diff_effects['trailingwhitespace'])
183 orig('\n'.join(lines))
183 orig('\n'.join(lines))
184
184
185 def colorshowpatch(orig, self, node):
185 def colorshowpatch(orig, self, node):
186 '''wrap cmdutil.changeset_printer.showpatch with colored output'''
186 '''wrap cmdutil.changeset_printer.showpatch with colored output'''
187 oldwrite = extensions.wrapfunction(self.ui, 'write', colorwrap)
187 oldwrite = extensions.wrapfunction(self.ui, 'write', colorwrap)
188 try:
188 try:
189 orig(self, node)
189 orig(self, node)
190 finally:
190 finally:
191 self.ui.write = oldwrite
191 self.ui.write = oldwrite
192
192
193 def colordiff(orig, ui, repo, *pats, **opts):
193 def colordiff(orig, ui, repo, *pats, **opts):
194 '''run the diff command with colored output'''
194 '''run the diff command with colored output'''
195 oldwrite = extensions.wrapfunction(ui, 'write', colorwrap)
195 oldwrite = extensions.wrapfunction(ui, 'write', colorwrap)
196 try:
196 try:
197 orig(ui, repo, *pats, **opts)
197 orig(ui, repo, *pats, **opts)
198 finally:
198 finally:
199 ui.write = oldwrite
199 ui.write = oldwrite
200
200
201 _diff_prefixes = [('diff', 'diffline'),
201 _diff_prefixes = [('diff', 'diffline'),
202 ('copy', 'extended'),
202 ('copy', 'extended'),
203 ('rename', 'extended'),
203 ('rename', 'extended'),
204 ('old', 'extended'),
204 ('old', 'extended'),
205 ('new', 'extended'),
205 ('new', 'extended'),
206 ('deleted', 'extended'),
206 ('deleted', 'extended'),
207 ('---', 'file_a'),
207 ('---', 'file_a'),
208 ('+++', 'file_b'),
208 ('+++', 'file_b'),
209 ('@', 'hunk'),
209 ('@', 'hunk'),
210 ('-', 'deleted'),
210 ('-', 'deleted'),
211 ('+', 'inserted')]
211 ('+', 'inserted')]
212
212
213 _diff_effects = {'diffline': ['bold'],
213 _diff_effects = {'diffline': ['bold'],
214 'extended': ['cyan', 'bold'],
214 'extended': ['cyan', 'bold'],
215 'file_a': ['red', 'bold'],
215 'file_a': ['red', 'bold'],
216 'file_b': ['green', 'bold'],
216 'file_b': ['green', 'bold'],
217 'hunk': ['magenta'],
217 'hunk': ['magenta'],
218 'deleted': ['red'],
218 'deleted': ['red'],
219 'inserted': ['green'],
219 'inserted': ['green'],
220 'changed': ['white'],
220 'changed': ['white'],
221 'trailingwhitespace': ['bold', 'red_background']}
221 'trailingwhitespace': ['bold', 'red_background']}
222
222
223 def uisetup(ui):
223 def uisetup(ui):
224 '''Initialize the extension.'''
224 '''Initialize the extension.'''
225 _setupcmd(ui, 'diff', commands.table, colordiff, _diff_effects)
225 _setupcmd(ui, 'diff', commands.table, colordiff, _diff_effects)
226 _setupcmd(ui, 'incoming', commands.table, None, _diff_effects)
226 _setupcmd(ui, 'incoming', commands.table, None, _diff_effects)
227 _setupcmd(ui, 'log', commands.table, None, _diff_effects)
227 _setupcmd(ui, 'log', commands.table, None, _diff_effects)
228 _setupcmd(ui, 'outgoing', commands.table, None, _diff_effects)
228 _setupcmd(ui, 'outgoing', commands.table, None, _diff_effects)
229 _setupcmd(ui, 'tip', commands.table, None, _diff_effects)
229 _setupcmd(ui, 'tip', commands.table, None, _diff_effects)
230 _setupcmd(ui, 'status', commands.table, colorstatus, _status_effects)
230 _setupcmd(ui, 'status', commands.table, colorstatus, _status_effects)
231 try:
231 try:
232 mq = extensions.find('mq')
232 mq = extensions.find('mq')
233 _setupcmd(ui, 'qdiff', mq.cmdtable, colordiff, _diff_effects)
233 _setupcmd(ui, 'qdiff', mq.cmdtable, colordiff, _diff_effects)
234 _setupcmd(ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects)
234 _setupcmd(ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects)
235 except KeyError:
235 except KeyError:
236 # The mq extension is not enabled
236 # The mq extension is not enabled
237 pass
237 pass
238
238
239 def _setupcmd(ui, cmd, table, func, effectsmap):
239 def _setupcmd(ui, cmd, table, func, effectsmap):
240 '''patch in command to command table and load effect map'''
240 '''patch in command to command table and load effect map'''
241 def nocolor(orig, *args, **opts):
241 def nocolor(orig, *args, **opts):
242
242
243 if (opts['no_color'] or opts['color'] == 'never' or
243 if (opts['no_color'] or opts['color'] == 'never' or
244 (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
244 (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
245 or not sys.__stdout__.isatty()))):
245 or not sys.__stdout__.isatty()))):
246 return orig(*args, **opts)
246 return orig(*args, **opts)
247
247
248 oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,
248 oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,
249 'showpatch', colorshowpatch)
249 'showpatch', colorshowpatch)
250 try:
250 try:
251 if func is not None:
251 if func is not None:
252 return func(orig, *args, **opts)
252 return func(orig, *args, **opts)
253 return orig(*args, **opts)
253 return orig(*args, **opts)
254 finally:
254 finally:
255 cmdutil.changeset_printer.showpatch = oldshowpatch
255 cmdutil.changeset_printer.showpatch = oldshowpatch
256
256
257 entry = extensions.wrapcommand(table, cmd, nocolor)
257 entry = extensions.wrapcommand(table, cmd, nocolor)
258 entry[1].extend([
258 entry[1].extend([
259 ('', 'color', 'auto', _("when to colorize (always, auto, or never)")),
259 ('', 'color', 'auto', _("when to colorize (always, auto, or never)")),
260 ('', 'no-color', None, _("don't colorize output")),
260 ('', 'no-color', None, _("don't colorize output")),
261 ])
261 ])
262
262
263 for status in effectsmap:
263 for status in effectsmap:
264 effects = ui.configlist('color', cmd + '.' + status)
264 configkey = cmd + '.' + status
265 effects = ui.configlist('color', configkey)
265 if effects:
266 if effects:
266 effectsmap[status] = effects
267 good = []
268 for e in effects:
269 if e in _effect_params:
270 good.append(e)
271 else:
272 ui.warn(_("ignoring unknown color/effect %r "
273 "(configured in color.%s)\n")
274 % (e, configkey))
275 effectsmap[status] = good
@@ -1,97 +1,100 b''
1 #!/bin/sh
1 #!/bin/sh
2
2
3 echo "[extensions]" >> $HGRCPATH
3 echo "[extensions]" >> $HGRCPATH
4 echo "color=" >> $HGRCPATH
4 echo "color=" >> $HGRCPATH
5
5
6 hg init repo1
6 hg init repo1
7 cd repo1
7 cd repo1
8 mkdir a b a/1 b/1 b/2
8 mkdir a b a/1 b/1 b/2
9 touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
9 touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
10 echo "hg status in repo root:"
10 echo "hg status in repo root:"
11 hg status --color=always
11 hg status --color=always
12 echo "hg status . in repo root:"
12 echo "hg status . in repo root:"
13 hg status --color=always .
13 hg status --color=always .
14 for dir in a b a/1 b/1 b/2; do
14 for dir in a b a/1 b/1 b/2; do
15 echo "hg status in $dir:"
15 echo "hg status in $dir:"
16 hg status --color=always --cwd "$dir"
16 hg status --color=always --cwd "$dir"
17 echo "hg status . in $dir:"
17 echo "hg status . in $dir:"
18 hg status --color=always --cwd "$dir" .
18 hg status --color=always --cwd "$dir" .
19 echo "hg status .. in $dir:"
19 echo "hg status .. in $dir:"
20 hg status --color=always --cwd "$dir" ..
20 hg status --color=always --cwd "$dir" ..
21 done
21 done
22 cd ..
22 cd ..
23
23
24 hg init repo2
24 hg init repo2
25 cd repo2
25 cd repo2
26 touch modified removed deleted ignored
26 touch modified removed deleted ignored
27 echo "^ignored$" > .hgignore
27 echo "^ignored$" > .hgignore
28 hg ci -A -m 'initial checkin' -d "1000000 0"
28 hg ci -A -m 'initial checkin' -d "1000000 0"
29 touch modified added unknown ignored
29 touch modified added unknown ignored
30 hg add added
30 hg add added
31 hg remove removed
31 hg remove removed
32 rm deleted
32 rm deleted
33 echo "hg status:"
33 echo "hg status:"
34 hg status --color=always
34 hg status --color=always
35 echo "hg status modified added removed deleted unknown never-existed ignored:"
35 echo "hg status modified added removed deleted unknown never-existed ignored:"
36 hg status --color=always modified added removed deleted unknown never-existed ignored
36 hg status --color=always modified added removed deleted unknown never-existed ignored
37 hg copy modified copied
37 hg copy modified copied
38 echo "hg status -C:"
38 echo "hg status -C:"
39 hg status --color=always -C
39 hg status --color=always -C
40 echo "hg status -A:"
40 echo "hg status -A:"
41 hg status --color=always -A
41 hg status --color=always -A
42 echo "^ignoreddir$" > .hgignore
42 echo "^ignoreddir$" > .hgignore
43 mkdir ignoreddir
43 mkdir ignoreddir
44 touch ignoreddir/file
44 touch ignoreddir/file
45 echo "hg status ignoreddir/file:"
45 echo "hg status ignoreddir/file:"
46 hg status --color=always ignoreddir/file
46 hg status --color=always ignoreddir/file
47 echo "hg status -i ignoreddir/file:"
47 echo "hg status -i ignoreddir/file:"
48 hg status --color=always -i ignoreddir/file
48 hg status --color=always -i ignoreddir/file
49 cd ..
49 cd ..
50
50
51 # check 'status -q' and some combinations
51 # check 'status -q' and some combinations
52 hg init repo3
52 hg init repo3
53 cd repo3
53 cd repo3
54 touch modified removed deleted ignored
54 touch modified removed deleted ignored
55 echo "^ignored$" > .hgignore
55 echo "^ignored$" > .hgignore
56 hg commit -A -m 'initial checkin'
56 hg commit -A -m 'initial checkin'
57 touch added unknown ignored
57 touch added unknown ignored
58 hg add added
58 hg add added
59 echo "test" >> modified
59 echo "test" >> modified
60 hg remove removed
60 hg remove removed
61 rm deleted
61 rm deleted
62 hg copy modified copied
62 hg copy modified copied
63
63
64 echo "% test unknown color"
65 hg --config color.status.modified=periwinkle status --color=always
66
64 # Run status with 2 different flags.
67 # Run status with 2 different flags.
65 # Check if result is the same or different.
68 # Check if result is the same or different.
66 # If result is not as expected, raise error
69 # If result is not as expected, raise error
67 assert() {
70 assert() {
68 hg status --color=always $1 > ../a
71 hg status --color=always $1 > ../a
69 hg status --color=always $2 > ../b
72 hg status --color=always $2 > ../b
70 out=`diff ../a ../b`
73 out=`diff ../a ../b`
71 if [ $? -ne 0 ]; then
74 if [ $? -ne 0 ]; then
72 out=1
75 out=1
73 else
76 else
74 out=0
77 out=0
75 fi
78 fi
76 if [ $3 -eq 0 ]; then
79 if [ $3 -eq 0 ]; then
77 df="same"
80 df="same"
78 else
81 else
79 df="different"
82 df="different"
80 fi
83 fi
81 if [ $out -ne $3 ]; then
84 if [ $out -ne $3 ]; then
82 echo "Error on $1 and $2, should be $df."
85 echo "Error on $1 and $2, should be $df."
83 fi
86 fi
84 }
87 }
85
88
86 # assert flag1 flag2 [0-same | 1-different]
89 # assert flag1 flag2 [0-same | 1-different]
87 assert "-q" "-mard" 0
90 assert "-q" "-mard" 0
88 assert "-A" "-marduicC" 0
91 assert "-A" "-marduicC" 0
89 assert "-qA" "-mardcC" 0
92 assert "-qA" "-mardcC" 0
90 assert "-qAui" "-A" 0
93 assert "-qAui" "-A" 0
91 assert "-qAu" "-marducC" 0
94 assert "-qAu" "-marducC" 0
92 assert "-qAi" "-mardicC" 0
95 assert "-qAi" "-mardicC" 0
93 assert "-qu" "-u" 0
96 assert "-qu" "-u" 0
94 assert "-q" "-u" 1
97 assert "-q" "-u" 1
95 assert "-m" "-a" 1
98 assert "-m" "-a" 1
96 assert "-r" "-d" 1
99 assert "-r" "-d" 1
97
100
@@ -1,126 +1,134 b''
1 hg status in repo root:
1 hg status in repo root:
2 ? a/1/in_a_1
2 ? a/1/in_a_1
3 ? a/in_a
3 ? a/in_a
4 ? b/1/in_b_1
4 ? b/1/in_b_1
5 ? b/2/in_b_2
5 ? b/2/in_b_2
6 ? b/in_b
6 ? b/in_b
7 ? in_root
7 ? in_root
8 hg status . in repo root:
8 hg status . in repo root:
9 ? a/1/in_a_1
9 ? a/1/in_a_1
10 ? a/in_a
10 ? a/in_a
11 ? b/1/in_b_1
11 ? b/1/in_b_1
12 ? b/2/in_b_2
12 ? b/2/in_b_2
13 ? b/in_b
13 ? b/in_b
14 ? in_root
14 ? in_root
15 hg status in a:
15 hg status in a:
16 ? a/1/in_a_1
16 ? a/1/in_a_1
17 ? a/in_a
17 ? a/in_a
18 ? b/1/in_b_1
18 ? b/1/in_b_1
19 ? b/2/in_b_2
19 ? b/2/in_b_2
20 ? b/in_b
20 ? b/in_b
21 ? in_root
21 ? in_root
22 hg status . in a:
22 hg status . in a:
23 ? 1/in_a_1
23 ? 1/in_a_1
24 ? in_a
24 ? in_a
25 hg status .. in a:
25 hg status .. in a:
26 ? 1/in_a_1
26 ? 1/in_a_1
27 ? in_a
27 ? in_a
28 ? ../b/1/in_b_1
28 ? ../b/1/in_b_1
29 ? ../b/2/in_b_2
29 ? ../b/2/in_b_2
30 ? ../b/in_b
30 ? ../b/in_b
31 ? ../in_root
31 ? ../in_root
32 hg status in b:
32 hg status in b:
33 ? a/1/in_a_1
33 ? a/1/in_a_1
34 ? a/in_a
34 ? a/in_a
35 ? b/1/in_b_1
35 ? b/1/in_b_1
36 ? b/2/in_b_2
36 ? b/2/in_b_2
37 ? b/in_b
37 ? b/in_b
38 ? in_root
38 ? in_root
39 hg status . in b:
39 hg status . in b:
40 ? 1/in_b_1
40 ? 1/in_b_1
41 ? 2/in_b_2
41 ? 2/in_b_2
42 ? in_b
42 ? in_b
43 hg status .. in b:
43 hg status .. in b:
44 ? ../a/1/in_a_1
44 ? ../a/1/in_a_1
45 ? ../a/in_a
45 ? ../a/in_a
46 ? 1/in_b_1
46 ? 1/in_b_1
47 ? 2/in_b_2
47 ? 2/in_b_2
48 ? in_b
48 ? in_b
49 ? ../in_root
49 ? ../in_root
50 hg status in a/1:
50 hg status in a/1:
51 ? a/1/in_a_1
51 ? a/1/in_a_1
52 ? a/in_a
52 ? a/in_a
53 ? b/1/in_b_1
53 ? b/1/in_b_1
54 ? b/2/in_b_2
54 ? b/2/in_b_2
55 ? b/in_b
55 ? b/in_b
56 ? in_root
56 ? in_root
57 hg status . in a/1:
57 hg status . in a/1:
58 ? in_a_1
58 ? in_a_1
59 hg status .. in a/1:
59 hg status .. in a/1:
60 ? in_a_1
60 ? in_a_1
61 ? ../in_a
61 ? ../in_a
62 hg status in b/1:
62 hg status in b/1:
63 ? a/1/in_a_1
63 ? a/1/in_a_1
64 ? a/in_a
64 ? a/in_a
65 ? b/1/in_b_1
65 ? b/1/in_b_1
66 ? b/2/in_b_2
66 ? b/2/in_b_2
67 ? b/in_b
67 ? b/in_b
68 ? in_root
68 ? in_root
69 hg status . in b/1:
69 hg status . in b/1:
70 ? in_b_1
70 ? in_b_1
71 hg status .. in b/1:
71 hg status .. in b/1:
72 ? in_b_1
72 ? in_b_1
73 ? ../2/in_b_2
73 ? ../2/in_b_2
74 ? ../in_b
74 ? ../in_b
75 hg status in b/2:
75 hg status in b/2:
76 ? a/1/in_a_1
76 ? a/1/in_a_1
77 ? a/in_a
77 ? a/in_a
78 ? b/1/in_b_1
78 ? b/1/in_b_1
79 ? b/2/in_b_2
79 ? b/2/in_b_2
80 ? b/in_b
80 ? b/in_b
81 ? in_root
81 ? in_root
82 hg status . in b/2:
82 hg status . in b/2:
83 ? in_b_2
83 ? in_b_2
84 hg status .. in b/2:
84 hg status .. in b/2:
85 ? ../1/in_b_1
85 ? ../1/in_b_1
86 ? in_b_2
86 ? in_b_2
87 ? ../in_b
87 ? ../in_b
88 adding .hgignore
88 adding .hgignore
89 adding deleted
89 adding deleted
90 adding modified
90 adding modified
91 adding removed
91 adding removed
92 hg status:
92 hg status:
93 A added
93 A added
94 R removed
94 R removed
95 ! deleted
95 ! deleted
96 ? unknown
96 ? unknown
97 hg status modified added removed deleted unknown never-existed ignored:
97 hg status modified added removed deleted unknown never-existed ignored:
98 never-existed: No such file or directory
98 never-existed: No such file or directory
99 A added
99 A added
100 R removed
100 R removed
101 ! deleted
101 ! deleted
102 ? unknown
102 ? unknown
103 hg status -C:
103 hg status -C:
104 A added
104 A added
105 A copied
105 A copied
106  modified
106  modified
107 R removed
107 R removed
108 ! deleted
108 ! deleted
109 ? unknown
109 ? unknown
110 hg status -A:
110 hg status -A:
111 A added
111 A added
112 A copied
112 A copied
113  modified
113  modified
114 R removed
114 R removed
115 ! deleted
115 ! deleted
116 ? unknown
116 ? unknown
117 I ignored
117 I ignored
118 C .hgignore
118 C .hgignore
119 C modified
119 C modified
120 hg status ignoreddir/file:
120 hg status ignoreddir/file:
121 hg status -i ignoreddir/file:
121 hg status -i ignoreddir/file:
122 I ignoreddir/file
122 I ignoreddir/file
123 adding .hgignore
123 adding .hgignore
124 adding deleted
124 adding deleted
125 adding modified
125 adding modified
126 adding removed
126 adding removed
127 % test unknown color
128 ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
129 M modified
130 A added
131 A copied
132 R removed
133 ! deleted
134 ? unknown
General Comments 0
You need to be logged in to leave comments. Login now