##// END OF EJS Templates
Merge with stable
Matt Mackall -
r10790:ef366845 merge default
parent child Browse files
Show More
@@ -33,6 +33,8 b' The following settings are available::'
33 # (that is, min(width, term width) will be used)
33 # (that is, min(width, term width) will be used)
34 clear-complete = True # clear the progress bar after it's done
34 clear-complete = True # clear the progress bar after it's done
35 disable = False # if true, don't show a progress bar
35 disable = False # if true, don't show a progress bar
36 assume-tty = False # if true, ALWAYS show a progress bar, unless
37 # disable is given
36
38
37 Valid entries for the format field are topic, bar, number, unit, and
39 Valid entries for the format field are topic, bar, number, unit, and
38 item. item defaults to the last 20 characters of the item, but this
40 item. item defaults to the last 20 characters of the item, but this
@@ -131,18 +133,18 b' class progbar(object):'
131 out = spacejoin(head, prog, tail)
133 out = spacejoin(head, prog, tail)
132 else:
134 else:
133 out = spacejoin(head, tail)
135 out = spacejoin(head, tail)
134 sys.stdout.write('\r' + out[:termwidth])
136 sys.stderr.write('\r' + out[:termwidth])
135 sys.stdout.flush()
137 sys.stderr.flush()
136
138
137 def clear(self):
139 def clear(self):
138 sys.stdout.write('\r%s\r' % (' ' * self.width()))
140 sys.stderr.write('\r%s\r' % (' ' * self.width()))
139
141
140 def complete(self):
142 def complete(self):
141 if self.ui.configbool('progress', 'clear-complete', default=True):
143 if self.ui.configbool('progress', 'clear-complete', default=True):
142 self.clear()
144 self.clear()
143 else:
145 else:
144 sys.stdout.write('\n')
146 sys.stderr.write('\n')
145 sys.stdout.flush()
147 sys.stderr.flush()
146
148
147 def width(self):
149 def width(self):
148 tw = util.termwidth()
150 tw = util.termwidth()
@@ -175,7 +177,8 b' def uisetup(ui):'
175 # setconfig('progress', 'disable', 'True') to disable this extension
177 # setconfig('progress', 'disable', 'True') to disable this extension
176 if ui.configbool('progress', 'disable'):
178 if ui.configbool('progress', 'disable'):
177 return
179 return
178 if ui.interactive() and not ui.debugflag and not ui.quiet:
180 if ((sys.stderr.isatty() or ui.configbool('progress', 'assume-tty'))
181 and not ui.debugflag and not ui.quiet):
179 # we instantiate one globally shared progress bar to avoid
182 # we instantiate one globally shared progress bar to avoid
180 # competing progress bars when multiple UI objects get created
183 # competing progress bars when multiple UI objects get created
181 global sharedprog
184 global sharedprog
@@ -1260,7 +1260,7 b' def termwidth():'
1260 pass
1260 pass
1261 try:
1261 try:
1262 import termios, array, fcntl
1262 import termios, array, fcntl
1263 for dev in (sys.stdout, sys.stdin):
1263 for dev in (sys.stderr, sys.stdout, sys.stdin):
1264 try:
1264 try:
1265 try:
1265 try:
1266 fd = dev.fileno()
1266 fd = dev.fileno()
@@ -31,30 +31,29 b' EOF'
31 echo "[extensions]" >> $HGRCPATH
31 echo "[extensions]" >> $HGRCPATH
32 echo "progress=" >> $HGRCPATH
32 echo "progress=" >> $HGRCPATH
33 echo "loop=`pwd`/loop.py" >> $HGRCPATH
33 echo "loop=`pwd`/loop.py" >> $HGRCPATH
34 echo "[ui]" >> $HGRCPATH
34 echo "[progress]" >> $HGRCPATH
35 echo "interactive=1" >> $HGRCPATH
35 echo "assume-tty=1" >> $HGRCPATH
36
36
37 echo '% test default params, display nothing because of delay'
37 echo '% test default params, display nothing because of delay'
38 hg -y loop 3 | python filtercr.py
38 hg -y loop 3 2>&1 | python filtercr.py
39
39
40 echo "[progress]" >> $HGRCPATH
41 echo "delay=0" >> $HGRCPATH
40 echo "delay=0" >> $HGRCPATH
42 echo "refresh=0" >> $HGRCPATH
41 echo "refresh=0" >> $HGRCPATH
43
42
44 echo '% test with delay=0, refresh=0'
43 echo '% test with delay=0, refresh=0'
45 hg -y loop 3 | python filtercr.py
44 hg -y loop 3 2>&1 | python filtercr.py
46
45
47 echo '% test refresh is taken in account'
46 echo '% test refresh is taken in account'
48 hg -y --config progress.refresh=100 loop 3 | python filtercr.py
47 hg -y --config progress.refresh=100 loop 3 2>&1 | python filtercr.py
49
48
50 echo '% test format options 1'
49 echo '% test format options 1'
51 hg -y --config 'progress.format=number topic item+2' loop 2 | python filtercr.py
50 hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 | python filtercr.py
52
51
53 echo '% test format options 2'
52 echo '% test format options 2'
54 hg -y --config 'progress.format=number item-3 bar' loop 2 | python filtercr.py
53 hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 | python filtercr.py
55
54
56 echo '% test format options and indeterminate progress'
55 echo '% test format options and indeterminate progress'
57 hg -y --config 'progress.format=number item bar' loop -- -2 | python filtercr.py
56 hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py
58
57
59 echo '% test immediate progress completion'
58 echo '% test immediate progress completion'
60 hg -y loop 0 | python filtercr.py
59 hg -y loop 0 2>&1 | python filtercr.py
General Comments 0
You need to be logged in to leave comments. Login now